def test_duplicated(self): expected_ticket_1 = Ticket('URID-1', "https://github.com/anvatar/URID/abc") self._git_repo.t_add_ticket_or_exception_for_url(expected_ticket_1, expected_ticket_1.url) response = self.client.post(reverse('urid:api_create_ticket'), data='{ "url": "%s" }' % (expected_ticket_1.url,), content_type='application/json') self.assertContains(response, expected_ticket_1.as_json(), status_code=201) self._git_repo.t_add_ticket_or_exception_for_url( DuplicatedTicketException(expected_ticket_1), expected_ticket_1.url) response = self.client.post(reverse('urid:api_create_ticket'), data='{ "url": "%s" }' % (expected_ticket_1.url,), content_type='application/json') self.assertContains(response, expected_ticket_1.as_json(), status_code=409)
def test_create(self): expected_ticket_1 = Ticket('URID-1', "https://github.com/anvatar/URID/abc") self._git_repo.t_add_ticket_or_exception_for_url(expected_ticket_1, expected_ticket_1.url) expected_ticket_2 = Ticket('URID-2', "https://github.com/anvatar/URID/def") self._git_repo.t_add_ticket_or_exception_for_url(expected_ticket_2, expected_ticket_2.url) response = self.client.post(reverse('urid:api_create_ticket'), data='{ "url": "%s" }' % (expected_ticket_1.url,), content_type='application/json') self.assertContains(response, expected_ticket_1.as_json(), status_code=201) self.assertDictContainsSubset({'Location': _reverse('urid:api_follow_ticket', args=('URID-1',))}, response) response = self.client.post(reverse('urid:api_create_ticket'), data='{ "url": "%s" }' % (expected_ticket_2.url,), content_type='application/json') self.assertContains(response, expected_ticket_2.as_json(), status_code=201) self.assertDictContainsSubset({'Location': _reverse('urid:api_follow_ticket', args=('URID-2',))}, response)