def test_cancel_sn(self, tracker): sn = '1234' container = Mock() admin = Admin(container) canceled = admin.cancel(sn=sn) tracker.return_value.cancel.assert_called_once_with(sn) self.assertEqual(canceled, [tracker.return_value.cancel.return_value])
def test_cancel_criteria(self, tracker, builder): sn = '1234' name = 'joe' criteria = {'eq': name} tracker.return_value.find.return_value = [sn] # test admin = Admin() canceled = admin.cancel(criteria=criteria) # validation builder.return_value.build.assert_called_once_with(criteria) tracker.return_value.cancel.assert_called_once_with(sn) self.assertEqual(canceled, [tracker.return_value.cancel.return_value])
def cancel(self, sn=None, criteria=None): container = Container() admin = Admin(container) return admin.cancel(sn=sn, criteria=criteria)