Пример #1
0
 def testSaveCountShouldCreatesStockFacetRecord(self, mock_save):
     from stockandflow.models import Facet
     f = Facet("test_slug", "test name", "test_field", [1,2])
     s = Stock(*self.stock_args)
     s.facets = [f]
     s.save_count()
     self.assertEqual(mock_save.call_count, 2)
Пример #2
0
 def testSaveCountShouldPassThroughFieldPrefix(self, mock_save):
     from stockandflow.models import Facet
     f = Facet("test_slug", "test name", "test_field", [1,2])
     f.to_count = MagicMock()
     s = Stock(*self.stock_args)
     s.facets = [(f, "test_prefix")]
     s.save_count()
     self.assertEqual(f.to_count.call_args, (("test_prefix",), {}))
Пример #3
0
 def testMostRecentRecordShouldReturnCorrectStockRecord(self):
     s = Stock(*self.stock_args)
     s.save_count() # this would be the wrong record
     self.mock_qs.count.return_value = 111
     s.save_count()
     self.assertEqual(s.most_recent_record().count, 111)
     self.mock_qs.count.return_value = 222
     s.save_count()
     self.assertEqual(s.most_recent_record().count, 222)
Пример #4
0
 def testSaveCountShouldCreatesStockRecord(self, mock_save):
     s = Stock(*self.stock_args)
     s.save_count()
     self.assertTrue(mock_save.called)
Пример #5
0
 def testSaveCountShouldCheckTheCount(self):
     s = Stock(*self.stock_args)
     s.save_count()
     self.assertTrue(self.mock_qs.count.called)