Curently I've a Django Application and it works perfect when using their models on my project. But when I try to create a new object when testing on my test.py it wont save tried debug and it returns for object.pk (None)
Here is my code:
class TestUserViews(TestCase):
def test_authentication_success(self):
try:
cc = Country.objects.create(name="Lala Land")
print('country saved')
print(cc.id)
print('-----')
except Exception as error:
print(error)
try:
ll = Language.objects.create(name="English")
print('language saved')
print(ll.id)
print('-----')
except Exception as error:
print(error)
try:
user = User.objects.create(first_name="user name",
last_name="user last",
phone="000123455",
identification="0000001123",
address="my house",
country=cc,
language=ll,
email="email@mail.com",
password=hash_string("mypassword"))
print('User saved')
print(user.id)
except Exception as error:
print(error)
Aucun commentaire:
Enregistrer un commentaire