def test_add_with_error(self): # Setup strategy = mock.Mock() strategy.create_schedule.side_effect = ValueError('bad value') create_command = commands.CreateScheduleCommand( self.context, strategy, 'add', 'add') self.cli.add_command(create_command) # Test self.cli.run( 'add --schedule 2012-05-22T00:00:00/P1D --failure-threshold 10'. split()) # Verify args = strategy.create_schedule.call_args[0] self.assertEqual('2012-05-22T00:00:00/P1D', args[0]) self.assertEqual('10', args[1]) self.assertEqual(True, args[2]) self.assertEqual(2, len(self.prompt.get_write_tags())) self.assertEqual(TAG_FAILURE, self.prompt.get_write_tags()[0]) self.assertEqual(TAG_FAILURE, self.prompt.get_write_tags()[1])
def test_add(self): # Setup strategy = mock.Mock() strategy.create_schedule.return_value = Response(201, {}) create_command = commands.CreateScheduleCommand( self.context, strategy, 'add', 'add') create_command.create_option('--extra', 'extra') self.cli.add_command(create_command) # Test self.cli.run( 'add --schedule 2012-05-22T00:00:00/P1D --failure-threshold 10 --extra foo' .split()) # Verify args = strategy.create_schedule.call_args[0] self.assertEqual('2012-05-22T00:00:00/P1D', args[0]) self.assertEqual('10', args[1]) self.assertEqual(True, args[2]) self.assertEqual('foo', args[3]['extra']) self.assertEqual(1, len(self.prompt.get_write_tags())) self.assertEqual(TAG_SUCCESS, self.prompt.get_write_tags()[0])