def test_pull_request_opened_by_organization_member(self, mock): """Tests that the `CreatePullRequestCard` is not enqueued.""" payload = json_fixture('./tests/fixtures/pull_request_opened.json') GitHubReceiver.delay(payload=payload) # It does not enqueue the `CreatePullRequestCard` task mock.assert_not_called()
def test_issue_opened_by_external_contributor(self, mock): """Tests that the `CreateIssueCard` is not enqueued.""" payload = json_fixture('./tests/fixtures/issue_opened.json') GitHubReceiver.delay(payload=payload) # It does not enqueue the `CreateIssueCard` task mock.assert_not_called()
def test_run(self, mock): """Tests to ensure a new `Issue` is persisted when the task is run.""" mock.return_value = mock_trello_service() issues = Issue.query.all() self.assertTrue(len(issues) is 0) payload = json_fixture('./tests/fixtures/manual_comment.json') CreateManualCard.delay(board_id=default_board_id, list_id=default_list_id, name='test', payload=payload) # Enqueuing new issue `CreateManualCard` should create an `Issue` new_issues = Issue.query.all() self.assertTrue(len(new_issues) is 1)
def test_run(self, mock): """Tests to ensure a new `PullRequest` is persisted when run.""" mock.return_value = mock_trello_service() pull_requests = PullRequest.query.all() self.assertTrue(len(pull_requests) is 0) payload = json_fixture('./tests/fixtures/pull_request_opened.json') CreatePullRequestCard.delay( board_id=default_board_id, list_id=default_list_id, name='Fake Pull Request', payload=payload ) # Enqueuing new pull_request `CreatePullRequestCard` should create a # `PullRequest` record new_pull_requests = PullRequest.query.all() self.assertTrue(len(new_pull_requests) is 1)
def test_closed_event(self, mock): """Tests `DeleteCardObjectFromDatabase` is enqueued.""" create_issue() payload = json_fixture('./tests/fixtures/issue_closed.json') GitHubReceiver.delay(payload=payload) mock.assert_called_once()
def test_manual_command_by_organization_member(self, mock): """Tests `CreateManualCard` is not enqueued.""" payload = json_fixture('./tests/fixtures/manual_comment.json') GitHubReceiver.delay(payload=payload) mock.assert_not_called()
def test_pull_request_opened_by_external_contributor(self, mock): """Tests `CreatePullRequestCard` is enqueued.""" payload = json_fixture('./tests/fixtures/pull_request_opened.json') GitHubReceiver.delay(payload=payload) mock.assert_called_once()
def test_issue_opened_by_organization_member(self, mock): """Tests `CreateIssueCard` is not enqueued.""" payload = json_fixture('./tests/fixtures/issue_opened.json') GitHubReceiver.delay(payload=payload) mock.assert_not_called()
def test_manual_command_by_external_contributor(self, mock): """Tests `CreateManualCard` is enqueued.""" payload = json_fixture('./tests/fixtures/manual_comment.json') GitHubReceiver.delay(payload=payload) mock.assert_not_called()