def test_import_archive_without_type(self, stderr):
     expected = self.format_error_message("You must specify an archive type")
     with self.assertRaises(SystemExit) as ex:
         handle_import_archive(self.options, self.session, [self.build_id, self.archive_path])
     self.assertExitCode(ex, 2)
     self.assert_console_message(stderr, expected)
     self.activate_session_mock.assert_called_with(self.session, self.options)
 def test_import_archive_without_option(self, stderr):
     expected = self.format_error_message(
         "You must specify a build ID or N-V-R and an archive to import")
     with self.assertRaises(SystemExit) as ex:
         handle_import_archive(self.options, self.session, [])
     self.assertExitCode(ex, 2)
     self.assert_console_message(stderr, expected)
     self.activate_session_mock.assert_not_called()
 def test_import_archive_wrong_type(self, stderr):
     archive_type = 'test-type'
     expected = self.format_error_message("Unsupported archive type: %s" % archive_type)
     with self.assertRaises(SystemExit) as ex:
         handle_import_archive(self.options, self.session, ['--type', archive_type,
                                                            self.build_id, self.archive_path])
     self.assertExitCode(ex, 2)
     self.assert_console_message(stderr, expected)
     self.activate_session_mock.assert_called_with(self.session, self.options)
 def test_import_archive_without_option(self, stderr):
     expected = "Usage: %s import-archive <build-id|n-v-r> <archive_path> [<archive_path2 ...]\n" \
                "(Specify the --help global option for a list of other help options)\n\n" \
                "%s: error: You must specify a build ID or N-V-R and " \
                "an archive to import\n" % (self.progname, self.progname)
     with self.assertRaises(SystemExit) as ex:
         handle_import_archive(self.options, self.session, [])
     self.assertExitCode(ex, 2)
     self.assert_console_message(stderr, expected)
 def test_import_archive_type_win_without_type_info(self, stderr):
     archive_type = 'win'
     self.session.hasPerm.side_effect = [False, True]
     expected = self.format_error_message("--type-info must be specified")
     with self.assertRaises(SystemExit) as ex:
         handle_import_archive(self.options, self.session,
                               ['--type', archive_type, self.build_id, self.archive_path])
     self.assertExitCode(ex, 2)
     self.assert_console_message(stderr, expected)
     self.activate_session_mock.assert_called_with(self.session, self.options)
 def test_import_archive_type_win_without_perm(self, stderr):
     archive_type = 'win'
     self.session.hasPerm.side_effect = [False, False]
     expected = self.format_error_message("This action requires the win-import privilege")
     with self.assertRaises(SystemExit) as ex:
         handle_import_archive(self.options, self.session,
                               ['--type', archive_type, self.build_id, self.archive_path])
     self.assertExitCode(ex, 2)
     self.assert_console_message(stderr, expected)
     self.activate_session_mock.assert_called_with(self.session, self.options)
 def test_import_archive_wrong_type(self, stderr):
     archive_type = 'test-type'
     archive_path = '/mnt/brew/work/test-archive.type'
     expected = "Usage: %s import-archive <build-id|n-v-r> <archive_path> [<archive_path2 ...]\n" \
                "(Specify the --help global option for a list of other help options)\n\n" \
                "%s: error: Unsupported archive type: %s\n" % (self.progname, self.progname,
                                                               archive_type)
     with self.assertRaises(SystemExit) as ex:
         handle_import_archive(self.options, self.session, ['--type', archive_type, '12',
                                                            archive_path])
     self.assertExitCode(ex, 2)
     self.assert_console_message(stderr, expected)