Exemple #1
0
 def test_provider_change_nonexistent_service(self):
     provider = ProviderFactory(user=self.user)
     type = ServiceTypeFactory()
     area = ServiceAreaFactory()
     service = ServiceFactory(provider=provider, type=type, area_of_service=area)
     service.name_en = 'Radiator Repair'
     service.name_fr = 'Le Marseilles'
     book = get_export_workbook([provider], [service])
     service_id = service.id
     service.delete()
     rsp = self.import_book(book)
     self.assertContains(rsp, "%d is not a service this user may import" % service_id,
                         status_code=BAD_REQUEST)
Exemple #2
0
 def test_provider_change_service(self):
     # A provider can change their existing service
     provider = ProviderFactory(user=self.user)
     type = ServiceTypeFactory()
     area = ServiceAreaFactory()
     service = ServiceFactory(provider=provider, type=type, area_of_service=area)
     service.name_en = 'Radiator Repair'
     service.name_fr = 'Le Marseilles'
     book = get_export_workbook([provider], [service])
     rsp = self.import_book(book)
     self.assertEqual(OK, rsp.status_code, msg=rsp.content.decode('utf-8'))
     new_service = Service.objects.get(id=service.id)
     self.assertEqual(service.name_en, new_service.name_en)
     self.assertEqual(service.name_fr, new_service.name_fr)
Exemple #3
0
 def test_provider_change_service(self):
     # A provider can change their existing service
     provider = ProviderFactory(user=self.user)
     type = ServiceTypeFactory()
     area = ServiceAreaFactory()
     service = ServiceFactory(provider=provider,
                              type=type,
                              area_of_service=area)
     service.name_en = 'Radiator Repair'
     service.name_fr = 'Le Marseilles'
     book = get_export_workbook([provider], [service])
     rsp = self.import_book(book)
     self.assertEqual(OK, rsp.status_code, msg=rsp.content.decode('utf-8'))
     new_service = Service.objects.get(id=service.id)
     self.assertEqual(service.name_en, new_service.name_en)
     self.assertEqual(service.name_fr, new_service.name_fr)
Exemple #4
0
 def test_staff_change_services(self):
     # Staff can change anyone's service
     self.user.is_staff = True
     self.user.save()
     provider = ProviderFactory()
     type = ServiceTypeFactory()
     area = ServiceAreaFactory()
     service = ServiceFactory(provider=provider, type=type, area_of_service=area)
     service.name_en = 'Radiator Repair'
     service.name_fr = 'Le Marseilles'
     book = get_export_workbook([provider], [service])
     rsp = self.import_book(book)
     self.assertEqual(OK, rsp.status_code, msg=rsp.content.decode('utf-8'))
     new_service = Service.objects.get(id=service.id)
     self.assertEqual(service.name_en, new_service.name_en)
     self.assertEqual(service.name_fr, new_service.name_fr)
Exemple #5
0
 def test_provider_change_anothers_service(self):
     # A provider cannot change another provider's existing service
     provider = ProviderFactory()
     type = ServiceTypeFactory()
     area = ServiceAreaFactory()
     service = ServiceFactory(provider=provider, type=type, area_of_service=area)
     service.name_en = 'Radiator Repair'
     service.name_fr = 'Le Marseilles'
     book = get_export_workbook([provider], [service])
     rsp = self.import_book(book)
     # self.fail(rsp.content.decode('utf-8'))
     self.assertEqual(BAD_REQUEST, rsp.status_code, msg=rsp.content.decode('utf-8'))
     self.assertContains(rsp, "%d is not a provider this user may import" % provider.id,
                         status_code=BAD_REQUEST)
     self.assertContains(rsp, "%d is not a service this user may import" % service.id,
                         status_code=BAD_REQUEST)
Exemple #6
0
 def test_provider_change_nonexistent_service(self):
     provider = ProviderFactory(user=self.user)
     type = ServiceTypeFactory()
     area = ServiceAreaFactory()
     service = ServiceFactory(provider=provider,
                              type=type,
                              area_of_service=area)
     service.name_en = 'Radiator Repair'
     service.name_fr = 'Le Marseilles'
     book = get_export_workbook([provider], [service])
     service_id = service.id
     service.delete()
     rsp = self.import_book(book)
     self.assertContains(rsp,
                         "%d is not a service this user may import" %
                         service_id,
                         status_code=BAD_REQUEST)
Exemple #7
0
 def test_staff_change_services(self):
     # Staff can change anyone's service
     self.user.is_staff = True
     self.user.save()
     provider = ProviderFactory()
     type = ServiceTypeFactory()
     area = ServiceAreaFactory()
     service = ServiceFactory(provider=provider,
                              type=type,
                              area_of_service=area)
     service.name_en = 'Radiator Repair'
     service.name_fr = 'Le Marseilles'
     book = get_export_workbook([provider], [service])
     rsp = self.import_book(book)
     self.assertEqual(OK, rsp.status_code, msg=rsp.content.decode('utf-8'))
     new_service = Service.objects.get(id=service.id)
     self.assertEqual(service.name_en, new_service.name_en)
     self.assertEqual(service.name_fr, new_service.name_fr)
Exemple #8
0
 def test_provider_change_anothers_service(self):
     # A provider cannot change another provider's existing service
     provider = ProviderFactory()
     type = ServiceTypeFactory()
     area = ServiceAreaFactory()
     service = ServiceFactory(provider=provider,
                              type=type,
                              area_of_service=area)
     service.name_en = 'Radiator Repair'
     service.name_fr = 'Le Marseilles'
     book = get_export_workbook([provider], [service])
     rsp = self.import_book(book)
     # self.fail(rsp.content.decode('utf-8'))
     self.assertEqual(BAD_REQUEST,
                      rsp.status_code,
                      msg=rsp.content.decode('utf-8'))
     self.assertContains(rsp,
                         "%d is not a provider this user may import" %
                         provider.id,
                         status_code=BAD_REQUEST)
     self.assertContains(rsp,
                         "%d is not a service this user may import" %
                         service.id,
                         status_code=BAD_REQUEST)