Пример #1
0
 def testCreateFlowEventShouldCreateDBRecord(self):
     # Create an object in the db - use stockrecord just because it is here and simple
     sr = StockRecord.objects.create(stock='no_stock', count=0)
     self.args["flow_event_model"] = Mock()
     f = Flow(**self.args)
     fe = f.add_event(sr, self.stocks[0], self.stocks[1])
     pos, kw = f.flow_event_model.call_args
     expect = {"flow": f.slug, "subject": sr, "source": self.stocks[0].slug,
               "sink": self.stocks[1].slug }
     self.assertEqual(expect, kw)
     self.assertTrue(f.flow_event_model.return_value.save.called)
Пример #2
0
 def testFlowAllWithSourceAndOrSinkShouldReturnAQSFilteredByTheSink(self):
     f = Flow(**self.args)
     qs_mock = f.all()
     sink_mock = Mock()
     source_mock = Mock()
     rv_mock = f.all(sink=sink_mock)
     self.assertEqual(((), {"sink": sink_mock.slug}), qs_mock.filter.call_args)
     qs_mock.reset_mock()
     rv_mock = f.all(source=source_mock)
     self.assertEqual(((), {"source": source_mock.slug}), qs_mock.filter.call_args)
     qs_mock.reset_mock()
     rv_mock = f.all(sink=sink_mock, source=source_mock)
     self.assertEqual(((), {"source": source_mock.slug}), qs_mock.filter.call_args)
     qs2_mock = qs_mock.filter.return_value
     self.assertEqual(((), {"sink": sink_mock.slug}), qs2_mock.filter.call_args)
Пример #3
0
 def testFlowAllShouldReturnTheFlowQS(self):
     f = Flow(**self.args)
     self.assertEqual(f.queryset, f.all())
Пример #4
0
 def testFlowAddEventShouldReturnNoneIfSourceIsNotInSources(self):
     f = Flow(**self.args)
     self.assertTrue(f.add_event(Mock(), Mock(), self.stocks[1]) is None)