Beispiel #1
0
 def testGenerateAListOfFacetsSortedBySlugBasedOnTheStocks(self):
     from stockandflow.models import Stock, Facet
     from stockandflow.views import Process
     f1 = Facet("test_slug", "test name", "test_field", [1,2])
     f2 = Facet("test_slug", "test name", "test_field", [1,2])
     self.stock_args = []
     s1 = Stock('test name 1', 'test_slug_1', Mock())
     s2 = Stock('test name 2', 'test_slug_2', Mock())
     s1.facets = [f1]
     s2.facets = [f1, f2]
     process = Process("process_test", "process test", [s1, s2])
     self.assertEqual(process.facets, [f1, f2])
Beispiel #2
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)
Beispiel #3
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",), {}))