-
Notifications
You must be signed in to change notification settings - Fork 58
First two exercise for review #1
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
03a8732
First two exercise for review
NikitaTiv 052e5d4
Adding 3 last tasks
NikitaTiv 1493d19
Удалил ненужные текстуры, поправил названия
NikitaTiv 4ddc607
Исправил текстуру списка с банккартами и добавил текстуру сегодня, за…
NikitaTiv 0918597
fail
NikitaTiv 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 @@ | ||
| __pycache__/ |
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,59 @@ | ||
| import pytest | ||
| import datetime | ||
| from functions.four_bank_parser import SmsMessage, Expense, BankCard | ||
| from decimal import Decimal | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def long_string(): | ||
| return ''.join('s' for n in range(100)) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def sms_text(): | ||
| return '1020 руб, 4400430255123326 20.02.23 16:20 7/11 authcode 3034' | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def sms_message(sms_text): | ||
| return SmsMessage( | ||
| text=sms_text, | ||
| author="Sberbank", | ||
| sent_at=datetime.datetime(2023, 2, 20, 16, 20, 20), | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def bank_cards(bank_card): | ||
| return [ | ||
| bank_card, | ||
| BankCard(last_digits='1815', owner='Olga N.'), | ||
| BankCard(last_digits='1855', owner='Roman G.'), | ||
| ] | ||
|
|
||
| @pytest.fixture | ||
| def bank_card(): | ||
| return BankCard( | ||
| last_digits='3326', | ||
| owner='Nikita T.', | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def expense(bank_card): | ||
| return Expense( | ||
| amount=Decimal('1020'), | ||
| card=bank_card, | ||
| spent_in='7/11', | ||
| spent_at=datetime.datetime(2023, 2, 20, 16, 20), | ||
| ) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def today(): | ||
| return datetime.date.today() | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def yesterday(today): | ||
| return today + datetime.timedelta(days=1) |
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 |
|---|---|---|
| @@ -1,5 +1,17 @@ | ||
| from functions.five_title import change_copy_item | ||
| import pytest | ||
|
|
||
|
|
||
| def test_change_copy_item(): | ||
| pass | ||
| @pytest.mark.parametrize( | ||
| 'title, max_main_item_title_length, expected_result', | ||
| [ | ||
| (pytest.lazy_fixture('long_string'), 100, pytest.lazy_fixture('long_string')), | ||
| ('string', 100, 'Copy of string'), | ||
| ('Copy of string (2)', 100, 'Copy of string (3)'), | ||
| ('Copy of string', 100,'Copy of string (2)'), | ||
| ('Copy of string (2+)', 100, 'Copy of string (2+) (2)'), | ||
| ('(2)', 100, 'Copy of (2)'), | ||
| ] | ||
| ) | ||
| def test_change_copy_item(title, max_main_item_title_length, expected_result): | ||
| assert change_copy_item(title, max_main_item_title_length) == expected_result |
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 |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| from functions.four_bank_parser import BankCard, SmsMessage, Expense, parse_ineco_expense | ||
|
|
||
|
|
||
| def test_parse_ineco_expense(): | ||
| pass | ||
| def test_parse_ineco_expense(sms_message, bank_cards, expense): | ||
| assert parse_ineco_expense(sms_message, bank_cards) == expense |
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 |
|---|---|---|
| @@ -1,5 +1,13 @@ | ||
| from functions.one_gender import genderalize | ||
| import pytest | ||
|
|
||
|
|
||
| def test_genderalize(): | ||
| pass | ||
| @pytest.mark.parametrize( | ||
| 'gender, expected_result', | ||
| [ | ||
| ('male', 'male_verb'), | ||
| ('female', 'female_verb'), | ||
| ] | ||
| ) | ||
| def test_genderalize(gender, expected_result): | ||
| assert genderalize('male_verb', 'female_verb', gender) == expected_result | ||
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 |
|---|---|---|
| @@ -1,5 +1,18 @@ | ||
| from functions.three_url_builder import build_url | ||
| import pytest | ||
|
|
||
|
|
||
| def test_build_url(): | ||
| pass | ||
| @pytest.mark.parametrize( | ||
| 'host_name, relative_url, get_params, expected_result', | ||
| [ | ||
| ( | ||
| 'hh.ru', 'applicant/negotiations', | ||
| {'hhtmFrom': 'employer', 'hhtmFromLabel': 'header'}, | ||
| 'hh.ru/applicant/negotiations?hhtmFrom=employer&hhtmFromLabel=header' | ||
| ), | ||
| ('hh.ru', 'applicant/negotiations', {}, 'hh.ru/applicant/negotiations'), | ||
| ('hh.ru', 'applicant/negotiations', None, 'hh.ru/applicant/negotiations') | ||
| ] | ||
| ) | ||
| def test_build_url(host_name, relative_url, get_params, expected_result): | ||
| assert build_url(host_name, relative_url, get_params) == expected_result |
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 |
|---|---|---|
| @@ -1,5 +1,10 @@ | ||
| import datetime | ||
| from functions.two_date_parser import compose_datetime_from | ||
|
|
||
|
|
||
| def test_compose_datetime_from(): | ||
| pass | ||
| def test_compose_datetime_from_today(today): | ||
| assert compose_datetime_from('today', '16 : 48') == datetime.datetime(today.year, today.month, today.day, 16, 48) | ||
|
|
||
|
|
||
| def test_compose_datetime_from(yesterday): | ||
| assert compose_datetime_from('tomorrow', '16 : 48') == datetime.datetime(yesterday.year, yesterday.month, yesterday.day, 16, 48) |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут есть лишние параметры: первый, например, всегда одинаковый, второй тоже. Убери их из параметрайза.
И фикстуры я бы эти тоже удалил: они завязаны на этот тест и не очень универсальные, поэтому просто захардкодь слова тут и будет нормас.