lundi 22 février 2021

how to create test into with django

I just started to create an app and now I m trying to do somme test on it so I write a test code however it always return a 200 code even when I put a wrong URL that doesn't exist

here is the code

class TestViews(TestCase):
c=None
response = None
def setUp(self):
    User = apps.get_model('auth','user')
    User.objects.create_superuser("admin", "Admin", "Admin")
    self.c = Client()
    self.response = self.c.post('/login/', {'username': 'admin', 'password':'admin'})


def testAudit(self):
    
    self.response.get('/actors/audit')
    self.assertEqual(self.response.status_code,200)
   
def testGetFile(self):
    
    self.response.get('/actors/GetFile',{'file_name' : 'file1'})
    self.assertEqual(self.response.status_code,200)
   
    
def testDetail(self):
    
    self.response.get('/ffff')
    self.assertEqual(self.response.status_code,200)
   

can anyone help or does anyone went throught this problem tnx

Aucun commentaire:

Enregistrer un commentaire