M
M
marselabdullin2020-09-30 17:28:06
Django
marselabdullin, 2020-09-30 17:28:06

Not passing test in django?

I'm trying to write a test that checks the content of a parameter in a template using the assertContains function, but the test fails:

class DashboardTests(TestCase):
    def setUp(self):
        self.user = User.objects.create_user(
            email='[email protected]', password='pass1234', email_confirm=True)
        self.client.login(username='[email protected]', password='pass1234')
        self.healht_data = baker.make(
            HealthData, user=CustomUser.objects.get(id=self.user.id))
        self.parameters = baker.make(
            Result, dashboard=self.healht_data, fat_percent='49 %, 3', bmi=20)
        self.url = reverse('cms:dashboard')
        self.resp = self.client.get(self.url)

    def test_parameters_template(self):
        self.assertEqual(self.resp.status_code, 200)
        self.assertTemplateUsed(self.resp, 'cms/dashboard.html')
        self.assertContains(self.resp, 'form')
        self.assertContains(self.resp, 'measuring_system')

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question