Пример #1
0
 def test_staff_add_services(self):
     # Staff can add services to any provider
     self.user.is_staff = True
     self.user.save()
     provider = ProviderFactory()
     type = ServiceTypeFactory()
     area = ServiceAreaFactory()
     service = ServiceFactory.build(provider=provider, type=type, area_of_service=area)
     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(name_en=service.name_en)
     self.assertEqual(new_service.name_en, service.name_en)
Пример #2
0
 def test_provider_add_anothers_service(self):
     # A provider can't add a service to another provider
     provider = ProviderFactory()
     type = ServiceTypeFactory()
     area = ServiceAreaFactory()
     service = ServiceFactory.build(provider=provider, type=type, area_of_service=area)
     book = get_export_workbook([provider], [service])
     rsp = self.import_book(book)
     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, "Non-staff users may not create services for other providers",
                         status_code=BAD_REQUEST)
Пример #3
0
 def test_staff_add_services(self):
     # Staff can add services to any provider
     self.user.is_staff = True
     self.user.save()
     provider = ProviderFactory()
     type = ServiceTypeFactory()
     area = ServiceAreaFactory()
     service = ServiceFactory.build(provider=provider,
                                    type=type,
                                    area_of_service=area)
     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(name_en=service.name_en)
     self.assertEqual(new_service.name_en, service.name_en)
Пример #4
0
 def test_provider_add_bad_service(self):
     provider = ProviderFactory(user=self.user)
     type = ServiceTypeFactory()
     area = ServiceAreaFactory()
     service = ServiceFactory.build(provider=provider, type=type, area_of_service=area,
                                    name_en=VERY_LONG_STRING,
                                    tuesday_open=time(6, 59),
                                    tuesday_close=time(21, 2))
     self.assertIsNotNone(service.location)
     criterion = SelectionCriterionFactory.build(
         service=service
     )
     book = get_export_workbook([provider], [service], [criterion])
     rsp = self.import_book(book)
     self.assertEqual(BAD_REQUEST, rsp.status_code, msg=rsp.content.decode('utf-8'))
Пример #5
0
 def test_provider_add_bad_service(self):
     provider = ProviderFactory(user=self.user)
     type = ServiceTypeFactory()
     area = ServiceAreaFactory()
     service = ServiceFactory.build(provider=provider,
                                    type=type,
                                    area_of_service=area,
                                    name_en=VERY_LONG_STRING,
                                    tuesday_open=time(6, 59),
                                    tuesday_close=time(21, 2))
     self.assertIsNotNone(service.location)
     criterion = SelectionCriterionFactory.build(service=service)
     book = get_export_workbook([provider], [service], [criterion])
     rsp = self.import_book(book)
     self.assertEqual(BAD_REQUEST,
                      rsp.status_code,
                      msg=rsp.content.decode('utf-8'))
Пример #6
0
 def test_provider_add_anothers_service(self):
     # A provider can't add a service to another provider
     provider = ProviderFactory()
     type = ServiceTypeFactory()
     area = ServiceAreaFactory()
     service = ServiceFactory.build(provider=provider,
                                    type=type,
                                    area_of_service=area)
     book = get_export_workbook([provider], [service])
     rsp = self.import_book(book)
     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,
         "Non-staff users may not create services for other providers",
         status_code=BAD_REQUEST)
Пример #7
0
 def test_provider_add_service(self):
     # A provider can create a new service for themselves
     provider = ProviderFactory(user=self.user)
     type = ServiceTypeFactory()
     area = ServiceAreaFactory()
     service = ServiceFactory.build(provider=provider,
                                    type=type,
                                    area_of_service=area,
                                    tuesday_open=time(6, 59),
                                    tuesday_close=time(21, 2))
     self.assertIsNotNone(service.location)
     criterion = SelectionCriterionFactory.build(service=service)
     book = get_export_workbook([provider], [service], [criterion])
     rsp = self.import_book(book)
     self.assertEqual(OK, rsp.status_code, msg=rsp.content.decode('utf-8'))
     new_service = Service.objects.get(name_en=service.name_en)
     self.assertEqual(new_service.name_en, service.name_en)
     self.assertTrue(
         SelectionCriterion.objects.filter(
             service=new_service, text_en=criterion.text_en).exists())
     self.assertIsNotNone(new_service.location)
     self.assertEqual(service.location, new_service.location)
     self.assertEqual(service.tuesday_open, new_service.tuesday_open)
     self.assertEqual(service.tuesday_close, new_service.tuesday_close)
Пример #8
0
 def test_provider_add_service(self):
     # A provider can create a new service for themselves
     provider = ProviderFactory(user=self.user)
     type = ServiceTypeFactory()
     area = ServiceAreaFactory()
     service = ServiceFactory.build(provider=provider, type=type, area_of_service=area,
                                    tuesday_open=time(6, 59),
                                    tuesday_close=time(21, 2))
     self.assertIsNotNone(service.location)
     criterion = SelectionCriterionFactory.build(
         service=service
     )
     book = get_export_workbook([provider], [service], [criterion])
     rsp = self.import_book(book)
     self.assertEqual(OK, rsp.status_code, msg=rsp.content.decode('utf-8'))
     new_service = Service.objects.get(name_en=service.name_en)
     self.assertEqual(new_service.name_en, service.name_en)
     self.assertTrue(SelectionCriterion.objects.filter(service=new_service,
                                                       text_en=criterion.text_en
                                                       ).exists())
     self.assertIsNotNone(new_service.location)
     self.assertEqual(service.location, new_service.location)
     self.assertEqual(service.tuesday_open, new_service.tuesday_open)
     self.assertEqual(service.tuesday_close, new_service.tuesday_close)