S
S
Socrates2018-02-20 12:16:00
Django
Socrates, 2018-02-20 12:16:00

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, 'имя пользователя')

and so all the fields of the User model. What else needs to be tested here?
Protestl and view
class EvoprintUsersUrlsTest(TestCase):
    def test_view_url_registration(self):
        resp = self.client.get('/user/registration/')
        self.assertEqual(resp.status_code, 200)

The question arose of how to test those models that are tied to User. (additional information about the user)
It would be great every time, for example, to test registration, not to enter data, but to run a test that would fill out forms with random data and show the result.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2018-02-20
@sim3x

https://www.obeythetestinggoat.com/
Testing the label - not necessary
If the label is used, somewhere test its appearance where required

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question