def setUp(self) -> None: obj = Kita(name='Kita', street_name='Foobar', number=12, postal_code=12345, email='*****@*****.**') obj.save() KitaRepresentative(first_name='Jon', name='Doe', email='*****@*****.**', kita=obj).save() KitaRepresentative(first_name='Jane', name='Doe', email='*****@*****.**', kita=obj).save()
def test_postalcode_invalid_str(self): try: Kita(name='Kita', street_name='Foobar', number=12, postal_code='12345', email='*****@*****.**') except ValidationError: pass
def _save_kita_entry(data: dict): street_key = 'street' if 'street' in data else 'street_name' postal_key = 'plz' if 'plz' in data else 'postal_code' num = int(data['number']) if data['number'] else 0 postal = int(data[postal_key]) if data[postal_key] else 12345 street = data[street_key] if data[street_key] else '-----' Kita(name=data['name'], email=data['email'], street_name=street, number=num, postal_code=postal).save()
def test_create_kita(self): obj = Kita(name='Kita', street_name='Foobar', number=12, postal_code=12345, email='*****@*****.**') obj.save() obj.refresh_from_db() self.assertIsNotNone(obj)
def setUp(self) -> None: Kita(name='Test', street_name='abcdefghijk', number='12a', postal_code=12345, email='*****@*****.**').save()