def test_wrong_slug_returns_error(self): request = construct_dummy_request(matchdict={ 'slug': '', 'position_id': 2 }) response = apiviews.discussion_attitude(request) self.assertIsInstance(response, httpexceptions.HTTPError) request = construct_dummy_request(matchdict={ 'slug': 'this-is-not-a-valid-slug', 'position_id': 2 }) response = apiviews.discussion_attitude(request) self.assertIsInstance(response, httpexceptions.HTTPError)
def test_wrong_position_id_returns_error(self): request = construct_dummy_request( matchdict={ 'slug': self.issue_cat_or_dog.slug, 'position_id': self.position_town.uid }) response = apiviews.discussion_attitude(request) self.assertIsInstance(response, httpexceptions.HTTPError) request = construct_dummy_request(matchdict={ 'slug': self.issue_cat_or_dog.slug, 'position_id': -1 }) response = apiviews.discussion_attitude(request) self.assertIsInstance(response, httpexceptions.HTTPError)
def test_successful_discussion_attitude(self): request = construct_dummy_request( matchdict={ 'slug': self.issue_cat_or_dog.slug, 'position_id': self.position_cat_or_dog.uid }) response = apiviews.discussion_attitude(request) self.assertTrue(response) self.assertIsInstance(response, dict) self.assertIn('position', request.validated) self.assertIn('issue', request.validated) self.assertIn('user', request.validated)