def test_do_not_create_payment_if_profile_does_not_exist(self): self.client.force_authenticate(getattr(self.fixture, 'staff')) date = datetime.date.today() response = self.client.post(self.url, data={ 'date': date, 'proof': dummy_image() }, format='multipart') self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
def test_when_thumbnail_is_uploaded_plans_are_not_archived(self): # Arrange plan = factories.PlanFactory(offering=self.offering) # Act payload = {'thumbnail': dummy_image()} self.client.force_authenticate(self.fixture.owner) response = self.client.patch(self.url, payload, format='multipart') # Assert self.assertEqual(response.status_code, status.HTTP_200_OK, response.data) plan.refresh_from_db() self.assertFalse(plan.archived)
def test_upload_service_provider_image(self): payload = {'image': dummy_image()} response, service_provider = self.update_service_provider( 'staff', payload=payload, format='multipart') self.assertEqual(response.status_code, status.HTTP_200_OK, response.data) self.assertTrue(service_provider.image) url = factories.ServiceProviderFactory.get_url(service_provider) response = self.client.patch(url, {'image': None}) service_provider.refresh_from_db() self.assertEqual(response.status_code, status.HTTP_200_OK, response.data) self.assertFalse(service_provider.image)
def create_screenshot(self, user): user = getattr(self.fixture, user) self.client.force_authenticate(user) url = factories.ScreenshotFactory.get_list_url() self.provider = factories.ServiceProviderFactory( customer=self.customer) self.offering = factories.OfferingFactory(customer=self.customer) payload = { 'name': 'screenshot', 'offering': factories.OfferingFactory.get_url(offering=self.offering), 'image': dummy_image(), } return self.client.post(url, payload, format='multipart')
def test_create_payment_if_payment_data_has_been_passed(self): profile = factories.PaymentProfileFactory( organization=self.invoice.customer, is_active=True) self.client.force_authenticate(getattr(self.fixture, 'staff')) date = datetime.date.today() response = self.client.post(self.url, data={ 'date': date, 'proof': dummy_image() }, format='multipart') self.assertEqual(response.status_code, status.HTTP_200_OK) self.invoice.refresh_from_db() self.assertEqual(self.invoice.state, models.Invoice.States.PAID) self.assertEqual( models.Payment.objects.filter(date_of_payment=date, profile=profile).count(), 1, )
def setUp(self): super(AttachmentCreateTest, self).setUp() self.url = factories.AttachmentFactory.get_list_url() self.file = dummy_image()