From 99eac77197d73294bae9ae2a75c65302c893e23f Mon Sep 17 00:00:00 2001 From: Joe Kaufeld Date: Wed, 26 Jan 2022 19:28:01 -0500 Subject: [PATCH] move pytest information into pyproject.toml --- api/tests/submissions/test_submission_done.py | 25 +++++++++++++++++++ pyproject.toml | 4 +++ pytest.ini | 4 --- 3 files changed, 29 insertions(+), 4 deletions(-) delete mode 100644 pytest.ini diff --git a/api/tests/submissions/test_submission_done.py b/api/tests/submissions/test_submission_done.py index edd7224c..a36a7676 100644 --- a/api/tests/submissions/test_submission_done.py +++ b/api/tests/submissions/test_submission_done.py @@ -262,6 +262,11 @@ def test_send_transcription_to_slack( f"Please check the following transcription of u/{user.username}:" f" asdf." ) + check_slack_message = ( + f"Please check the following transcription of u/{user.username}:" + f" asdf.\n\nThis user is being watched with a chance of 100%.\n" + f"Undo this using the `unwatch {user.username}` command." + ) assert result.status_code == status.HTTP_201_CREATED assert ( @@ -291,6 +296,26 @@ def test_send_transcription_to_slack( ) == slack_client.chat_postMessage.call_args_list[-1] ) + submission.refresh_from_db() + submission.completed_by = None + submission.save() + + user.overwrite_check_percentage = 1 + user.save() + result = client.patch( + reverse("submission-done", args=[submission.id]), + json.dumps({"username": user.username}), + content_type="application/json", + **headers, + ) + assert result.status_code == status.HTTP_201_CREATED + assert ( + call( + channel=settings.SLACK_TRANSCRIPTION_CHECK_CHANNEL, + text=check_slack_message, + ) + == slack_client.chat_postMessage.call_args_list[-1] + ) def test_removed_transcription_changes(self, client: Client) -> None: """Verify that a removed transcription is not sent to Slack.""" diff --git a/pyproject.toml b/pyproject.toml index b9a6ec50..a330508b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,3 +76,7 @@ exclude = ''' requires = ["poetry>=0.12"] build-backend = "poetry.masonry.api" +[tool.pytest.ini_options] +DJANGO_SETTINGS_MODULE = "blossom.settings.testing" +python_files = "tests.py test_*.py *_tests.py" +addopts = "--nomigrations --cov=. --cov-report=html --cov-report=term:skip-covered -p no:warnings" diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index c3365b7f..00000000 --- a/pytest.ini +++ /dev/null @@ -1,4 +0,0 @@ -[pytest] -DJANGO_SETTINGS_MODULE = blossom.settings.testing -python_files = tests.py test_*.py *_tests.py -addopts = --nomigrations --cov=. --cov-report=html --cov-report=term:skip-covered -p no:warnings