vendredi 19 février 2021

Does LogEntry objects gets create while running the tests scripts in Django?

I am trying to write test script

def test_logentry_gets_created(self):
        print("##############==================###############")
        path = 'url'
        t = self._create_blog()
        data = {'_selected_action': [t.pk], 'action': 'create_blog', 'csrfmiddlewaretoken': 'test',}
        self.client.post(path, data, follow=True)
        # I have a method defined which clones a blog article and then adds its actions in the LogEntry Model
        clone = t.clone(user)
        self.assertIn('test-blog (Clone)', str(LogEntry.objects.first()))
        print(LogEntry.objects.all().count())
        print("##############==================###############")

I am getting the count as Zero But since I am calling the LogEntry in the clone method shouldn't the object of this model get created?

Aucun commentaire:

Enregistrer un commentaire