def test_moderation_template_ongoing(setup): """Check the return values are for the needsmoderation case.""" # test the default actual = moderation_template() assert actual['title'] == 'In the moderation queue.' assert 'put in the moderation queue.' in actual['body'] # test the keyword actual = moderation_template('ongoing') assert actual['title'] == 'In the moderation queue.' assert 'put in the moderation queue.' in actual['body'] # bad keyword, we go back to the default. actual = moderation_template('punkcat') assert actual['title'] == 'In the moderation queue.' assert 'put in the moderation queue.' in actual['body']
def test_moderation_template_ongoing(self): """Check the return values are for the needsmoderation case.""" # test the default actual = moderation_template() self.assertEqual(actual['title'], 'In the moderation queue.') self.assertIn('put in the moderation queue.', actual['body']) # test the keyword actual = moderation_template('ongoing') self.assertEqual(actual['title'], 'In the moderation queue.') self.assertIn('put in the moderation queue.', actual['body']) # bad keyword, we go back to the default. actual = moderation_template('punkcat') self.assertEqual(actual['title'], 'In the moderation queue.') self.assertIn('put in the moderation queue.', actual['body'])
def test_moderation_template(self): """Check the moderation template structure. - must be a dictionary - must contain the keys: title, body """ actual = moderation_template('ongoing') self.assertIs(type(actual), dict) self.assertIn('title', actual.keys()) self.assertIn('body', actual.keys())
def comment_closed_reason(self, reason): """Publish a comment on the public issue about why it was closed.""" if reason in ['invalid', 'incomplete']: comment = moderation_template(reason).get('body') else: raise ValueError("reason must be one of invalid or incomplete") payload = {'body': comment} issue_number = self.get_public_issue_number() path = f'repos/{PUBLIC_REPO}/{issue_number}/comments' make_request('post', path, payload)
def test_moderation_template(setup): """Check the moderation template structure. - must be a dictionary - must contain the keys: title, body """ actual = moderation_template('ongoing') assert type(actual) is dict assert 'title' in actual.keys() assert 'body' in actual.keys()
def prepare_rejected_issue(): """Create the payload for the rejected moderated issue. When the issue has been moderated as rejected, we need to change a couple of things in the public space - change Title - change body - close the issue - remove the action-needsmoderation label - change the milestone to invalid """ # Extract the relevant information invalid_id = app.config['STATUSES']['invalid']['id'] payload_request = moderation_template('rejected') payload_request['labels'] = ['status-notacceptable'] payload_request['state'] = 'closed' payload_request['milestone'] = invalid_id return payload_request
def prepare_rejected_issue(reason='rejected'): """Create the payload for the rejected moderated issue. When the issue has been moderated as rejected or labelled invalid by the bot we need to change a couple of things in the public space - change Title - change body - close the issue - remove the action-needsmoderation label - change the milestone to invalid """ # Extract the relevant information invalid_id = app.config['STATUSES']['invalid']['id'] config = REJECTED_CONFIG[reason] payload_request = moderation_template(config['template']) payload_request['labels'] = config['labels'] payload_request['state'] = 'closed' payload_request['milestone'] = invalid_id return payload_request
def test_moderation_template_rejected(self): """Check the return values are for the rejected case.""" actual = moderation_template('rejected') self.assertEqual(actual['title'], 'Issue rejected.') self.assertIn('Its original content has been deleted', actual['body'])
def test_moderation_template_rejected(setup): """Check the return values are for the rejected case.""" actual = moderation_template('rejected') assert actual['title'] == 'Issue rejected.' assert 'Its original content has been deleted' in actual['body']