def test_should_softdelete_headquarter(self): headquarter = HeadquarterFactory() uuid = headquarter.pk headquarter.delete() exists = Headquarter.objects.filter(pk=uuid).exists() self.assertFalse(exists) exists = Headquarter.original_objects.filter(pk=uuid).exists() self.assertTrue(exists)
def test_should_create_headquarters_with_the_same_name_in_different_companies_and_cities(self): other_city = CityFactory( name='city #2', country=self.country, google_map_key='key #2', code=5002, type=City.Types.locality ) other_company = CompanyFactory( name='test company #2', country=self.country, created_by=self.user, namespace='testcompany2' ) other_headquarter = HeadquarterFactory( **{ 'company': other_company, 'name': 'test headquarter', 'address': 'test #2 address', 'city': other_city, 'created_by': self.user } ) self.assertIsNotNone(other_headquarter)
def test_should_user_has_not_permission_in_another_headquarter_in_other_company(self): headquarter = HeadquarterFactory( company=self.company, city=self.city, created_by=self.user, ) self.assertEqual(self.user.user_permissions.count(), 0) perm_pks = Permission.objects.all().values_list('codename', flat=True) self._add_user_permissions(perms=perm_pks, user=self.user, headquarter=self.headquarter) perm = Permission.objects.first() perm_codename = '%s.%s.%s' % (perm.content_type.app_label, perm.codename, headquarter.pk) self.assertFalse(self.user.has_perm(perm_codename))
def setUp(self): self.user = self.make_user() self.country = Country.objects.create(name='Colombia') self.city = City.objects.create(name='Colombia', country=self.country) self.language_code = LanguageCode.objects.create(name='Español', code='Es_co') self.company = CompanyFactory(country=self.country, created_by=self.user) self.headquarter = HeadquarterFactory( company=self.company, city=self.city, created_by=self.user, )
def setUp(self) -> None: self.user = self.make_user() self.country = CountryFactory(name='Colombia') self.city = CityFactory( country=self.country, google_map_key='key', code=5001, type=City.Types.locality ) self.company = CompanyFactory( name='test company', country=self.country, created_by=self.user, namespace='testcompany') self.headquarter = HeadquarterFactory( company=self.company, name='test headquarter', address='address', city=self.city, created_by=self.user )
def test_should_create_headquarters_with_the_same_name_in_the_same_city(self): # Even if the companies doesn't the same. other_company = CompanyFactory( name='test company #2', country=self.country, created_by=self.user, namespace='testcompany2' ) other_headquarter = HeadquarterFactory( **{ 'company': other_company, 'name': 'test headquarter', 'address': 'test #2 address', 'city': self.city, 'created_by': self.user } ) self.assertIsNotNone(other_headquarter)