def test_train_classifier_with_auto_correspondent(self, load_classifier): load_classifier.return_value = None Correspondent.objects.create(matching_algorithm=Tag.MATCH_AUTO, name="test") tasks.train_classifier() load_classifier.assert_called_once() self.assertFalse(os.path.isfile(settings.MODEL_FILE))
def test_train_classifier(self): c = Correspondent.objects.create(matching_algorithm=Tag.MATCH_AUTO, name="test") doc = Document.objects.create(correspondent=c, content="test", title="test") self.assertFalse(os.path.isfile(settings.MODEL_FILE)) tasks.train_classifier() self.assertTrue(os.path.isfile(settings.MODEL_FILE)) mtime = os.stat(settings.MODEL_FILE).st_mtime tasks.train_classifier() self.assertTrue(os.path.isfile(settings.MODEL_FILE)) mtime2 = os.stat(settings.MODEL_FILE).st_mtime self.assertEqual(mtime, mtime2) doc.content = "test2" doc.save() tasks.train_classifier() self.assertTrue(os.path.isfile(settings.MODEL_FILE)) mtime3 = os.stat(settings.MODEL_FILE).st_mtime self.assertNotEqual(mtime2, mtime3)
def test_train_classifier_no_auto_matching(self, load_classifier): tasks.train_classifier() load_classifier.assert_not_called()
def test_train_classifier(self): tasks.train_classifier()