Answer the question
In order to leave comments, you need to log in
Testing dependent models?
I’m slowly getting to grips with testing, I’ve done testing for the User model on user._meta labels in the admin panel in general.
class UserModelTest(TestCase):
@classmethod
def setUp(cls):
User.objects.create(email="[email protected]", password="user", first_name="Big", last_name='Bob')
def test_username_label(self):
user = User.objects.get(id=1)
field_label = user._meta.get_field('username').verbose_name
self.assertEquals(field_label, 'имя пользователя')
class EvoprintUsersUrlsTest(TestCase):
def test_view_url_registration(self):
resp = self.client.get('/user/registration/')
self.assertEqual(resp.status_code, 200)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question