Skip to content
This repository was archived by the owner on Nov 11, 2022. It is now read-only.

Commit f16c128

Browse files
Trying to add PyTest GitHub actions
1 parent a669b20 commit f16c128

File tree

5 files changed

+69
-28
lines changed

5 files changed

+69
-28
lines changed

.github/workflows/run-pytest.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Test Django-Rest-Framework application via PyTest
2+
3+
on: [push]
4+
5+
jobs:
6+
runtest:
7+
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Set up Python 3.9
13+
uses: actions/setup-python@v2
14+
with:
15+
python-version: 3.9
16+
- name: Install dependencies
17+
run: |
18+
python -m pip install --upgrade pip
19+
pip install -r requirements.txt
20+
pip install pytest-django
21+
- name: Run migrations
22+
run: |
23+
python manage.py migrate
24+
- name: Run tests
25+
run: |
26+
python -m coverage run -m pytest
27+
python -m coverage report

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
2. `docker-compose exec web python manage.py makemigrations --noinput`
5959
3. `docker-compose exec web python manage.py migrate --noinput`
6060
4. [optional] `docker-compose exec web python manage.py createsuperuser`
61-
8. [Auto running:](https://winitpro.ru/index.php/2019/10/11/avtozagruzka-servisov-i-skriptov-v-linux/)
61+
8. [Auto running in container:](https://winitpro.ru/index.php/2019/10/11/avtozagruzka-servisov-i-skriptov-v-linux/)
6262
9. `sudo touch /etc/systemd/system/test-script.service`
6363
10. `sudo chmod 664 /etc/systemd/system/test-script.service`
6464
11. `sudo nano /etc/systemd/system/test-script.service`

tests/data.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
"items": [
33
{
44
'type': 'CATEGORY',
5-
'name': 'Товары',
5+
'name': 'Все товары',
66
'id': '069cb8d7-bbdd-47d3-ad8f-82ef4c269df1',
77
'parentId': None
88
}
99
],
10-
'updateDate': '2022-02-01T12:00:00.000Z'
10+
'updateDate': '2022-04-01T12:00:00.000Z'
1111
}
1212

1313
INVALID: dict = {
@@ -19,95 +19,95 @@
1919
'parentId': None
2020
}
2121
],
22-
'updateDate': '2022-02-01T12:00:00.000Z'
22+
'updateDate': '2022-04-02T12:00:00.000Z'
2323
}
2424

2525
DATA_1: dict = {
2626
'items': [
2727
{
2828
'type': 'CATEGORY',
29-
'name': 'Товары',
29+
'name': 'Все товары',
3030
'id': '069cb8d7-bbdd-47d3-ad8f-82ef4c269df1',
3131
'parentId': None
3232
}
3333
],
34-
'updateDate': '2022-02-01T12:00:00.000Z'
34+
'updateDate': '2022-04-01T12:00:00.000Z'
3535
}
3636

3737
DATA_2: dict = {
3838
'items': [
3939
{
4040
'type': 'CATEGORY',
41-
'name': 'Смартфоны',
41+
'name': 'Ноутбуки',
4242
'id': 'd515e43f-f3f6-4471-bb77-6b455017a2d2',
4343
'parentId': '069cb8d7-bbdd-47d3-ad8f-82ef4c269df1'
4444
},
4545
{
4646
'type': 'OFFER',
47-
'name': 'jPhone 13',
47+
'name': 'Appple Mucbook Pro 14',
4848
'id': '863e1a7a-1304-42ae-943b-179184c077e3',
4949
'parentId': 'd515e43f-f3f6-4471-bb77-6b455017a2d2',
50-
'price': 79999
50+
'price': 10000
5151
},
5252
{
5353
'type': 'OFFER',
54-
'name': 'Xomiа Readme 10',
54+
'name': 'Appple Mucbook Air M2',
5555
'id': 'b1d8fd7d-2ae3-47d5-b2f9-0f094af800d4',
5656
'parentId': 'd515e43f-f3f6-4471-bb77-6b455017a2d2',
57-
'price': 59999
57+
'price': 5000
5858
}
5959
],
60-
'updateDate': '2022-02-02T12:00:00.000Z'
60+
'updateDate': '2022-04-03T12:00:00.000Z'
6161
}
6262

6363
DATA_3: dict = {
6464
'items': [
6565
{
6666
'type': 'CATEGORY',
67-
'name': 'Телевизоры',
67+
'name': 'Смартфоны',
6868
'id': '1cc0129a-2bfe-474c-9ee6-d435bf5fc8f2',
6969
'parentId': '069cb8d7-bbdd-47d3-ad8f-82ef4c269df1'
7070
},
7171
{
7272
'type': 'OFFER',
73-
'name': 'Samson 70\" LED UHD Smart',
73+
'name': 'Hooawei P50 Pro',
7474
'id': '98883e8f-0507-482f-bce2-2fb306cf6483',
7575
'parentId': '1cc0129a-2bfe-474c-9ee6-d435bf5fc8f2',
76-
'price': 32999
76+
'price': 10000
7777
},
7878
{
7979
'type': 'OFFER',
80-
'name': 'Phyllis 50\" LED UHD Smarter',
80+
'name': 'Gugle Pixel 6',
8181
'id': '74b81fda-9cdc-4b63-8927-c978afed5cf4',
8282
'parentId': '1cc0129a-2bfe-474c-9ee6-d435bf5fc8f2',
83-
'price': 49999
83+
'price': 2000
8484
}
8585
],
86-
'updateDate': '2022-02-03T12:00:00.000Z'
86+
'updateDate': '2022-04-04T12:00:00.000Z'
8787
}
8888

8989
DATA_4: dict = {
9090
'items': [
9191
{
9292
'type': 'OFFER',
93-
'name': 'Goldstar 65\" LED UHD LOL Very Smart',
93+
'name': 'Appple Ifone 13 Pro',
9494
'id': '73bc3b36-02d1-4245-ab35-3106c9ee1c65',
9595
'parentId': '1cc0129a-2bfe-474c-9ee6-d435bf5fc8f2',
96-
'price': 69999
96+
'price': 3000
9797
}
9898
],
99-
'updateDate': '2022-02-03T16:00:00.000Z'
99+
'updateDate': '2022-04-05T16:00:00.000Z'
100100
}
101101

102102
DATA_5: dict = {
103103
'items': [
104104
{
105105
'type': 'OFFER',
106-
'name': 'Goldstar 65\" LED UHD LOL Very Smart',
107-
'id': '73bc3b36-02d1-4245-ab35-3106c9ee1c65',
108-
'parentId': 'd515e43f-f3f6-4471-bb77-6b455017a2d2',
109-
'price': 58000
106+
'name': 'Gugle Pixel 6',
107+
'id': '74b81fda-9cdc-4b63-8927-c978afed5cf4',
108+
'parentId': '1cc0129a-2bfe-474c-9ee6-d435bf5fc8f2',
109+
'price': 2300
110110
}
111111
],
112-
'updateDate': '2022-02-03T16:00:00.000Z'
112+
'updateDate': '2022-04-06T16:00:00.000Z'
113113
}

tests/test_node.py renamed to tests/test_nodes.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,29 @@ def test_nodes():
1717
response = client.post(path='/imports', data=DATA_3, format='json')
1818
assert response.status_code == 200
1919

20+
response = client.get(path='/nodes/1cc0129a-2bfe-474c-9ee6-d435bf5fc8f2', format='json')
21+
assert response.status_code == 200
22+
assert response.data['price'] == 6000
23+
2024
response = client.post(path='/imports', data=DATA_4, format='json')
2125
assert response.status_code == 200
2226

27+
response = client.get(path='/nodes/1cc0129a-2bfe-474c-9ee6-d435bf5fc8f2', format='json')
28+
assert response.status_code == 200
29+
assert response.data['price'] == 5000
30+
2331
response = client.post(path='/imports', data=DATA_5, format='json')
2432
assert response.status_code == 200
2533

26-
response = client.get(path='/nodes/d515e43f-f3f6-4471-bb77-6b455017a2d2')
34+
response = client.get(path='/nodes/1cc0129a-2bfe-474c-9ee6-d435bf5fc8f2')
2735
assert response.status_code == 200
2836
assert response.data['name'] == 'Смартфоны'
37+
assert response.data['price'] == 5100
38+
39+
response = client.get(path='/nodes/d515e43f-f3f6-4471-bb77-6b455017a2d2')
40+
assert response.status_code == 200
41+
assert response.data['name'] == 'Ноутбуки'
42+
assert response.data['price'] == 7500
2943

3044
response = client.get(path='/nodes/d515e43ffbb776b455017a2d2')
3145
assert response.status_code == 400

unit_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import urllib.parse
77
import urllib.request
88

9-
API_BASEURL = 'http://127.0.0.1:8000'
9+
API_BASEURL = 'https://responses-1920.usr.yandex-academy.ru'
1010

1111

1212
ROOT_ID = "069cb8d7-bbdd-47d3-ad8f-82ef4c269df1"

0 commit comments

Comments
 (0)