Example #1
0
 def test_staff_change_providers(self):
     # Staff can change multiple providers
     self.user.is_staff = True
     self.user.save()
     provider1 = ProviderFactory()
     provider2 = ProviderFactory()
     # Tweak some data
     provider1.name_en = 'Jim-Bob'
     provider1.name_ar = 'Ahmed-Bob'
     provider1.name_fr = 'Pierre-Bob'
     provider2.number_of_monthly_beneficiaries = 1024
     provider2.type = ProviderTypeFactory()
     book = get_export_workbook([provider1, provider2])
     rsp = self.import_book(book)
     self.assertEqual(OK, rsp.status_code, msg=rsp.content.decode('utf-8'))
     new_provider1 = Provider.objects.get(id=provider1.id)
     self.assertEqual(provider1.name_en, new_provider1.name_en)
     self.assertEqual(provider1.name_ar, new_provider1.name_ar)
     self.assertEqual(provider1.name_fr, new_provider1.name_fr)
     new_provider2 = Provider.objects.get(id=provider2.id)
     self.assertEqual(provider2.number_of_monthly_beneficiaries,
                      new_provider2.number_of_monthly_beneficiaries)
Example #2
0
 def test_staff_change_providers(self):
     # Staff can change multiple providers
     self.user.is_staff = True
     self.user.save()
     provider1 = ProviderFactory()
     provider2 = ProviderFactory()
     # Tweak some data
     provider1.name_en = 'Jim-Bob'
     provider1.name_ar = 'Ahmed-Bob'
     provider1.name_fr = 'Pierre-Bob'
     provider2.number_of_monthly_beneficiaries = 1024
     provider2.type = ProviderTypeFactory()
     book = get_export_workbook([provider1, provider2])
     rsp = self.import_book(book)
     self.assertEqual(OK, rsp.status_code, msg=rsp.content.decode('utf-8'))
     new_provider1 = Provider.objects.get(id=provider1.id)
     self.assertEqual(provider1.name_en, new_provider1.name_en)
     self.assertEqual(provider1.name_ar, new_provider1.name_ar)
     self.assertEqual(provider1.name_fr, new_provider1.name_fr)
     new_provider2 = Provider.objects.get(id=provider2.id)
     self.assertEqual(provider2.number_of_monthly_beneficiaries,
                      new_provider2.number_of_monthly_beneficiaries)
 def test_staff_change_providers(self):
     # Staff can change multiple providers
     self.user.is_staff = True
     self.user.save()
     provider1 = ProviderFactory()
     provider2 = ProviderFactory()
     name_fields = generate_translated_fields('name', False)
     # Tweak some data
     for field in name_fields:
         setattr(provider1, field, random_string(10))
     provider2.number_of_monthly_beneficiaries = 1024
     provider2.type = ProviderTypeFactory()
     book = get_export_workbook([provider1, provider2])
     rsp = self.import_book(book)
     self.assertEqual(OK, rsp.status_code, msg=rsp.content.decode('utf-8'))
     new_provider1 = Provider.objects.get(id=provider1.id)
     for field in name_fields:
         self.assertEqual(getattr(provider1, field),
                          getattr(new_provider1, field))
     new_provider2 = Provider.objects.get(id=provider2.id)
     self.assertEqual(provider2.number_of_monthly_beneficiaries,
                      new_provider2.number_of_monthly_beneficiaries)