def test_default_options(self):
     """Test for an empty command line."""
     arguments = stable_version._parse_args(['command'])
     self.assertFalse(arguments.dry_run)
     self.assertIsNone(arguments.type)
     self.assertIsNone(arguments.web)
     self.assertFalse(arguments.delete)
     self.assertIsNone(arguments.key)
     self.assertIsNone(arguments.version)
 def _dispatch_command_success(self, afe, argv, name_called):
     arguments = stable_version._parse_args(argv)
     patches = mock.patch.multiple(stable_version,
                                   list_all_mappings=mock.DEFAULT,
                                   list_mapping_by_key=mock.DEFAULT,
                                   set_mapping=mock.DEFAULT,
                                   delete_mapping=mock.DEFAULT)
     with patches as mocks:
         stable_version._dispatch_command(afe, arguments)
     for not_called in set(mocks) - set([name_called]):
         mocks[not_called].assert_not_called()
     return mocks[name_called]
 def _assert_command_error(self, argv):
     afe = object()
     arguments = stable_version._parse_args(argv)
     with self.assertRaises(stable_version._CommandError):
         stable_version._dispatch_command(afe, arguments)
 def test_version_argument(self):
     """Test for the VERSION argument."""
     argv = ['command', 'key', 'version']
     arguments = stable_version._parse_args(argv)
     self.assertEqual(arguments.key, argv[1])
     self.assertEqual(arguments.version, argv[2])
 def test_key_argument(self):
     """Test for the BOARD_OR_MODEL argument."""
     argv = ['command', 'key']
     arguments = stable_version._parse_args(argv)
     self.assertEqual(arguments.key, argv[1])
 def test_delete_option(self):
     """Test for the `--delete` option."""
     for option in ['-d', '--delete']:
         argv = ['command', option]
         arguments = stable_version._parse_args(argv)
         self.assertTrue(arguments.delete)
 def test_image_type_option(self):
     """Test for the `--type` option."""
     for image_type in stable_version._ALL_IMAGE_TYPES:
         for option in ['-t', '--type']:
             argv = ['command', option, image_type]
             arguments = stable_version._parse_args(argv)
 def test_dry_run_option(self):
     """Test for the `--dry-run` option."""
     for option in ['-n', '--dry-run']:
         argv = ['command', option]
         arguments = stable_version._parse_args(argv)
         self.assertTrue(arguments.dry_run)
 def test_web_option(self):
     """Test for the `--web` option."""
     for option in ['-w', '--web']:
         argv = ['command', option, 'server']
         arguments = stable_version._parse_args(argv)
         self.assertEqual(arguments.web, argv[2])