Exemplo n.º 1
0
    def test_when_data_is_correct_then_returns_200_status_code(self):
        provider = ProviderFactory(name='Weird name')
        patch_data = {'name': 'Cool name'}

        response = self.client.patch('/api/providers/{}/'.format(provider.id),
                                     patch_data)

        self.assertEqual(response.status_code, status.HTTP_200_OK)
Exemplo n.º 2
0
    def test_when_data_is_correct_then_updates_the_provider(self):
        provider = ProviderFactory(name='Weird name')
        patch_data = {'name': 'Cool name'}

        self.client.patch('/api/providers/{}/'.format(provider.id), patch_data)

        provider_exists = Provider.objects.filter(
            id=provider.id, name=patch_data['name']).exists()
        self.assertTrue(provider_exists)
Exemplo n.º 3
0
 def setUp(self) -> None:
     self.post_data = {
         'name': 'Some name',
         'price': 3.9,
         'points': [
             [1, 2],
             [2, 3],
             [0, 4],
         ],
         'provider': ProviderFactory().id,
     }
Exemplo n.º 4
0
    def test_that_it_returns_correct_data(self):
        provider = ProviderFactory()

        response = self.client.get('/api/providers/{}/'.format(provider.id))

        self.assertDictEqual(
            response.data, {
                'id': provider.id,
                'name': provider.name,
                'email': provider.email,
                'language': provider.language,
                'currency': provider.currency,
                'phone_number': provider.phone_number,
            })
Exemplo n.º 5
0
    def test_when_data_is_correct_then_returns_correct_data(self):
        provider = ProviderFactory(name='Weird name')
        patch_data = {'name': 'Cool name'}

        response = self.client.patch('/api/providers/{}/'.format(provider.id),
                                     patch_data)

        data = response.data
        self.assertEqual(
            data, {
                'id': provider.id,
                'name': patch_data['name'],
                'email': provider.email,
                'language': provider.language,
                'currency': provider.currency,
                'phone_number': provider.phone_number,
            })
Exemplo n.º 6
0
    def test_that_it_returns_200_status_code(self):
        provider_id = ProviderFactory().id

        response = self.client.get('/api/providers/{}/'.format(provider_id))

        self.assertEqual(response.status_code, status.HTTP_200_OK)
Exemplo n.º 7
0
    def test_that_it_returns_correct_amount_of_providers(self):
        ProviderFactory.create_batch(13)

        response = self.client.get('/api/providers/')

        self.assertEqual(len(response.data), 13)
Exemplo n.º 8
0
    def test_that_it_deletes_the_provider(self):
        provider_id = ProviderFactory().id

        self.client.delete('/api/providers/{}/'.format(provider_id))

        self.assertFalse(Provider.objects.filter(id=provider_id).exists())