From 89ab7d2a6ac54484861868f92249a72ee6c544e3 Mon Sep 17 00:00:00 2001 From: Bernhard M. Wiedemann Date: Dec 03 2020 09:11:42 +0000 Subject: api/project: Extend test coverage to cover the case fixed in the previous commit --- diff --git a/tests/test_pagure_flask_api_project.py b/tests/test_pagure_flask_api_project.py index 60b81fd..86a5469 100644 --- a/tests/test_pagure_flask_api_project.py +++ b/tests/test_pagure_flask_api_project.py @@ -4136,6 +4136,65 @@ class PagureFlaskApiProjectOptionsTests(tests.Modeltests): before["settings"]["issues_default_to_private"] = True self.assertEqual(after, before) + def test_api_modify_project_options2(self): + """ Test accessing api_modify_project_options w/ auth header. """ + + # check before + headers = {"Authorization": "token aaabbbcccddd"} + output = self.app.get("/api/0/test/options", headers=headers) + self.assertEqual(output.status_code, 200) + before = json.loads(output.get_data(as_text=True)) + self.assertEqual( + before, + { + "settings": { + "Enforce_signed-off_commits_in_pull-request": False, + "Minimum_score_to_merge_pull-request": -1, + "Only_assignee_can_merge_pull-request": False, + "Web-hooks": None, + "always_merge": False, + "disable_non_fast-forward_merges": False, + "fedmsg_notifications": True, + "issue_tracker": True, + "issue_tracker_read_only": False, + "issues_default_to_private": False, + "mqtt_notifications": True, + "notify_on_commit_flag": False, + "notify_on_pull-request_flag": False, + "open_metadata_access_to_all": False, + "project_documentation": False, + "pull_request_access_only": False, + "pull_requests": True, + "stomp_notifications": True, + }, + "status": "ok", + }, + ) + + # Update: `issue_tracker`. + data = {"issue_tracker": False} + output = self.app.post( + "/api/0/test/options/update", headers=headers, data=data + ) + self.assertEqual(output.status_code, 200) + data = json.loads(output.get_data(as_text=True)) + self.assertEqual( + data, + { + "message": "Edited successfully settings of repo: test", + "status": "ok", + }, + ) + + # check after + headers = {"Authorization": "token aaabbbcccddd"} + output = self.app.get("/api/0/test/options", headers=headers) + self.assertEqual(output.status_code, 200) + after = json.loads(output.get_data(as_text=True)) + self.assertNotEqual(before, after) + before["settings"]["issue_tracker"] = False + self.assertEqual(after, before) + class PagureFlaskApiProjectCreateAPITokenTests(tests.Modeltests): """ Tests for the flask API of pagure for creating user project API token