-
Notifications
You must be signed in to change notification settings - Fork 0
QA 104 Тест Создание профиля лектора #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
GinKo314
wants to merge
5
commits into
main
Choose a base branch
from
gamma
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import os | ||
| from dotenv import load_dotenv | ||
| from pathlib import Path | ||
| #BASE_DIR = Path(__file__).resolve().parent.parent | ||
| #os.getenv("/.env/.env") # Можно переопределить через ОС | ||
|
|
||
|
|
||
| load_dotenv("C:/.env/.env") | ||
|
Temmmmmo marked this conversation as resolved.
Outdated
|
||
| # Загружает переменные из .env файла | ||
|
|
||
| # Теперь их можно использовать в тестах | ||
| api_token = os.getenv("API_TOKEN") | ||
| base_url = os.getenv("BASE_URL") | ||
|
Temmmmmo marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import requests | ||
| import pytest | ||
| import json | ||
| from conftest import api_token, base_url #env_path | ||
|
|
||
| I = 5896550 | ||
|
Temmmmmo marked this conversation as resolved.
Outdated
|
||
| #BASE_URL | ||
| #token_test | ||
|
|
||
| headers = { | ||
| "Authorization": api_token | ||
| } | ||
|
Temmmmmo marked this conversation as resolved.
Outdated
|
||
|
|
||
| @pytest.mark.parametrize("first_name, last_name, timetable_id, expected_status", [ | ||
|
Temmmmmo marked this conversation as resolved.
Outdated
|
||
| ("Николай", "Николаев", I, 200), | ||
|
|
||
| ("Николай", 999, I, 422), | ||
| (999, "Николаев", I, 422), | ||
| (999, 999, I, 422), | ||
| ("", "Николаев", I, 200), | ||
| ("Николай", "", I, 200), | ||
| ("", "", I, 200), | ||
| (999, "", I, 422), | ||
| ("", 999, I, 422), | ||
| ("string", "Николаев", I, 200), | ||
| ("string", 999, I, 422), | ||
| (999, "string", I, 422), | ||
| ("Николай", "string", I, 200), | ||
| ("string", "", I, 200), | ||
| ("", "string", I, 200), | ||
| ("string", "string", I, 200), | ||
| ("Николай", "Николаев", "ag", 422), | ||
| ("Николай", 999, "ag", 422), | ||
| (999, "Николаев", "ag", 422), | ||
| (999, 999, "ag", 422), | ||
| ("", "Николаев", "ag", 422), | ||
| ("Николай", "", "ag", 422), | ||
| ("", "", "ag", 422), | ||
| (999, "", "ag", 422), | ||
| ("", 999, "ag", 422), | ||
| ("string", "Николаев", "ag", 422), | ||
| ("string", 999, "ag", 422), | ||
| (999, "string", "ag", 422), | ||
| ("Николай", "string", "ag", 422), | ||
| ("string", "", "ag", 422), | ||
| ("", "string", "ag", 422), | ||
| ("string", "string", "ag", 422) | ||
| ]) | ||
| def test_create_profile(first_name, last_name, timetable_id, expected_status): | ||
| url = f"{base_url}/lecturer" | ||
| data = { | ||
| "first_name": first_name, | ||
| "last_name": last_name, | ||
| "middle_name": "Иванович", | ||
| "avatar_link": "", | ||
| "timetable_id": timetable_id | ||
| } | ||
|
|
||
| response = requests.post(url, headers=headers, json=data) | ||
| assert response.status_code == expected_status | ||
| response_json = response.json() | ||
| print(json.dumps(response.json(), indent=2, ensure_ascii=False)) | ||
|
Temmmmmo marked this conversation as resolved.
Outdated
|
||
| #assert response_json["first_name"] == data["first_name"] | ||
| #assert response_json["last_name"] == data["last_name"] | ||
| #assert data["timetable_id"] == response_json["timetable_id"] | ||
|
Temmmmmo marked this conversation as resolved.
Outdated
|
||
|
|
||
| if expected_status == 200: | ||
| #проверка_поста | ||
| get_response = requests.get(f"{url}/{response_json['id']}") | ||
| assert get_response.status_code == 200 | ||
| assert get_response.json()["first_name"] == data["first_name"] | ||
| assert get_response.json()["last_name"] == data["last_name"] | ||
| print(json.dumps(response.json(), indent=2, ensure_ascii=False)) | ||
|
Temmmmmo marked this conversation as resolved.
Outdated
|
||
| #удаление_поста | ||
| delete_response = requests.delete(f"{url}/{response_json['id']}", headers=headers) | ||
| print(delete_response) | ||
|
Temmmmmo marked this conversation as resolved.
Outdated
|
||
| assert delete_response.status_code == 200 | ||
| # проверка_удалённого_поста | ||
| get_deleted_response = requests.get(f"{url}/{response_json['id']}") | ||
| assert get_deleted_response.status_code == 404 | ||
| print(json.dumps(response.json(), indent=2, ensure_ascii=False)) | ||
|
Temmmmmo marked this conversation as resolved.
Outdated
|
||
|
Temmmmmo marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import requests | ||
| import pytest | ||
| from conftest import base_url | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| @pytest.mark.parametrize("first_name, last_name, timetable_id, expected_status", [ | ||
| ("Николай", "Николаев", 100, 403), | ||
| ("Николай", 999, 100, 403), | ||
| (999, "Николаев", 100, 403), | ||
| (999, 999, 100, 403), | ||
| ("", "Николаев", 100, 403), | ||
| ("Николай", "", 100, 403), | ||
| ("", "", 100, 403), | ||
| (999, "", 100, 403), | ||
| ("", 999, 100, 403), | ||
| ("string", "Николаев", 100, 403), | ||
| ("string", 999, 100, 403), | ||
| (999, "string", 100, 403), | ||
| ("Николай", "string", 100, 403), | ||
| ("string", "", 100, 403), | ||
| ("", "string", 100, 403), | ||
| ("string", "string", 100, 403), | ||
| ("Николай", "Николаев", "ag", 403), | ||
| ("Николай", 999, "ag", 403), | ||
| (999, "Николаев", "ag", 403), | ||
| (999, 999, "ag", 403), | ||
| ("", "Николаев", "ag", 403), | ||
| ("Николай", "", "ag", 403), | ||
| ("", "", "ag", 403), | ||
| (999, "", "ag", 403), | ||
| ("", 999, "ag", 403), | ||
| ("string", "Николаев", "ag", 403), | ||
| ("string", 999, "ag", 403), | ||
| (999, "string", "ag", 403), | ||
| ("Николай", "string", "ag", 403), | ||
| ("string", "", "ag", 403), | ||
| ("", "string", "ag", 403), | ||
| ("string", "string", "ag", 403) | ||
| ]) | ||
| def test_create_profile(first_name, last_name, timetable_id, expected_status): | ||
| url = f"{base_url}/lecturer" | ||
| data = { | ||
| "first_name":first_name, | ||
| "last_name":last_name, | ||
| "middle_name": "Иванович", | ||
| "avatar_link": "", | ||
| "timetable_id": 0 | ||
| } | ||
|
|
||
| response = requests.post(url, json=data) | ||
| assert response.status_code == expected_status | ||
| response_json = response.json() | ||
|
|
||
|
|
||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.