From 48b3fd776489f731feec0847f93089898d36b73a Mon Sep 17 00:00:00 2001 From: Drew Larson Date: Sun, 5 Feb 2017 11:00:42 -0600 Subject: [PATCH] =?UTF-8?q?Refine=20tests=20a=20bit=20maybe=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bikeshop_project/bike/tests.py | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/bikeshop_project/bike/tests.py b/bikeshop_project/bike/tests.py index 9a5b47e..6b863ac 100644 --- a/bikeshop_project/bike/tests.py +++ b/bikeshop_project/bike/tests.py @@ -35,7 +35,7 @@ class TestBikeApi(TestCase): self.assertEqual(result.status_code, status.HTTP_200_OK) self.assertEqual(len(result.data), 10) - def test_create_new_bike(self): + def test_create_new_bike(self,): client = APIClient() client.force_authenticate(user=self.user, token='blah') data = { @@ -48,11 +48,15 @@ class TestBikeApi(TestCase): result = client.post('/api/v1/bikes/', data=data) self.assertEqual(result.status_code, status.HTTP_201_CREATED) + self.assertTrue(result.data['id']) self.assertEqual(result.data['colour'], data['colour']) self.assertEqual(result.data['make'], data['make']) self.assertEqual(result.data['serial_number'], data['serial_number']) self.assertEqual(result.data['source'], data['source']) self.assertEqual(result.data['donated_by'], data['donated_by']) + bike = Bike.objects.get(serial_number='12345676') + self.assertEqual(bike.id, result.data['id']) + self.assertEqual(bike.serial_number, result.data['serial_number']) def test_update_partial_created_at(self): bike = mommy.make('bike.Bike') @@ -350,19 +354,6 @@ class TestBikeApi(TestCase): self.assertEqual(result.status_code, status.HTTP_200_OK) - # I am not sure I can say at this point whether check_cpic will be called - # @patch('bike.consumers.check_cpic') - # def test_check_cpic(self, check_cpic_mock): - # bike = mommy.make(model=Bike, cpic_searched_at=None, stolen=None) - # client = APIClient() - # client.force_authenticate(user=self.user, token='blah') - # data = {'serial_number': '123abc'} - # result = client.put(f'/api/v1/bikes/{bike.id}/check/', data=data) - # - # self.assertEqual(result.status_code, status.HTTP_200_OK) - # self.assertEqual(result.data, {'status': 'pending'}) - # check_cpic_mock.assert_called_once() - class TestBikeSignals(TestCase): @patch('bike.consumers._is_stolen')