Example #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)
Example #2
0
 def testFlowAddEventShouldReturnNoneIfSourceIsNotInSources(self):
     f = Flow(**self.args)
     self.assertTrue(f.add_event(Mock(), Mock(), self.stocks[1]) is None)