def test_invalid_body(self): request = create_request_with_token_header( match_dict={'slug': self.issue_cat_or_dog.slug}) request.json_body = { 'position': 'we should do something entirely else' } response: Response = apiviews.add_premise_to_argument(request) self.assertEqual(response.status_code, 400)
def test_add_valid_reason(self): request: IRequest = create_request_with_token_header( json_body={ 'reason': 'because i need to', }, match_dict={ 'slug': self.issue_cat_or_dog.slug, 'argument_id': '18', 'attitude': 'agree', 'relation': 'undercut' }) response: Response = apiviews.add_premise_to_argument(request) self.assertEqual(response.status_code, 303, response.body)
def test_add_valid_reason_with_malformed_origin(self): request: IRequest = create_request_with_token_header( json_body={ 'reason': 'because i need to', 'origin': { 'entity-id': 23, 'aggregate-id': 'evil.com', 'author': 'penguin', # missing: 'version' } }, match_dict={ 'slug': self.issue_cat_or_dog.slug, 'argument_id': '18', 'attitude': 'agree', 'relation': 'undercut' }) response: Response = apiviews.add_premise_to_argument(request) self.assertEqual(response.status_code, 400, response.body)
def test_add_valid_reason_with_valid_origin(self): request: IRequest = create_request_with_token_header( json_body={ 'reason': 'because i need to', 'origin': { 'entity-id': 23, 'aggregate-id': 'evil.com', 'author': { "dgep-native": True, "name": "anonymous", "id": 1, }, 'version': 666 } }, match_dict={ 'slug': self.issue_cat_or_dog.slug, 'argument_id': '18', 'attitude': 'agree', 'relation': 'undercut' }) response: Response = apiviews.add_premise_to_argument(request) self.assertEqual(response.status_code, 303, response.body)