Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
vadim committed Dec 17, 2024
1 parent 1073ba5 commit 6102ad4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,20 @@ jobs:
uses: docker/setup-buildx-action@v1
- name: Run Docker Compose
run: docker compose up -d
- uses: actions/setup-python@v1
with:
python-version: '3.12'
architecture: 'x64'
- name: Install requirements
# Устанавливаем зависимости
run: pip install -r requirements.txt
- name: Run tests
run: coverage run -m pytest
- name: Tests report
run: coverage report
- name: Start test Code with black
uses: psf/black@stable
with:
options: "--check --verbose"
src: "./app"
version: "~= 22.0"

version: "~= 22.0"
25 changes: 25 additions & 0 deletions tests/test_application.py
Original file line number Diff line number Diff line change
@@ -1 +1,26 @@
import pytest
import requests
import json

# тест на создание пользователя и проверку успешного создания
def test_create_user():
user = {"name": "Fred", "address": "Moscow25", "coffee_id":"1", "has_sale": "1"}
url = "http://localhost/add_user"
r = requests.post(url, data=user)
try:
r.raise_for_status()
except requests.exceptions.HTTPError as e:
print('ERROR: %s' % e)
assert r.status_code == 201

def test_find_user_by_country():
example_user = json.dumps({"name": "Fred", "address": "Moscow25", "coffee_id":"1", "has_sale": "1"})
url = "http://localhost/users_by_country"
country = json.dumps({"country": "Moscow25"})
r = requests.get(url, country)
try:
r.raise_for_status()
except requests.exceptions.HTTPError as e:
print('ERROR: %s' % e)
user = json.loads(r.data)
assert example_user == user

0 comments on commit 6102ad4

Please sign in to comment.