def test_clean(self): """ Test that clean method doesn't raise error if company with similar name doesn't exist. """ models.Company.objects.create(name="Foo company") company = models.Company(name="Foo company 1") company.clean()
def test_company_address(self): """ Test that company_address returns Company string """ company = models.Company(name="Foo company", address_street="Foo street") self.assertEqual(company.company_address(), "Foo street")
def test_clean_ico_error_not_changed(self): """ Test that clean method doesn't raises error if company with same ico exists, but nothing changed on self. """ models.Company.objects.create(name="Foo", ico=12345) company = models.Company(name="Bar", ico=12345) company.save() company.clean()
def test_clean_ico_error(self): """ Test that clean method raises error if company with same ico exists. """ models.Company.objects.create(name="Foo", ico=12345) company = models.Company(name="Bar", ico=12345) with self.assertRaisesRegex( ValidationError, "Organizace s tímto IČO již existuje, nezakládemte prosím novou, ale vyberte jí prosím ze seznamu", ): company.clean()
def test_clean_name_error(self): """ Test that clean method raises error if company with similar name exists. """ models.Company.objects.create(name="Foo company") company = models.Company(name="Foo Čömpany") with self.assertRaisesRegex( ValidationError, "Organizace s tímto názvem již existuje. Nemusíte tedy zakládat novou, vyberte tu stávající." ): company.clean()
def test_has_filled_contact_information(self): """ Test that has_filled_contact_information returns True if address information is complete """ company = models.Company( name="Foo company", ico=123, address_street="Foo street", address_street_number=123, address_psc=12345, address_city="Foo city", ) self.assertEqual(company.has_filled_contact_information(), True)
def test_has_filled_contact_information_false(self): """ Test that has_filled_contact_information returns False if address information is not complete """ company = models.Company(name="Foo company") self.assertEqual(company.has_filled_contact_information(), False)
def test_str(self): """ Test that __str__ returns Company string """ company = models.Company(name="Foo company") self.assertEqual(str(company), "Foo company")
def test_admin_telephones_blank(self): """ Test that admin_telephones returns "" if no company admin exists """ company = models.Company(name="Foo company") self.assertEqual(company.admin_telephones(None), "")