from django.contrib.auth import get_user_model from django.test import TestCase from kfet.models import Account User = get_user_model() class AccountTests(TestCase): def setUp(self): self.account = Account(trigramme='000') self.account.save({'username': 'user'}) def test_password(self): self.account.change_pwd('anna') self.account.save() self.assertEqual(Account.objects.get_by_password('anna'), self.account) with self.assertRaises(Account.DoesNotExist): Account.objects.get_by_password(None) with self.assertRaises(Account.DoesNotExist): Account.objects.get_by_password('bernard')