def test_cache_train_with_no_file(self, exists_mock): exists_mock.return_value = False sb = SimpleBayes() result = sb.cache_train() exists_mock.assert_called_once_with('/tmp/_simplebayes.pickle') self.assertFalse(result)
def test_cache_train_with_no_file(self, exists_mock): exists_mock.return_value = False sb = SimpleBayes() result = sb.cache_train() exists_mock.assert_called_once_with('/tmp/_simplebayes.pickle') self.assertFalse(result)
def test_cache_train(self, exists_mock, load_mock, open_mock, calc_mock): categories = BayesCategories() categories.categories = {'foo': 'bar'} load_mock.return_value = categories open_mock.return_value = 'opened' exists_mock.return_value = True sb = SimpleBayes(cache_path='foo') sb.cache_train() exists_mock.assert_called_once_with('foo/_simplebayes.pickle') open_mock.assert_called_once_with('foo/_simplebayes.pickle', 'rb') load_mock.assert_called_once_with('opened') calc_mock.assert_called_once_with() self.assertEqual(sb.categories, categories)
def test_cache_train(self, exists_mock, load_mock, open_mock, calc_mock): categories = BayesCategories() categories.categories = {'foo': 'bar'} load_mock.return_value = categories open_mock.return_value = 'opened' exists_mock.return_value = True sb = SimpleBayes(cache_path='foo') sb.cache_train() exists_mock.assert_called_once_with('foo/_simplebayes.pickle') open_mock.assert_called_once_with('foo/_simplebayes.pickle', 'rb') load_mock.assert_called_once_with('opened') calc_mock.assert_called_once_with() self.assertEqual(sb.categories, categories)