diff options
author | Tim Harder <radhermit@gmail.com> | 2021-06-30 16:23:53 -0600 |
---|---|---|
committer | Tim Harder <radhermit@gmail.com> | 2021-06-30 16:23:53 -0600 |
commit | cecfd75a1284b56a8046d36f66295cb188e6bcf8 (patch) | |
tree | 65d63e4e8c01d9fc5023c0b223bb8d0ace89356e /tests | |
parent | pkgdev commit: drop unnecessary message existence conditional (diff) | |
download | pkgdev-cecfd75a1284b56a8046d36f66295cb188e6bcf8.tar.gz pkgdev-cecfd75a1284b56a8046d36f66295cb188e6bcf8.tar.bz2 pkgdev-cecfd75a1284b56a8046d36f66295cb188e6bcf8.zip |
tests: add initial generated summary checks for metadata changes
Diffstat (limited to 'tests')
-rw-r--r-- | tests/scripts/test_pkgdev_commit.py | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/tests/scripts/test_pkgdev_commit.py b/tests/scripts/test_pkgdev_commit.py index 833125d..9412dc7 100644 --- a/tests/scripts/test_pkgdev_commit.py +++ b/tests/scripts/test_pkgdev_commit.py @@ -518,6 +518,91 @@ class TestPkgdevCommit: shutil.rmtree(pjoin(git_repo.path, 'newcat/pkg')) assert commit() == 'newcat/pkg: treeclean' + def test_metadata_summaries(self, capsys, repo, make_git_repo): + git_repo = make_git_repo(repo.location) + pkgdir = os.path.dirname(repo.create_ebuild('cat/pkg-0')) + # stub metadata + with open(pjoin(pkgdir, 'metadata.xml'), 'w') as f: + f.write(textwrap.dedent("""\ + <?xml version="1.0" encoding="UTF-8"?> + <!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> + <pkgmetadata> + <maintainer type="person"> + <email>person@email.com</email> + <name>Person</name> + </maintainer> + </pkgmetadata> + """)) + git_repo.add_all('cat/pkg-0') + + def commit(): + with os_environ(GIT_EDITOR="sed -i '1s/$/summary/'"), \ + patch('sys.argv', self.args + ['-a']), \ + pytest.raises(SystemExit) as excinfo, \ + chdir(git_repo.path): + self.script() + assert excinfo.value.code == 0 + out, err = capsys.readouterr() + assert err == out == '' + message = git_repo.log(['-1', '--pretty=tformat:%B', 'HEAD']) + return message[0] + + # add yourself + with open(pjoin(pkgdir, 'metadata.xml'), 'w') as f: + f.write(textwrap.dedent("""\ + <?xml version="1.0" encoding="UTF-8"?> + <!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> + <pkgmetadata> + <maintainer type="person"> + <email>person@email.com</email> + <name>Person</name> + </maintainer> + <maintainer type="person"> + <email>first.last@email.com</email> + <name>First Last</name> + </maintainer> + </pkgmetadata> + """)) + assert commit() == 'cat/pkg: add myself as a maintainer' + + # drop yourself + with open(pjoin(pkgdir, 'metadata.xml'), 'w') as f: + f.write(textwrap.dedent("""\ + <?xml version="1.0" encoding="UTF-8"?> + <!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> + <pkgmetadata> + <maintainer type="person"> + <email>person@email.com</email> + <name>Person</name> + </maintainer> + </pkgmetadata> + """)) + assert commit() == 'cat/pkg: drop myself as a maintainer' + + # drop to maintainer-needed + with open(pjoin(pkgdir, 'metadata.xml'), 'w') as f: + f.write(textwrap.dedent("""\ + <?xml version="1.0" encoding="UTF-8"?> + <!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> + <pkgmetadata> + </pkgmetadata> + """)) + assert commit() == 'cat/pkg: drop to maintainer-needed' + + # add random maintainer + with open(pjoin(pkgdir, 'metadata.xml'), 'w') as f: + f.write(textwrap.dedent("""\ + <?xml version="1.0" encoding="UTF-8"?> + <!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> + <pkgmetadata> + <maintainer type="person"> + <email>person@email.com</email> + <name>Person</name> + </maintainer> + </pkgmetadata> + """)) + assert commit() == 'cat/pkg: update maintainers' + def test_no_summary(self, capsys, repo, make_git_repo): git_repo = make_git_repo(repo.location) repo.create_ebuild('cat/pkg-0') |