Esempio n. 1
0
 def test_provider_bad_criterion_id(self):
     provider = ProviderFactory(user=self.user)
     service = ServiceFactory(provider=provider, status=Service.STATUS_CURRENT)
     criterion1 = SelectionCriterionFactory.build(service=service)
     criterion1.id = 'abc'
     book = get_export_workbook([provider], None, [criterion1])
     rsp = self.import_book(book)
     self.assertContains(rsp, "Row 2: id: %s is not a valid ID" % criterion1.id,
                         status_code=BAD_REQUEST,
                         msg_prefix=rsp.content.decode('utf-8'))
Esempio n. 2
0
 def test_provider_add_criterion_bad_service(self):
     provider = ProviderFactory(user=self.user)
     criterion1 = SelectionCriterionFactory.build()
     service = criterion1.service
     book = get_export_workbook([provider], None, [criterion1])
     rsp = self.import_book(book)
     self.assertContains(rsp,
                         "Row 2: service__id: Selection criterion refers to service with ID "
                         "or name '%s' that is not in the 2nd sheet" % service.name_en,
                         status_code=BAD_REQUEST,
                         msg_prefix=rsp.content.decode('utf-8'))
Esempio n. 3
0
 def test_provider_add_criterion_bad_service(self):
     provider = ProviderFactory(user=self.user)
     criterion1 = SelectionCriterionFactory.build()
     service = criterion1.service
     book = get_export_workbook([provider], None, [criterion1])
     rsp = self.import_book(book)
     self.assertContains(
         rsp,
         "Row 2: service__id: Selection criterion refers to service with ID "
         "or name '%s' that is not in the 2nd sheet" % service.name_en,
         status_code=BAD_REQUEST,
         msg_prefix=rsp.content.decode('utf-8'))
Esempio n. 4
0
 def test_provider_bad_criterion_id(self):
     provider = ProviderFactory(user=self.user)
     service = ServiceFactory(provider=provider,
                              status=Service.STATUS_CURRENT)
     criterion1 = SelectionCriterionFactory.build(service=service)
     criterion1.id = 'abc'
     book = get_export_workbook([provider], None, [criterion1])
     rsp = self.import_book(book)
     self.assertContains(rsp,
                         "Row 2: id: %s is not a valid ID" % criterion1.id,
                         status_code=BAD_REQUEST,
                         msg_prefix=rsp.content.decode('utf-8'))
Esempio n. 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'))
Esempio n. 6
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'))
Esempio n. 7
0
 def test_provider_add_criteria(self):
     provider = ProviderFactory(user=self.user)
     service = ServiceFactory(provider=provider,
                              status=Service.STATUS_CURRENT)
     criterion1 = SelectionCriterionFactory(service=service)
     criterion2 = SelectionCriterionFactory.build(service=service,
                                                  text_en="New Criterion!")
     book = get_export_workbook([provider], None, [criterion1, criterion2])
     rsp = self.import_book(book)
     self.assertEqual(OK, rsp.status_code, msg=rsp.content.decode('utf-8'))
     # Existing one still there
     self.assertTrue(
         SelectionCriterion.objects.filter(service=service,
                                           text_en=criterion1.text_en,
                                           id=criterion1.id).exists())
     # New one added
     self.assertTrue(
         SelectionCriterion.objects.filter(
             service=service, text_en=criterion2.text_en).exists())
Esempio n. 8
0
 def test_provider_add_criteria(self):
     provider = ProviderFactory(user=self.user)
     service = ServiceFactory(provider=provider, status=Service.STATUS_CURRENT)
     criterion1 = SelectionCriterionFactory(service=service)
     criterion2 = SelectionCriterionFactory.build(service=service, text_en="New Criterion!")
     book = get_export_workbook([provider], None, [criterion1, criterion2])
     rsp = self.import_book(book)
     self.assertEqual(OK, rsp.status_code, msg=rsp.content.decode('utf-8'))
     # Existing one still there
     self.assertTrue(SelectionCriterion.objects.filter(
         service=service,
         text_en=criterion1.text_en,
         id=criterion1.id
     ).exists())
     # New one added
     self.assertTrue(SelectionCriterion.objects.filter(
         service=service,
         text_en=criterion2.text_en
     ).exists())
Esempio n. 9
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)
Esempio n. 10
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)