def test_start_prompt_with_package_updates_prompt(self): _, fn = tempfile.mkstemp() self.addCleanup(os.remove, fn) pkg = Package(product='123456789') dump_package(pkg.to_template(), fn) self.repl = UHURepl(fn) self.assertEqual(self.repl.prompt, '[123456] uhu> ')
def setUp(self): super().setUp() pkg = Package(version='1.0') pkg.objects.create(self.obj_options) dump_package(pkg.to_template(), self.pkg_fn) self.dest_pkg_fn = '/tmp/pkg-dump' self.addCleanup(self.remove_file, self.dest_pkg_fn)
def test_can_create_repl_with_default_package(self): pkg_fn = self.create_file(b'') self.set_env_var(LOCAL_CONFIG_VAR, pkg_fn) pkg = Package(version='2.0') dump_package(pkg.to_template(), pkg_fn) repl = UHURepl() self.assertEqual(repl.package.version, '2.0')
def test_metadata_commands_returns_0_when_metadata_is_valid(self): pkg = Package() pkg.objects.create(self.obj_options) pkg.product = '0' * 64 pkg.version = '2.0' dump_package(pkg.to_template(), self.pkg_fn) result = self.runner.invoke(metadata_command) self.assertEqual(result.exit_code, 0)
def test_open_package_quits_program_if_invalid_package(self): pkg_fn = self.create_file(b'') self.set_env_var(LOCAL_CONFIG_VAR, pkg_fn) pkg = Package() template = pkg.to_template() del template['objects'] with open(pkg_fn, 'w') as fp: json.dump(template, fp) with self.assertRaises(SystemExit): with open_package() as pkg: pass
def setUp(self): super().setUp() pkg = Package() dump_package(pkg.to_template(), self.pkg_fn)
def test_metadata_commands_returns_1_when_metadata_is_invalid(self): pkg = Package() dump_package(pkg.to_template(), self.pkg_fn) result = self.runner.invoke(metadata_command) self.assertEqual(result.exit_code, 1)
def test_show_command_returns_0_if_successful(self): pkg = Package() pkg.objects.create(self.obj_options) dump_package(pkg.to_template(), self.pkg_fn) result = self.runner.invoke(show_command) self.assertEqual(result.exit_code, 0)
def setUp(self): super().setUp() pkg = Package() pkg.objects.create(self.obj_options) dump_package(pkg.to_template(), self.pkg_fn)
def test_can_create_repl_with_custom_package_file(self): pkg_fn = self.create_file(b'') pkg = Package(version='2.0') dump_package(pkg.to_template(), pkg_fn) repl = UHURepl(pkg_fn) self.assertEqual(repl.package.version, '2.0')