diff options
Diffstat (limited to 'mediagoblin/tests')
-rw-r--r-- | mediagoblin/tests/test_api.py | 26 | ||||
-rw-r--r-- | mediagoblin/tests/test_auth.py | 4 | ||||
-rw-r--r-- | mediagoblin/tests/test_edit.py | 2 | ||||
-rw-r--r-- | mediagoblin/tests/test_exif.py | 2 | ||||
-rw-r--r-- | mediagoblin/tests/test_moderation.py | 18 | ||||
-rw-r--r-- | mediagoblin/tests/test_notifications.py | 2 | ||||
-rw-r--r-- | mediagoblin/tests/test_oauth1.py | 2 | ||||
-rw-r--r-- | mediagoblin/tests/test_reporting.py | 2 | ||||
-rw-r--r-- | mediagoblin/tests/test_submission.py | 14 |
9 files changed, 36 insertions, 36 deletions
diff --git a/mediagoblin/tests/test_api.py b/mediagoblin/tests/test_api.py index 5f688857..f987ddc8 100644 --- a/mediagoblin/tests/test_api.py +++ b/mediagoblin/tests/test_api.py @@ -55,7 +55,7 @@ class TestAPI: with self.mock_oauth(): response = test_app.post( - "/api/user/{}/feed".format(self.active_user.username), + f"/api/user/{self.active_user.username}/feed", json.dumps(activity), headers=headers ) @@ -75,7 +75,7 @@ class TestAPI: with self.mock_oauth(): response = test_app.post( - "/api/user/{}/uploads".format(self.active_user.username), + f"/api/user/{self.active_user.username}/uploads", data, headers=headers ) @@ -192,7 +192,7 @@ class TestAPI: # Will be self.user trying to upload as self.other_user with pytest.raises(AppError) as excinfo: test_app.post( - "/api/user/{}/uploads".format(self.other_user.username), + f"/api/user/{self.other_user.username}/uploads", data, headers=headers ) @@ -215,7 +215,7 @@ class TestAPI: with self.mock_oauth(): with pytest.raises(AppError) as excinfo: test_app.post( - "/api/user/{}/feed".format(self.other_user.username), + f"/api/user/{self.other_user.username}/feed", json.dumps(activity), headers=headers ) @@ -250,7 +250,7 @@ class TestAPI: with self.mock_oauth(): with pytest.raises(AppError) as excinfo: test_app.post( - "/api/user/{}/feed".format(self.user.username), + f"/api/user/{self.user.username}/feed", json.dumps(activity), headers=headers ) @@ -277,7 +277,7 @@ class TestAPI: with self.mock_oauth(): response = test_app.post( - "/api/user/{}/feed".format(self.user.username), + f"/api/user/{self.user.username}/feed", json.dumps(activity), headers={"Content-Type": "application/json"} ) @@ -311,7 +311,7 @@ class TestAPI: with self.mock_oauth(): with pytest.raises(AppError) as excinfo: test_app.post( - "/api/user/{}/uploads".format(self.user.username), + f"/api/user/{self.user.username}/uploads", data, headers=headers ) @@ -406,7 +406,7 @@ class TestAPI: with self.mock_oauth(): with pytest.raises(AppError) as excinfo: test_app.post( - "/api/user/{}/feed".format(self.other_user.username), + f"/api/user/{self.other_user.username}/feed", json.dumps(activity), headers=headers ) @@ -452,7 +452,7 @@ class TestAPI: with self.mock_oauth(): with pytest.raises(AppError) as excinfo: test_app.post( - "/api/user/{}/feed".format(self.user.username), + f"/api/user/{self.user.username}/feed", json.dumps(activity), headers=headers ) @@ -461,7 +461,7 @@ class TestAPI: def test_profile(self, test_app): """ Tests profile endpoint """ - uri = "/api/user/{}/profile".format(self.user.username) + uri = f"/api/user/{self.user.username}/profile" with self.mock_oauth(): response = test_app.get(uri) profile = json.loads(response.body.decode()) @@ -475,7 +475,7 @@ class TestAPI: def test_user(self, test_app): """ Test the user endpoint """ - uri = "/api/user/{}/".format(self.user.username) + uri = f"/api/user/{self.user.username}/" with self.mock_oauth(): response = test_app.get(uri) user = json.loads(response.body.decode()) @@ -501,7 +501,7 @@ class TestAPI: response, image_data = self._upload_image(test_app, GOOD_JPG) response, data = self._post_image_to_feed(test_app, image_data) - uri = "/api/user/{}/feed".format(self.active_user.username) + uri = f"/api/user/{self.active_user.username}/feed" with self.mock_oauth(): response = test_app.get(uri) feed = json.loads(response.body.decode()) @@ -574,7 +574,7 @@ class TestAPI: self.active_user = self.other_user # Fetch the feed - url = "/api/user/{}/feed".format(self.user.username) + url = f"/api/user/{self.user.username}/feed" with self.mock_oauth(): response = test_app.get(url) feed = json.loads(response.body.decode()) diff --git a/mediagoblin/tests/test_auth.py b/mediagoblin/tests/test_auth.py index c5218050..30d7b301 100644 --- a/mediagoblin/tests/test_auth.py +++ b/mediagoblin/tests/test_auth.py @@ -164,7 +164,7 @@ def test_register_views(test_app): ## Verify the email activation works template.clear_test_template_context() - response = test_app.get("{}?{}".format(path, get_params)) + response = test_app.get(f"{path}?{get_params}") response.follow() context = template.TEMPLATE_TEST_CONTEXT[ 'mediagoblin/user_pages/user.html'] @@ -230,7 +230,7 @@ def test_register_views(test_app): ## Verify step 1 of password-change works -- can see form to change password template.clear_test_template_context() - response = test_app.get("{}?{}".format(path, get_params)) + response = test_app.get(f"{path}?{get_params}") assert 'mediagoblin/plugins/basic_auth/change_fp.html' in \ template.TEMPLATE_TEST_CONTEXT diff --git a/mediagoblin/tests/test_edit.py b/mediagoblin/tests/test_edit.py index 1593fa5d..e8780451 100644 --- a/mediagoblin/tests/test_edit.py +++ b/mediagoblin/tests/test_edit.py @@ -168,7 +168,7 @@ class TestUserEdit: # Verify email activation works template.clear_test_template_context() get_params = urlparse.urlsplit(email_context['verification_url'])[3] - res = test_app.get('{}?{}'.format(path, get_params)) + res = test_app.get(f'{path}?{get_params}') res.follow() # New email saved? diff --git a/mediagoblin/tests/test_exif.py b/mediagoblin/tests/test_exif.py index 0074e862..38fbd467 100644 --- a/mediagoblin/tests/test_exif.py +++ b/mediagoblin/tests/test_exif.py @@ -28,7 +28,7 @@ from .resources import GOOD_JPG, EMPTY_JPG, BAD_JPG, GPS_JPG, BAD_GPS_JPG def assert_in(a, b): - assert a in b, "{!r} not in {!r}".format(a, b) + assert a in b, f"{a!r} not in {b!r}" def test_exif_extraction(): diff --git a/mediagoblin/tests/test_moderation.py b/mediagoblin/tests/test_moderation.py index c262a768..222f6cb7 100644 --- a/mediagoblin/tests/test_moderation.py +++ b/mediagoblin/tests/test_moderation.py @@ -69,7 +69,7 @@ class TestModerationViews: # First, test an admin taking away a privilege from a user #---------------------------------------------------------------------- response, context = self.do_post({'privilege_name':'commenter'}, - url='/mod/users/{}/privilege/'.format(self.user.username)) + url=f'/mod/users/{self.user.username}/privilege/') assert response.status == '302 FOUND' self.query_for_users() assert not self.user.has_privilege('commenter') @@ -77,7 +77,7 @@ class TestModerationViews: # Then, test an admin giving a privilege to a user #---------------------------------------------------------------------- response, context = self.do_post({'privilege_name':'commenter'}, - url='/mod/users/{}/privilege/'.format(self.user.username)) + url=f'/mod/users/{self.user.username}/privilege/') assert response.status == '302 FOUND' self.query_for_users() assert self.user.has_privilege('commenter') @@ -90,7 +90,7 @@ class TestModerationViews: with pytest.raises(AppError) as excinfo: response, context = self.do_post({'privilege_name':'commenter'}, - url='/mod/users/{}/privilege/'.format(self.user.username)) + url=f'/mod/users/{self.user.username}/privilege/') assert 'Bad response: 403 FORBIDDEN' in str(excinfo) self.query_for_users() @@ -116,7 +116,7 @@ class TestModerationViews: response, context = self.do_post({'action_to_resolve':['takeaway'], 'take_away_privileges':['commenter'], 'targeted_user':self.user.id}, - url='/mod/reports/{}/'.format(comment_report.id)) + url=f'/mod/reports/{comment_report.id}/') self.query_for_users() comment_report = Report.query.filter( @@ -137,7 +137,7 @@ class TestModerationViews: response, context = self.do_post({'action_to_resolve':['sendmessage'], 'message_to_user':'This is your last warning, regular....', 'targeted_user':self.user.id}, - url='/mod/reports/{}/'.format(comment_report.id)) + url=f'/mod/reports/{comment_report.id}/') self.query_for_users() comment_report = Report.query.filter( @@ -175,7 +175,7 @@ VGhpcyBpcyB5b3VyIGxhc3Qgd2FybmluZywgcmVndWxhci4uLi4=\n', 'targeted_user':self.user.id, 'why_user_was_banned':'', 'user_banned_until':''}, - url='/mod/reports/{}/'.format(comment_report.id)) + url=f'/mod/reports/{comment_report.id}/') assert response.status == '302 FOUND' self.query_for_users() test_user_ban = UserBan.query.filter( @@ -196,7 +196,7 @@ VGhpcyBpcyB5b3VyIGxhc3Qgd2FybmluZywgcmVndWxhci4uLi4=\n', response, context = self.do_post({'action_to_resolve':['takeaway'], 'take_away_privileges':['active'], 'targeted_user':self.admin_user.id}, - url='/mod/reports/{}/'.format(comment_report.id)) + url=f'/mod/reports/{comment_report.id}/') self.query_for_users() assert response.status == '200 OK' @@ -216,7 +216,7 @@ VGhpcyBpcyB5b3VyIGxhc3Qgd2FybmluZywgcmVndWxhci4uLi4=\n', response = self.test_app.get('/mod/users/') assert response.status == "200 OK" - user_page_url = '/mod/users/{}/'.format(username) + user_page_url = f'/mod/users/{username}/' response = self.test_app.get(user_page_url) assert response.status == "200 OK" @@ -227,7 +227,7 @@ VGhpcyBpcyB5b3VyIGxhc3Qgd2FybmluZywgcmVndWxhci4uLi4=\n', self.login('admin') username = self.user.username user_id = self.user.id - ban_url = '/mod/users/{}/ban/'.format(username) + ban_url = f'/mod/users/{username}/ban/' response, context = self.do_post({ 'user_banned_until':'', 'why_user_was_banned':'Because I said so'}, diff --git a/mediagoblin/tests/test_notifications.py b/mediagoblin/tests/test_notifications.py index d19f2951..acba954d 100644 --- a/mediagoblin/tests/test_notifications.py +++ b/mediagoblin/tests/test_notifications.py @@ -147,7 +147,7 @@ otherperson@example.com\n\nSGkgb3RoZXJwZXJzb24sCmNocmlzIGNvbW1lbnRlZCBvbiB5b3VyI self.logout() self.login('otherperson', 'nosreprehto') - self.test_app.get(media_uri_slug + 'c/{}/'.format(comment_id)) + self.test_app.get(media_uri_slug + f'c/{comment_id}/') notification = Notification.query.filter_by(id=notification_id).first() diff --git a/mediagoblin/tests/test_oauth1.py b/mediagoblin/tests/test_oauth1.py index 345b308e..25f7c0d3 100644 --- a/mediagoblin/tests/test_oauth1.py +++ b/mediagoblin/tests/test_oauth1.py @@ -123,7 +123,7 @@ class TestOAuth: def to_authorize_headers(self, data): headers = "" for key, value in data.items(): - headers += '{}="{}",'.format(key, value) + headers += f'{key}="{value}",' return {"Authorization": "OAuth " + headers[:-1]} def test_request_token(self): diff --git a/mediagoblin/tests/test_reporting.py b/mediagoblin/tests/test_reporting.py index 81dc1d89..8dfb1a41 100644 --- a/mediagoblin/tests/test_reporting.py +++ b/mediagoblin/tests/test_reporting.py @@ -143,7 +143,7 @@ class TestReportFiling: {'action_to_resolve':['userban', 'delete'], 'targeted_user':allie_user.id, 'resolution_content':'This is a test of archiving reports.'}, - url='/mod/reports/{}/'.format(comment_report.id)) + url=f'/mod/reports/{comment_report.id}/') assert response.status == "302 FOUND" allie_user, natalie_user = self.query_for_users() diff --git a/mediagoblin/tests/test_submission.py b/mediagoblin/tests/test_submission.py index 2f5a2712..348ed03a 100644 --- a/mediagoblin/tests/test_submission.py +++ b/mediagoblin/tests/test_submission.py @@ -173,7 +173,7 @@ class BaseTestSubmission: def check_normal_upload(self, title, filename): response, context = self.do_post({'title': title}, do_follow=True, **self.upload_data(filename)) - self.check_url(response, '/u/{}/'.format(self.our_user().username)) + self.check_url(response, f'/u/{self.our_user().username}/') assert 'mediagoblin/user_pages/user.html' in context # Make sure the media view is at least reachable, logged in... url = '/u/{}/m/{}/'.format(self.our_user().username, @@ -215,7 +215,7 @@ class TestSubmissionBasics(BaseTestSubmission): # User uploaded should be the same as GOOD_JPG size in Mb file_size = os.stat(GOOD_JPG).st_size / (1024.0 * 1024) - file_size = float('{:.2f}'.format(file_size)) + file_size = float(f'{file_size:.2f}') # Reload user assert self.our_user().uploaded == file_size @@ -242,7 +242,7 @@ class TestSubmissionBasics(BaseTestSubmission): response, context = self.do_post({'title': 'Normal upload 4'}, do_follow=True, **self.upload_data(GOOD_JPG)) - self.check_url(response, '/u/{}/'.format(self.our_user().username)) + self.check_url(response, f'/u/{self.our_user().username}/') assert 'mediagoblin/user_pages/user.html' in context # Shouldn't have uploaded @@ -257,7 +257,7 @@ class TestSubmissionBasics(BaseTestSubmission): response, context = self.do_post({'title': 'Normal upload 5'}, do_follow=True, **self.upload_data(GOOD_JPG)) - self.check_url(response, '/u/{}/'.format(self.our_user().username)) + self.check_url(response, f'/u/{self.our_user().username}/') assert 'mediagoblin/user_pages/user.html' in context # Shouldn't have uploaded @@ -421,7 +421,7 @@ class TestSubmissionBasics(BaseTestSubmission): # they'll be caught as failures during the processing step. response, context = self.do_post({'title': title}, do_follow=True, **self.upload_data(filename)) - self.check_url(response, '/u/{}/'.format(self.our_user().username)) + self.check_url(response, f'/u/{self.our_user().username}/') entry = mg_globals.database.MediaEntry.query.filter_by(title=title).first() assert entry.state == 'failed' assert entry.fail_error == 'mediagoblin.processing:BadMediaFail' @@ -583,7 +583,7 @@ class TestSubmissionVideo(BaseTestSubmission): assert len(result) == len(video_config['available_resolutions']) for i in range(len(video_config['available_resolutions'])): media_file = MediaFile.query.filter_by(media_entry=media.id, - name=('webm_{}'.format(str(result[i][0])))).first() + name=(f'webm_{str(result[i][0])}')).first() # check media_file label assert result[i][0] == video_config['available_resolutions'][i] # check dimensions of media_file @@ -771,6 +771,6 @@ class TestSubmissionPDF(BaseTestSubmission): response, context = self.do_post({'title': 'Normal upload 3 (pdf)'}, do_follow=True, **self.upload_data(GOOD_PDF)) - self.check_url(response, '/u/{}/'.format(self.our_user().username)) + self.check_url(response, f'/u/{self.our_user().username}/') assert 'mediagoblin/user_pages/user.html' in context |