예제 #1
0
    def test_delete_one(self):
        # arrange
        num_to_create = randint(20, 40)
        util.create_Card_instances(num_to_create)
        index = randint(0, num_to_create-1)

        # act
        url = reverse('card-detail', args=[index+1])
        response = self.client.delete(url)

        # assert
        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
        self.assertEqual(Card.objects.all().count(), num_to_create-1)
예제 #2
0
    def test_delete_one(self):
        # arrange
        num_to_create = randint(20, 40)
        util.create_Card_instances(num_to_create)
        index = randint(0, num_to_create - 1)

        # act
        url = reverse('card-detail', args=[index + 1])
        response = self.client.delete(url)

        # assert
        self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
        self.assertEqual(Card.objects.all().count(), num_to_create - 1)
예제 #3
0
    def test_put_one(self):
        # arrange
        num_to_create = randint(20, 40)
        util.create_Card_instances(num_to_create)
        index = randint(0, num_to_create-1)

        # act
        new_font_size = 'new_font_size'
        data = {
            'font_size': new_font_size
        }
        url = reverse('card-detail', args=[index+1])  # index is 0 based, but API pk is 1 based
        response = self.client.put(url, data=data, format='json')

        # assert
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(Card.objects.all().count(), num_to_create)
        self.assertEqual(Card.objects.all()[index].font_size, new_font_size)
예제 #4
0
    def test_put_one(self):
        # arrange
        num_to_create = randint(20, 40)
        util.create_Card_instances(num_to_create)
        index = randint(0, num_to_create - 1)

        # act
        new_font_size = 'new_font_size'
        data = {'font_size': new_font_size}
        url = reverse('card-detail',
                      args=[index + 1
                            ])  # index is 0 based, but API pk is 1 based
        response = self.client.put(url, data=data, format='json')

        # assert
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(Card.objects.all().count(), num_to_create)
        self.assertEqual(Card.objects.all()[index].font_size, new_font_size)
예제 #5
0
    def test_get_one(self):
        # arrange
        num_to_create = randint(20, 40)
        font_sizes = util.create_Card_instances(num_to_create)
        index = randint(0, num_to_create-1)

        # act
        url = reverse('card-detail', args=[index+1])  # index is 0 based, but API pk is 1 based
        response = self.client.get(url)

        # assert
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['font_size'], font_sizes[index])
예제 #6
0
    def test_get_one(self):
        # arrange
        num_to_create = randint(20, 40)
        font_sizes = util.create_Card_instances(num_to_create)
        index = randint(0, num_to_create - 1)

        # act
        url = reverse('card-detail',
                      args=[index + 1
                            ])  # index is 0 based, but API pk is 1 based
        response = self.client.get(url)

        # assert
        self.assertEqual(response.status_code, status.HTTP_200_OK)
        self.assertEqual(response.data['font_size'], font_sizes[index])