Skip to content

Commit d021f19

Browse files
style: reformat codebase with black 26.3.1
1 parent 9e546ab commit d021f19

19 files changed

Lines changed: 195 additions & 171 deletions

allure_clean_attachments.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,15 @@
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.
2222
"""
23+
2324
import json
2425
import os
2526
import sys
2627

2728
from more_itertools import flatten
2829

2930
ALLURE_REPORT_DIRECTORY_PATH = sys.argv[1]
30-
ALLURE_TEST_CASES_PATH = os.path.join(
31-
ALLURE_REPORT_DIRECTORY_PATH, 'data', 'test-cases'
32-
)
31+
ALLURE_TEST_CASES_PATH = os.path.join(ALLURE_REPORT_DIRECTORY_PATH, 'data', 'test-cases')
3332
ALLURE_TEST_CASES = os.listdir(ALLURE_TEST_CASES_PATH)
3433

3534

@@ -73,9 +72,7 @@ def allure_attachment_sources():
7372
def clean_allure_attachments_of_passed_tests():
7473
"""Go to attachments/ and clean collected "sources" one by one."""
7574
for attachment in ALLURE_ATTACHMENT_SOURCES:
76-
attachment_path = os.path.join(
77-
ALLURE_REPORT_DIRECTORY_PATH, 'data', 'attachments', attachment
78-
)
75+
attachment_path = os.path.join(ALLURE_REPORT_DIRECTORY_PATH, 'data', 'attachments', attachment)
7976
if os.path.exists(attachment_path):
8077
os.remove(attachment_path)
8178
else:

artifacts.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,16 @@
88
CI_COMMIT_REF_NAME = os.environ.get('CI_COMMIT_REF_NAME')
99
PRIVATE_TOKEN = os.environ.get('PRIVATE_TOKEN')
1010

11-
PAYLOAD = {
12-
'job': 'pages',
13-
'scope': 'success'
14-
}
15-
HEADERS = {
16-
'PRIVATE-TOKEN': PRIVATE_TOKEN
17-
}
11+
PAYLOAD = {'job': 'pages', 'scope': 'success'}
12+
HEADERS = {'PRIVATE-TOKEN': PRIVATE_TOKEN}
1813
URL = f'https://gitlab.com/api/v4/projects/{CI_PROJECT_ID}/jobs'
1914

2015
RESPONSE = requests.request("GET", URL, headers=HEADERS, params=PAYLOAD)
2116

2217
LATEST_JOB_ID = RESPONSE.json()[0]['id']
2318
logging.info(LATEST_JOB_ID)
2419

25-
URL = f'https://gitlab.com/api/v4/projects/{CI_PROJECT_ID}/jobs/' \
26-
f'{LATEST_JOB_ID}/artifacts'
20+
URL = f'https://gitlab.com/api/v4/projects/{CI_PROJECT_ID}/jobs/' f'{LATEST_JOB_ID}/artifacts'
2721

2822
RESPONSE = requests.request("GET", URL, headers=HEADERS)
2923

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[tool.black]
2+
line-length = 120
3+
target-version = ["py311", "py312"]
4+
skip-string-normalization = true

quality_control.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010

1111
def get_opened_merge_requests_of_source_branch(project, branch):
1212
"""Get list of opened merge requests for source branch"""
13-
response = requests.request(method='get',
14-
url=f'https://gitlab.com/api/v4/projects/{project}/merge_requests',
15-
params={'source_branch': branch, 'state': 'opened'})
13+
response = requests.request(
14+
method='get',
15+
url=f'https://gitlab.com/api/v4/projects/{project}/merge_requests',
16+
params={'source_branch': branch, 'state': 'opened'},
17+
)
1618
assert response.status_code == 200
1719
return response.json()
1820

@@ -24,10 +26,11 @@ def get_target_branch_of_merge_request(merge_request):
2426

2527
def get_latest_job_artifact_of_branch(project, branch):
2628
"""Get latest score.log artifact for branch."""
27-
result = requests.request(method='get',
28-
url=f'https://gitlab.com/api/v4/projects/{project}/jobs/artifacts/'
29-
f'{branch}/raw/pylint/score.log?job=Pylint',
30-
headers={'PRIVATE-TOKEN': PRIVATE_TOKEN}).text
29+
result = requests.request(
30+
method='get',
31+
url=f'https://gitlab.com/api/v4/projects/{project}/jobs/artifacts/{branch}/raw/pylint/score.log?job=Pylint',
32+
headers={'PRIVATE-TOKEN': PRIVATE_TOKEN},
33+
).text
3134
print(f'{branch} score = {result}')
3235
return result
3336

src/main/allure_helpers.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,25 +61,26 @@ def wrapper(*args, **kwargs):
6161
body=msg.encode('utf8'),
6262
name=f'Request {response.status_code} {response.request.method} {response.request.url}',
6363
attachment_type=allure.attachment_type.TEXT,
64-
extension='txt')
64+
extension='txt',
65+
)
6566

6667
try:
6768
response.json()
6869
allure.attach(
6970
body=json.dumps(response.json(), indent=4, ensure_ascii=False).encode('utf8'),
70-
name=f'Response {response.status_code} {response.request.method} '
71-
f'{response.request.url}',
71+
name=f'Response {response.status_code} {response.request.method} ' f'{response.request.url}',
7272
attachment_type=allure.attachment_type.JSON,
73-
extension='json')
73+
extension='json',
74+
)
7475

7576
except ValueError:
7677
logging.error('RESPONSE IN NOT JSON FORMAT')
7778
allure.attach(
7879
body=response.text.encode('utf8'),
79-
name=f'NOT JSON Response {response.status_code} {response.request.method} '
80-
f'{response.request.url}',
80+
name=f'NOT JSON Response {response.status_code} {response.request.method} ' f'{response.request.url}',
8181
attachment_type=allure.attachment_type.TEXT,
82-
extension='txt')
82+
extension='txt',
83+
)
8384
return response
8485

8586
return wrapper

src/main/file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ def read_json(filename):
1212
allure.attach(
1313
body=json.dumps(body, indent=2, ensure_ascii=False).encode('utf8'),
1414
name=f'JSON resource: {filename}',
15-
attachment_type=allure.attachment_type.JSON
15+
attachment_type=allure.attachment_type.JSON,
1616
)
1717
return body

src/main/weekdays.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@
33

44

55
def in_words():
6-
""" Insert [Yesterday, Today, Tomorrow] into weekdays of current week """
7-
week_days = ['ПОНЕДЕЛЬНИК', 'ВТОРНИК', 'СРЕДА', 'ЧЕТВЕРГ', 'ПЯТНИЦА', 'СУББОТА', 'ВОСКРЕСЕНЬЕ']
6+
"""Insert [Yesterday, Today, Tomorrow] into weekdays of current week"""
7+
week_days = [
8+
'ПОНЕДЕЛЬНИК',
9+
'ВТОРНИК',
10+
'СРЕДА',
11+
'ЧЕТВЕРГ',
12+
'ПЯТНИЦА',
13+
'СУББОТА',
14+
'ВОСКРЕСЕНЬЕ',
15+
]
816
current_day = datetime.datetime.today().weekday()
917
week_days[current_day] = 'СЕГОДНЯ'
1018
if current_day > 0:

src/test/api_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def load_json_resource(filename: str) -> dict:
1313
allure.attach(
1414
body=json.dumps(body, indent=2, ensure_ascii=False).encode('utf8'),
1515
name=f'JSON resource: {filename}',
16-
attachment_type=allure.attachment_type.JSON
16+
attachment_type=allure.attachment_type.JSON,
1717
)
1818
return body
1919

src/test/old_ctc/tvprogram/test_weeks_slider.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ def test_current_week_has_words_in_days(browser_module):
2020
browser_module.open('https://ctc.ru/programm')
2121
logging.info('step1/2: finish')
2222
logging.info('step2/2: start')
23-
browser_module.all('.current_week .slider-item-day .m-desktop .day-week')\
24-
.should(have.exact_texts(*weekdays.in_words()))
23+
browser_module.all('.current_week .slider-item-day .m-desktop .day-week').should(
24+
have.exact_texts(*weekdays.in_words())
25+
)
2526
logging.info('step2/2: finish')
2627

2728

@@ -31,6 +32,5 @@ def test_today_is_active(browser_module):
3132
browser_module.open('https://ctc.ru/programm')
3233
logging.info('step1/2: finish')
3334
logging.info('step2/2: start')
34-
browser_module.element('.current_week .slider-item-day.current')\
35-
.should(have.exact_text('СЕГОДНЯ'))
35+
browser_module.element('.current_week .slider-item-day.current').should(have.exact_text('СЕГОДНЯ'))
3636
logging.info('step2/2: finish')

src/test/test_duplicates.py

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,7 @@
66
from mimesis.random import Random
77
from pytest import mark
88

9-
SOMETHING = [
10-
{
11-
'key': 'abc', 'id': 1
12-
},
13-
{
14-
'key': 'abc', 'id': 2
15-
},
16-
{
17-
'key': 'zzz', 'id': 3
18-
}
19-
]
9+
SOMETHING = [{'key': 'abc', 'id': 1}, {'key': 'abc', 'id': 2}, {'key': 'zzz', 'id': 3}]
2010

2111

2212
def test_list_of_dictionaries_does_not_duplicate_by_some_key_value():
@@ -36,14 +26,18 @@ def test_list_of_dictionaries_does_not_duplicate_by_some_key_value():
3626
with soft_assertions():
3727
for key in new_some_view:
3828
assert_that(len(new_some_view[key])).described_as(
39-
f'key "{key}"" has duplicates "{new_some_view[key]}"').is_less_than_or_equal_to(1)
40-
41-
42-
@mark.parametrize('some_list', [
43-
[20, 30, 20, 30, 40, 50, 15, 11, 20, 40, 50, 15, 6, 7],
44-
[9, 5, 4],
45-
Random().randints(20, 0, 10),
46-
])
29+
f'key "{key}"" has duplicates "{new_some_view[key]}"'
30+
).is_less_than_or_equal_to(1)
31+
32+
33+
@mark.parametrize(
34+
'some_list',
35+
[
36+
[20, 30, 20, 30, 40, 50, 15, 11, 20, 40, 50, 15, 6, 7],
37+
[9, 5, 4],
38+
Random().randints(20, 0, 10),
39+
],
40+
)
4741
def test_list_doesnt_have_duplicates(some_list):
4842
"""Parametrized test asserts there is no duplicate ints in list.
4943

0 commit comments

Comments
 (0)