Example #1
0
 def setUp(self):
     super(ProductMediaReorderViewTests, self).setUp()
     self.product = ProductFactory.create()
     self.media = (
         MediumFactory.create(instance=self.product, order=1),
         MediumFactory.create(instance=self.product, order=2),
         MediumFactory.create(instance=self.product, order=3),
     )
 def setUp(self):
     super(DonorMediaReorderViewTests, self).setUp()
     self.donor = DonorFactory.create()
     self.media = (
         MediumFactory.create(instance=self.donor, order=1),
         MediumFactory.create(instance=self.donor, order=2),
         MediumFactory.create(instance=self.donor, order=3),
     )
Example #3
0
    def test_delete_medium(self):
        class DummyView(MediumDeleteMixin):
            pass

        view = DummyView()
        medium = MediumFactory.create()
        view.delete_medium(medium)
        self.assertNotEqual(medium.deleted_at, None)
    def test_upload_medium(self, mock_upload_medium, mock_get_uploaded_file):
        new_medium = MediumFactory.create(self.donor)
        mock_upload_medium.return_value = new_medium

        file = MagicMock()
        file.content_type = 'image/png'
        mock_get_uploaded_file.return_value = file

        response = self.client.post(
            reverse('api:admin:donor-medium', kwargs=dict(pk=self.donor.pk)))
        self.assertEqual(response.status_code, status.HTTP_200_OK)

        self.assertNotEqual(self.donor.media.count(), 0)
Example #5
0
    def test_upload_logo(self, mock_upload_medium, mock_is_mimetype_image, mock_validated_data, mock_is_valid):
        new_logo = MediumFactory.create()
        old_logo = self.charity.logo
        mock_upload_medium.return_value = new_logo

        response = self.client.put(
            reverse('api:admin:charity-logo', kwargs=dict(pk=self.charity.pk))
        )
        self.assertEqual(response.status_code, status.HTTP_200_OK)

        old_logo.refresh_from_db()
        self.assertNotEqual(old_logo.deleted_at, None)

        self.charity.refresh_from_db()
        self.assertEqual(self.charity.logo.pk, new_logo.pk)
Example #6
0
    def test_upload_medium(self, mock_upload_medium, mock_get_uploaded_file):
        new_medium = MediumFactory.create(instance=self.product)
        mock_upload_medium.return_value = new_medium

        file = MagicMock()
        file.content_type = 'image/png'
        mock_get_uploaded_file.return_value = file

        response = self.client.post(
            reverse('api:admin:product-medium',
                    kwargs=dict(pk=self.product.pk)),
            dict(embed='http://some-url-here'))
        self.assertEqual(response.status_code, status.HTTP_200_OK,
                         response.content)

        self.assertNotEqual(self.product.media.count(), 0)
 def setUp(self):
     super(DonorMediumDeleteViewTests, self).setUp()
     self.donor = DonorFactory.create()
     self.medium = MediumFactory.create(instance=self.donor)
Example #8
0
 def setUp(self):
     super(ProductMediumDeleteViewTests, self).setUp()
     self.product = ProductFactory.create()
     self.medium = MediumFactory.create(instance=self.product, )
Example #9
0
 def setUp(self):
     super(ProductDetailViewTests, self).setUp()
     self.product = ProductFactory.create()
     self.medium = MediumFactory.create(instance=self.product, order=1)