From a7d5e0d1c92f7b0cfe2dd5fd1ca4b593fc3b3a24 Mon Sep 17 00:00:00 2001 From: Chenxiong Qi Date: Jul 12 2018 11:22:43 +0000 Subject: Replace extra module_name with repo_name module_name is replaced with repo_name in cli.py as well as tests, both calls to property Commands.module_name and name in tests names. Signed-off-by: Chenxiong Qi --- diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py index 3349957..f33d679 100644 --- a/pyrpkg/cli.py +++ b/pyrpkg/cli.py @@ -1480,8 +1480,8 @@ see API KEY section of copr-cli(1) man page. return koji_cli.lib.watch_tasks(self.cmd.kojisession, [task_id]) def chainbuild(self): - if self.cmd.module_name in self.args.package: - raise Exception('%s must not be in the chain' % self.cmd.module_name) + if self.cmd.repo_name in self.args.package: + raise Exception('%s must not be in the chain' % self.cmd.repo_name) # make sure we didn't get an empty chain if self.args.package == [':']: @@ -1822,7 +1822,7 @@ see API KEY section of copr-cli(1) man page. stream = self.args.stream if not self.args.file_path: - file_path = os.path.join(self.cmd.path, self.cmd.module_name + ".yaml") + file_path = os.path.join(self.cmd.path, self.cmd.repo_name + ".yaml") else: file_path = self.args.file_path @@ -2087,7 +2087,7 @@ see API KEY section of copr-cli(1) man page. self.cmd.verify_files(builddir=self.args.builddir) def verrel(self): - print('%s-%s-%s' % (self.cmd.module_name, self.cmd.ver, + print('%s-%s-%s' % (self.cmd.repo_name, self.cmd.ver, self.cmd.rel)) # Stole these three functions from /usr/bin/koji diff --git a/tests/commands/test_package_name.py b/tests/commands/test_package_name.py index 6c61856..57402e6 100644 --- a/tests/commands/test_package_name.py +++ b/tests/commands/test_package_name.py @@ -20,5 +20,5 @@ class CommandPackageNameTestCase(CommandTestCase): moduledir = os.path.join(self.path, self.module) cmd.path = moduledir - self.assertNotEqual(type(cmd.module_name), six.binary_type) - self.assertEqual(type(cmd.module_name), six.text_type) + self.assertNotEqual(type(cmd.repo_name), six.binary_type) + self.assertEqual(type(cmd.repo_name), six.text_type) diff --git a/tests/test_cli.py b/tests/test_cli.py index fd4442d..377f603 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -97,8 +97,8 @@ class TestModuleNameOption(CliTestCase): super(TestModuleNameOption, self).setUp() self.conf_file = self.get_absolute_conf_filename('rpkg-ns.conf') - def get_cmd(self, module_name, cfg=None): - cmd = ['rpkg', '--path', self.cloned_repo_path, '--module-name', module_name, 'verrel'] + def get_cmd(self, repo_name, cfg=None): + cmd = ['rpkg', '--path', self.cloned_repo_path, '--module-name', repo_name, 'verrel'] with patch('sys.argv', new=cmd): cli = self.new_cli(cfg=cfg) return cli.cmd @@ -657,7 +657,7 @@ class TestVerifyFiles(CliTestCase): class TestVerrel(CliTestCase): @patch('sys.stdout', new=StringIO()) - def test_verrel_get_module_name_from_spec(self): + def test_verrel_get_repo_name_from_spec(self): cli_cmd = ['rpkg', '--path', self.repo_path, '--release', 'rhel-6', 'verrel'] with patch('sys.argv', new=cli_cmd): @@ -675,9 +675,9 @@ class TestVerrel(CliTestCase): cli = self.new_cli() cli.verrel() - module_name = os.path.basename(self.repo_path) + repo_name = os.path.basename(self.repo_path) output = sys.stdout.getvalue().strip() - self.assertEqual('{0}-1.2-2.el6'.format(module_name), output) + self.assertEqual('{0}-1.2-2.el6'.format(repo_name), output) class TestSwitchBranch(CliTestCase): @@ -1047,7 +1047,7 @@ class LookasideCacheMock(object): def destroy_lookaside_cache(self): shutil.rmtree(self.lookasidecache_storage) - def lookasidecache_upload(self, module_name, filepath, hash): + def lookasidecache_upload(self, repo_name, filepath, hash): filename = os.path.basename(filepath) storage_filename = os.path.join(self.lookasidecache_storage, filename) with open(storage_filename, 'wb') as fout: @@ -1711,7 +1711,7 @@ class TestPatch(CliTestCase): cli.patch() m.return_value.write.assert_called_once_with('+ diff') - patch_file = '{0}-{1}-fix.patch'.format(cli.cmd.module_name, + patch_file = '{0}-{1}-fix.patch'.format(cli.cmd.repo_name, cli.cmd.ver) self.mock_repo.return_value.index.add.assert_called_once_with( [patch_file]) @@ -1747,7 +1747,7 @@ class TestPatch(CliTestCase): with patch('sys.argv', new=cli_cmd): cli = self.new_cli() - patch_file = '{0}-{1}-fix.patch'.format(cli.cmd.module_name, + patch_file = '{0}-{1}-fix.patch'.format(cli.cmd.repo_name, cli.cmd.ver) copied_patch_file = '{0}~'.format(patch_file) @@ -1787,7 +1787,7 @@ class TestPatch(CliTestCase): with patch('sys.argv', new=cli_cmd): cli = self.new_cli() - patch_file = '{0}-{1}-fix.patch'.format(cli.cmd.module_name, + patch_file = '{0}-{1}-fix.patch'.format(cli.cmd.repo_name, cli.cmd.ver) with patch('os.path.exists', return_value=False) as exists: six.assertRaisesRegex( @@ -2340,7 +2340,7 @@ State: failed mock_run.return_value = mock_proc with patch('sys.argv', new=cli_cmd): cli = self.new_cli() - file_path = os.path.join(self.cloned_repo_path, cli.cmd.module_name + '.yaml') + file_path = os.path.join(self.cloned_repo_path, cli.cmd.repo_name + '.yaml') # we create an empty file for the purpose of this test so we don't raise an exception open(file_path, 'a').close() cli.module_build_local() @@ -2366,7 +2366,7 @@ State: failed cli = self.new_cli() cli.config.set("rpkg.mbs", "config_file", "/etc/module-build-service/custom.py") cli.config.set("rpkg.mbs", "config_section", "CustomSection") - file_path = os.path.join(self.cloned_repo_path, cli.cmd.module_name + '.yaml') + file_path = os.path.join(self.cloned_repo_path, cli.cmd.repo_name + '.yaml') # we create an empty file for the purpose of this test so we don't raise an exception open(file_path, 'a').close() cli.module_build_local() @@ -2536,7 +2536,7 @@ State: failed # we create an empty file for the purpose of this test so we don't # raise an exception modulemd_yml = os.path.join(self.cloned_repo_path, - cli.cmd.module_name + '.yaml') + cli.cmd.repo_name + '.yaml') self.write_file(modulemd_yml) six.assertRaisesRegex(self, rpkgError, r'mbs-manager is missing.+', @@ -2608,7 +2608,7 @@ class TestOptionNameAndNamespace(CliTestCase): ] with patch('sys.argv', new=cli): cli = self.new_cli() - self.assertEqual('somepkg', cli.cmd.module_name) + self.assertEqual('somepkg', cli.cmd.repo_name) self.assertEqual('rpms', cli.cmd.ns) def test_name_and_namespace_with_distgit_namespace_enabled(self): @@ -2619,5 +2619,5 @@ class TestOptionNameAndNamespace(CliTestCase): with patch('sys.argv', new=cli): abs_filename = self.get_absolute_conf_filename('rpkg-ns.conf') cli = self.new_cli(abs_filename) - self.assertEqual('somepkg', cli.cmd.module_name) + self.assertEqual('somepkg', cli.cmd.repo_name) self.assertEqual('modules', cli.cmd.ns) diff --git a/tests/test_commands.py b/tests/test_commands.py index 269c40d..c53a24f 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -405,10 +405,10 @@ class TestProperties(CommandTestCase): def test_nvr(self): cmd = self.make_commands(dist='eng-rhel-6') - module_name = os.path.basename(self.repo_path) - self.assertEqual('{0}-1.2-2.el6'.format(module_name), cmd.nvr) + repo_name = os.path.basename(self.repo_path) + self.assertEqual('{0}-1.2-2.el6'.format(repo_name), cmd.nvr) - def test_nvr_cannot_get_module_name_from_push_url(self): + def test_nvr_cannot_get_repo_name_from_push_url(self): cmd = self.make_commands(path=self.repo_path, dist='eng-rhel-6') self.assertEqual('docpkg-1.2-2.el6', cmd.nvr) @@ -450,7 +450,7 @@ class TestProperties(CommandTestCase): expected_localarch = rpm.expandMacro('%{_arch}') self.assertEqual('eng-rhel-7-candidate-{0}'.format(expected_localarch), cmd.mockconfig) - def test_get_ns_module_name(self): + def test_get_ns_repo_name(self): cmd = self.make_commands(path=self.cloned_repo_path) tests = ( @@ -459,11 +459,11 @@ class TestProperties(CommandTestCase): ('http://localhost/docpkg.git', 'docpkg'), ('http://localhost/rpms/docpkg', 'docpkg'), ) - for push_url, expected_ns_module_name in tests: + for push_url, expected_ns_repo_name in tests: cmd._push_url = push_url cmd.load_ns() - cmd.load_module_name() - self.assertEqual(expected_ns_module_name, cmd.ns_module_name) + cmd.load_repo_name() + self.assertEqual(expected_ns_repo_name, cmd.ns_repo_name) cmd.distgit_namespaced = True tests = ( @@ -472,11 +472,11 @@ class TestProperties(CommandTestCase): ('http://localhost/docpkg.git', 'rpms/docpkg'), ('http://localhost/rpms/docpkg', 'rpms/docpkg'), ) - for push_url, expected_ns_module_name in tests: + for push_url, expected_ns_repo_name in tests: cmd._push_url = push_url cmd.load_ns() - cmd.load_module_name() - self.assertEqual(expected_ns_module_name, cmd.ns_module_name) + cmd.load_repo_name() + self.assertEqual(expected_ns_repo_name, cmd.ns_repo_name) class TestNamespaced(CommandTestCase): @@ -580,26 +580,26 @@ class TestTagInheritanceTag(CommandTestCase): self.assertRaises(rpkgError, cmd.check_inheritance, build_target, dest_tag) -class TestLoadModuleNameFromSpecialPushURL(CommandTestCase): - """Test load module name from a special push url that ends in / +class TestLoadRepoNameFromSpecialPushURL(CommandTestCase): + """Test load repo name from a special push url that ends in / For issue: https://pagure.io/rpkg/issue/192 """ def setUp(self): - super(TestLoadModuleNameFromSpecialPushURL, self).setUp() + super(TestLoadRepoNameFromSpecialPushURL, self).setUp() - self.case_repo = tempfile.mkdtemp(prefix='case-test-load-module-name-') + self.case_repo = tempfile.mkdtemp(prefix='case-test-load-repo-name-') cmd = ['git', 'clone', '{0}/'.format(self.repo_path), self.case_repo] self.run_cmd(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) def tearDown(self): shutil.rmtree(self.case_repo) - super(TestLoadModuleNameFromSpecialPushURL, self).tearDown() + super(TestLoadRepoNameFromSpecialPushURL, self).tearDown() - def test_load_module_name(self): + def test_load_repo_name(self): cmd = self.make_commands(path=self.case_repo) - self.assertEqual(os.path.basename(self.repo_path), cmd.module_name) + self.assertEqual(os.path.basename(self.repo_path), cmd.repo_name) class TestLoginKojiSession(CommandTestCase): @@ -697,33 +697,31 @@ class TestConstructBuildURL(CommandTestCase): @patch('pyrpkg.Commands.ns_repo_name', new_callable=PropertyMock) @patch('pyrpkg.Commands.commithash', new_callable=PropertyMock) - def test_construct_url(self, commithash, ns_module_name): + def test_construct_url(self, commithash, ns_repo_name): commithash.return_value = '12345' - ns_module_name.return_value = 'container/fedpkg' + ns_repo_name.return_value = 'container/fedpkg' cmd = self.make_commands() - anongiturl = 'https://src.example.com/%(module)s' + anongiturl = 'https://src.example.com/%(repo)s' with patch.object(cmd, 'anongiturl', new=anongiturl): url = cmd.construct_build_url() expected_url = '{0}#{1}'.format( - anongiturl % {'module': ns_module_name.return_value}, + anongiturl % {'repo': ns_repo_name.return_value}, commithash.return_value) self.assertEqual(expected_url, url) - def test_construct_with_given_module_name_and_hash(self): + def test_construct_with_given_repo_name_and_hash(self): cmd = self.make_commands() - anongiturl = 'https://src.example.com/%(module)s' + anongiturl = 'https://src.example.com/%(repo)s' with patch.object(cmd, 'anongiturl', new=anongiturl): - for module_name in ('extra-cmake-modules', - 'rpms/kf5-kfilemetadata'): - url = cmd.construct_build_url(module_name, '123456') + for repo_name in ('extra-cmake-modules', 'rpms/kf5-kfilemetadata'): + url = cmd.construct_build_url(repo_name, '123456') expected_url = '{0}#{1}'.format( - anongiturl % {'module': module_name}, - '123456') + anongiturl % {'repo': repo_name}, '123456') self.assertEqual(expected_url, url)