diff options
author | Miroslav Šedivý <[email protected]> | 2022-12-02 22:04:23 +0100 |
---|---|---|
committer | Miroslav Šedivý <[email protected]> | 2022-12-02 22:04:23 +0100 |
commit | 325cc917d5ad14b130b156d23b7adca46499dc24 (patch) | |
tree | 247b41199512db9693d00baf7522602805e31c3f /tests | |
parent | c796cf39b01e38fe381fb4743988da991b072183 (diff) | |
download | mastodon.py-325cc917d5ad14b130b156d23b7adca46499dc24.tar.gz |
refactor: use f-strings
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_create_app.py | 2 | ||||
-rw-r--r-- | tests/test_pagination.py | 15 | ||||
-rw-r--r-- | tests/test_status.py | 2 |
3 files changed, 12 insertions, 7 deletions
diff --git a/tests/test_create_app.py b/tests/test_create_app.py index c7282df..97556c6 100644 --- a/tests/test_create_app.py +++ b/tests/test_create_app.py | |||
@@ -64,7 +64,7 @@ def test_app_account_create(): | |||
64 | test_app[1], | 64 | test_app[1], |
65 | api_base_url="http://localhost:3000/" | 65 | api_base_url="http://localhost:3000/" |
66 | ) | 66 | ) |
67 | test_token = test_app_api.create_account("coolguy" + suffix, "swordfish", "email@localhost" + suffix, agreement=True) | 67 | test_token = test_app_api.create_account(f"coolguy{suffix}", "swordfish", f"email@localhost{suffix}", agreement=True) |
68 | assert test_token | 68 | assert test_token |
69 | 69 | ||
70 | # We can also test resending (marginally) | 70 | # We can also test resending (marginally) |
diff --git a/tests/test_pagination.py b/tests/test_pagination.py index 9f26140..0c83fe4 100644 --- a/tests/test_pagination.py +++ b/tests/test_pagination.py | |||
@@ -16,7 +16,7 @@ UNLIKELY_HASHTAG = "fgiztsshwiaqqiztpmmjbtvmescsculuvmgjgopwoeidbcrixp" | |||
16 | def many_statuses(api, n=10, suffix=''): | 16 | def many_statuses(api, n=10, suffix=''): |
17 | statuses = list() | 17 | statuses = list() |
18 | for i in range(n): | 18 | for i in range(n): |
19 | status = api.status_post("Toot number {}!{}".format(i, suffix)) | 19 | status = api.status_post(f"Toot number {i}!{suffix}") |
20 | statuses.append(status) | 20 | statuses.append(status) |
21 | yield statuses | 21 | yield statuses |
22 | for status in statuses: | 22 | for status in statuses: |
@@ -102,10 +102,15 @@ def test_link_headers(api): | |||
102 | 102 | ||
103 | _id='abc1234' | 103 | _id='abc1234' |
104 | 104 | ||
105 | rmock.register_uri('GET', requests_mock.ANY, json=[{"foo": "bar"}], headers={"link":""" | 105 | rmock.register_uri( |
106 | <{base}/api/v1/timelines/tag/{tag}?max_id={_id}>; rel="next", <{base}/api/v1/timelines/tag/{tag}?since_id={_id}>; rel="prev" | 106 | 'GET', |
107 | """.format(base=api.api_base_url, tag=UNLIKELY_HASHTAG, _id=_id).strip() | 107 | requests_mock.ANY, |
108 | }) | 108 | json=[{"foo": "bar"}], |
109 | headers={ | ||
110 | "link": f"<{api.api_base_url}/api/v1/timelines/tag/{UNLIKELY_HASHTAG}?max_id={_id}>; rel=\"next\", " | ||
111 | f"<{api.api_base_url}/api/v1/timelines/tag/{UNLIKELY_HASHTAG}?since_id={_id}>; rel=\"prev\"" | ||
112 | } | ||
113 | ) | ||
109 | 114 | ||
110 | resp = api.timeline_hashtag(UNLIKELY_HASHTAG) | 115 | resp = api.timeline_hashtag(UNLIKELY_HASHTAG) |
111 | assert resp._pagination_next['max_id'] == _id | 116 | assert resp._pagination_next['max_id'] == _id |
diff --git a/tests/test_status.py b/tests/test_status.py index 8461bc3..56e7397 100644 --- a/tests/test_status.py +++ b/tests/test_status.py | |||
@@ -203,7 +203,7 @@ def test_scheduled_status_long_part1(api): | |||
203 | else: | 203 | else: |
204 | the_medium_term_future = datetime.datetime.now() + datetime.timedelta(minutes=6) | 204 | the_medium_term_future = datetime.datetime.now() + datetime.timedelta(minutes=6) |
205 | pickle.dump(the_medium_term_future.timestamp(), open("tests/cassettes_special/test_scheduled_status_long_datetimeobjects.pkl", 'wb')) | 205 | pickle.dump(the_medium_term_future.timestamp(), open("tests/cassettes_special/test_scheduled_status_long_datetimeobjects.pkl", 'wb')) |
206 | scheduled_toot = api.status_post("please ensure maximum headroom at " + str(the_medium_term_future), scheduled_at=the_medium_term_future) | 206 | scheduled_toot = api.status_post(f"please ensure maximum headroom at {the_medium_term_future}", scheduled_at=the_medium_term_future) |
207 | scheduled_toot_list = api.scheduled_statuses() | 207 | scheduled_toot_list = api.scheduled_statuses() |
208 | assert scheduled_toot.id in map(lambda x: x.id, scheduled_toot_list) | 208 | assert scheduled_toot.id in map(lambda x: x.id, scheduled_toot_list) |
209 | pickle.dump(scheduled_toot.params.text, open("tests/cassettes_special/test_scheduled_status_long_text.pkl", 'wb')) | 209 | pickle.dump(scheduled_toot.params.text, open("tests/cassettes_special/test_scheduled_status_long_text.pkl", 'wb')) |