mardi 12 avril 2016

How to test model method django

I write test to my app and I don't know how to test this model method:

def has_recipe(self):
    if self.type in [101, 102, 103, 104, 201, 301, 302, 303, 304]:
        return True
    else:
        return False

When I write test like this:

def test_has_recipe(self):
    book = Book(type in [101, 102, 103, 104, 201, 301, 302, 303, 304])
    self.assertTrue(book, [101, 102, 103, 104, 201, 301, 302, 303, 304])

test foes ok, but without coverage.

Aucun commentaire:

Enregistrer un commentaire