Skip to content

Commit

Permalink
add test_loader, github_actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Den2909 committed Dec 10, 2023
1 parent 24236f1 commit 04e9d9f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ jobs:
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Run tests
run: |
python -m pytest ./src/model/test_loader.py
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
![Tests](https://github.com/pyretttt/unigoto/actions/workflows/python-app.yml/badge.svg)

# unigoto

## Запуск сервера FastAPI
Expand Down
32 changes: 32 additions & 0 deletions src/model/test_loader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import pytest
import json
from .loader import SyncedLoader
import os

@pytest.mark.asyncio
async def test_synced_loader():
token = 'RHWBuMDebpkT8HNvPYw'
base_url = 'http://45.91.8.110'
request_limit_per_min = 10
output = 'output.csv'
pages = [1, 2, 3]

try:
# Создание экземпляра SyncedLoader
loader = SyncedLoader(token, base_url, request_limit_per_min, output)

# Запуск загрузки страниц
await loader.load(pages)

# Проверка наличия столбцов в файле
with open(output, 'r') as f:
header_line = f.readline().strip()
assert "about" in header_line
assert "activities" in header_line
assert "books" in header_line
assert "games" in header_line
assert "interests" in header_line

finally:
# Удаление файла после выполнения теста
os.remove(output)

0 comments on commit 04e9d9f

Please sign in to comment.