Exemple #1
0
 def test_update(self):
     reimbursement = Mock()
     command = Command()
     command.queue = []
     command.update(reimbursement)
     reimbursement.get_receipt_url.assert_called_once_with(bulk=True)
     self.assertEqual(1, len(command.queue))
Exemple #2
0
 def test_bulk_update(self, print_saving, bulk_update):
     command = Command()
     command.queue = [1, 2, 3]
     command.bulk_update()
     fields = ['receipt_url', 'receipt_fetched']
     bulk_update.assert_called_once_with([1, 2, 3], update_fields=fields)
     self.assertEqual([], command.queue)
     print_saving.assert_called_once_with()
Exemple #3
0
 def test_update_with_error(self):
     reimbursement = Mock()
     reimbursement.get_receipt_url.side_effect = ConnectionError()
     command = Command()
     command.queue = []
     command.update(reimbursement)
     reimbursement.get_receipt_url.assert_called_once_with(bulk=True)
     self.assertEqual(0, len(command.queue))
Exemple #4
0
 def test_fetch(self, print_count, bulk_update, update):
     command = Command()
     command.count = 0
     command.queryset = (1, 2, 3)
     command.queue = []
     command.fetch()
     print_count.assert_has_calls((call(), call(), call()))
     update.assert_has_calls(call(i) for i in range(1, 4))
     self.assertEqual(3, command.count)
     bulk_update.assert_called_once_with()