1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883
|
#!/usr/bin/python
# Copyright (C) 2018 Jelmer Vernooij
#
# Tests for find_thanks and find_extra_authors originally imported from
# breezy-debian, also (C) 2006 James Westby
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
"""Tests for lintian_brush.changelog."""
import os
import shutil
import tempfile
from datetime import datetime
from unittest import TestCase
from debian.changelog import Changelog, Version
from debmutate.changelog import (
ChangelogCreateError,
ChangelogEditor,
TextWrapper,
all_sha_prefixed,
changeblock_ensure_first_line,
changes_sections,
find_extra_authors,
find_last_distribution,
find_thanks,
increment_version,
new_upstream_package_version,
release,
rewrap_change,
strip_changelog_message,
take_uploadership,
upstream_merge_changelog_line,
)
class CreateChangelogTests(TestCase):
def setUp(self):
self.test_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.test_dir)
self.addCleanup(os.chdir, os.getcwd())
os.chdir(self.test_dir)
os.mkdir("debian")
def test_create(self):
with ChangelogEditor.create() as updater:
updater.new_block(
package="blah",
version=Version("1.0-1"),
author="Jelmer Vernooij <jelmer@debian.org>",
date="Mon, 02 Sep 2019 00:23:11 +0000",
distributions="UNRELEASED",
changes=["", " * New entry.", ""],
)
with open("debian/changelog") as f:
self.assertEqual(
"""\
blah (1.0-1) UNRELEASED; urgency=unknown
* New entry.
-- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Sep 2019 00:23:11 +0000
""",
f.read(),
)
def test_auto_version(self):
with ChangelogEditor.create() as updater:
updater.auto_version(
Version("1.0-1"),
package="blah",
urgency="low",
maintainer=("Jelmer Vernooij", "jelmer@debian.org"),
timestamp=datetime.utcfromtimestamp(1604934305),
)
with open("debian/changelog") as f:
self.assertEqual(
"""\
blah (1.0-1) UNRELEASED; urgency=low
-- Jelmer Vernooij <jelmer@debian.org> Mon, 09 Nov 2020 15:05:05 -0000
""",
f.read(),
)
class UpdateChangelogTests(TestCase):
def setUp(self):
self.test_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.test_dir)
self.addCleanup(os.chdir, os.getcwd())
os.chdir(self.test_dir)
os.mkdir("debian")
with open("debian/changelog", "w") as f:
f.write(
"""\
lintian-brush (0.28) UNRELEASED; urgency=medium
* Add fixer for obsolete-runtime-tests-restriction.
-- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Sep 2019 00:23:11 +0000
"""
)
def test_edit_simple(self):
with ChangelogEditor() as updater:
updater.changelog.version = "0.29"
with open("debian/changelog") as f:
self.assertEqual(
"""\
lintian-brush (0.29) UNRELEASED; urgency=medium
* Add fixer for obsolete-runtime-tests-restriction.
-- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Sep 2019 00:23:11 +0000
""",
f.read(),
)
def test_auto_version_update(self):
with ChangelogEditor() as updater:
updater.auto_version(
Version("0.29"), timestamp=datetime.utcfromtimestamp(1604934305)
)
with open("debian/changelog") as f:
self.assertEqual(
"""\
lintian-brush (0.29) UNRELEASED; urgency=medium
* Add fixer for obsolete-runtime-tests-restriction.
-- Jelmer Vernooij <jelmer@debian.org> Mon, 09 Nov 2020 15:05:05 -0000
""",
f.read(),
)
def test_auto_version_add(self):
with open("debian/changelog", "w") as f:
f.write(
"""\
lintian-brush (0.28) unstable; urgency=medium
* Add fixer for obsolete-runtime-tests-restriction.
-- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Sep 2019 00:23:11 +0000
"""
)
with ChangelogEditor() as updater:
updater.auto_version(
Version("0.29"),
maintainer=("Jelmer Vernooij", "jelmer@debian.org"),
timestamp=datetime.utcfromtimestamp(1604934305),
)
with open("debian/changelog") as f:
self.assertEqual(
"""\
lintian-brush (0.29) UNRELEASED; urgency=low
-- Jelmer Vernooij <jelmer@debian.org> Mon, 09 Nov 2020 15:05:05 -0000
lintian-brush (0.28) unstable; urgency=medium
* Add fixer for obsolete-runtime-tests-restriction.
-- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Sep 2019 00:23:11 +0000
""",
f.read(),
)
def test_invalid(self):
with open("debian/changelog", "w") as f:
f.write(
"""\
lalalalala
"""
)
self.assertRaises(ChangelogCreateError, ChangelogEditor().__enter__)
def test_add_entry_to_new_block(self):
with ChangelogEditor.create() as updater:
updater[-1].distributions = "unstable"
updater.auto_version(
Version("2.0-1"),
package="blah",
urgency="low",
maintainer=("Jelmer Vernooij", "jelmer@debian.org"),
timestamp=datetime.utcfromtimestamp(1604934305),
)
updater.add_entry(
["New release"], maintainer=("Jelmer Vernooij", "jelmer@debian.org")
)
with open("debian/changelog") as f:
self.assertEqual(
"""\
blah (2.0-1) UNRELEASED; urgency=low
* New release
-- Jelmer Vernooij <jelmer@debian.org> Mon, 09 Nov 2020 15:05:05 -0000
lintian-brush (0.28) unstable; urgency=medium
* Add fixer for obsolete-runtime-tests-restriction.
-- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Sep 2019 00:23:11 +0000
""",
f.read(),
)
class TextWrapperTests(TestCase):
def setUp(self):
super().setUp()
self.wrapper = TextWrapper()
def test_wrap_closes(self):
self.assertEqual(
[
"And",
" ",
"this",
" ",
"fixes",
" ",
"something.",
" ",
"Closes: #123456",
],
self.wrapper._split("And this fixes something. Closes: #123456"),
)
LONG_LINE = (
"This is a very long line that could have been broken "
"and should have been broken but was not broken."
)
class RewrapChangeTests(TestCase):
def test_too_short(self):
self.assertEqual([], rewrap_change([]))
self.assertEqual(["Foo bar"], rewrap_change(["Foo bar"]))
self.assertEqual(["Foo", "bar"], rewrap_change(["Foo", "bar"]))
self.assertEqual(
[" * Beginning", " next line"],
rewrap_change([" * Beginning", " next line"]),
)
def test_no_initial(self):
self.assertEqual(["x" * 100], rewrap_change(["x" * 100]))
def test_wrap(self):
self.assertEqual(
[
" * This is a very long line that could have been "
"broken and should have been",
" broken but was not broken.",
],
rewrap_change([" * " + LONG_LINE]),
)
self.assertEqual(
"""\
* Build-Depend on libsdl1.2-dev, libsdl-ttf2.0-dev and libsdl-mixer1.2-dev
instead of with the embedded version, add -lSDL_ttf to --with-py-libs in
debian/rules and rebootstrap (Closes: #382202)
""".splitlines(),
rewrap_change(
"""\
* Build-Depend on libsdl1.2-dev, libsdl-ttf2.0-dev and libsdl-mixer1.2-dev \
instead
of with the embedded version, add -lSDL_ttf to --with-py-libs in \
debian/rules
and rebootstrap (Closes: #382202)
""".splitlines()
),
)
def test_no_join(self):
self.assertEqual(
"""\
- Translators know why this sign has been put here:
_Choices: ${FOO}, !Other[ You only have to translate Other, remove the
exclamation mark and this comment between brackets]
Currently text, newt, slang and gtk frontends support this feature.
""".splitlines(),
rewrap_change(
"""\
- Translators know why this sign has been put here:
_Choices: ${FOO}, !Other[ You only have to translate Other, remove \
the exclamation mark and this comment between brackets]
Currently text, newt, slang and gtk frontends support this feature.
""".splitlines()
),
)
class IncVersionTests(TestCase):
def test_native(self):
self.assertEqual(Version("1.1"), increment_version(Version("1.0")))
self.assertEqual(Version("1a1.1"), increment_version(Version("1a1.0")))
self.assertEqual(Version("9.11~2"), increment_version(Version("9.11~1")))
self.assertEqual(Version("9.11~1"), increment_version(Version("9.11~")))
def test_non_native(self):
self.assertEqual(Version("1.1-2"), increment_version(Version("1.1-1")))
self.assertEqual(Version("9.11-1~1"), increment_version(Version("9.11-1~")))
self.assertEqual(Version("9.11-1~2"), increment_version(Version("9.11-1~1")))
class ChangesSectionsTests(TestCase):
def test_simple(self):
self.assertEqual(
[
(
None,
[1, 2, 3, 4],
[
([(1, " * Change 1")]),
([(2, " * Change 2"), (3, " rest")]),
],
)
],
list(
changes_sections(["", " * Change 1", " * Change 2", " rest", ""])
),
)
def test_with_header(self):
self.assertEqual(
[
("Author 1", [1, 2, 3], [([(2, " * Change 1")])]),
("Author 2", [4, 5, 6, 7], [([(5, " * Change 2"), (6, " rest")])]),
],
list(
changes_sections(
[
"",
" [ Author 1 ]",
" * Change 1",
"",
" [ Author 2 ]",
" * Change 2",
" rest",
"",
]
)
),
)
class StripChangelogMessageTests(TestCase):
def test_None(self):
self.assertEqual(strip_changelog_message(None), None) # type: ignore
def test_no_changes(self):
self.assertEqual(strip_changelog_message([]), [])
def test_empty_changes(self):
self.assertEqual(strip_changelog_message([""]), [])
def test_removes_leading_whitespace(self):
self.assertEqual(
strip_changelog_message(["foo", " bar", "\tbaz", " bang"]),
["foo", "bar", "baz", " bang"],
)
def test_removes_star_if_one(self):
self.assertEqual(strip_changelog_message([" * foo"]), ["foo"])
self.assertEqual(strip_changelog_message(["\t* foo"]), ["foo"])
self.assertEqual(strip_changelog_message([" + foo"]), ["foo"])
self.assertEqual(strip_changelog_message([" - foo"]), ["foo"])
self.assertEqual(strip_changelog_message([" * foo"]), ["foo"])
self.assertEqual(
strip_changelog_message([" * foo", " bar"]), ["foo", "bar"]
)
def test_leaves_start_if_multiple(self):
self.assertEqual(
strip_changelog_message([" * foo", " * bar"]), ["* foo", "* bar"]
)
self.assertEqual(
strip_changelog_message([" * foo", " + bar"]), ["* foo", "+ bar"]
)
self.assertEqual(
strip_changelog_message([" * foo", " bar", " * baz"]),
["* foo", "bar", "* baz"],
)
class TestNewUpstreamPackageVersion(TestCase):
def test_simple_debian(self):
self.assertEqual(
Version("1.2-1"), new_upstream_package_version("1.2", "debian")
)
def test_simple_ubuntu(self):
self.assertEqual(
Version("1.2-0ubuntu1"), new_upstream_package_version("1.2", "ubuntu")
)
def test_debian_with_dash(self):
self.assertEqual(
Version("1.2-0ubuntu1-1"),
new_upstream_package_version("1.2-0ubuntu1", "debian"),
)
def test_ubuntu_with_dash(self):
self.assertEqual(
Version("1.2-1-0ubuntu1"), new_upstream_package_version("1.2-1", "ubuntu")
)
def test_ubuntu_with_epoch(self):
self.assertEqual(
Version("3:1.2-1-0ubuntu1"),
new_upstream_package_version("1.2-1", "ubuntu", "3"),
)
class AllShaPrefixedTests(TestCase):
def test_no_prefix(self):
cl = Changelog(
"""\
lintian-brush (0.28) UNRELEASED; urgency=medium
* Add fixer for obsolete-runtime-tests-restriction.
-- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Sep 2019 00:23:11 +0000
"""
)
self.assertFalse(all_sha_prefixed(cl[0]))
def test_empty(self):
cl = Changelog(
"""\
lintian-brush (0.28) UNRELEASED; urgency=medium
-- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Sep 2019 00:23:11 +0000
"""
)
self.assertFalse(all_sha_prefixed(cl[0]))
def test_prefixed(self):
cl = Changelog(
"""\
lintian-brush (0.28) UNRELEASED; urgency=medium
* [217263e] Add fixer for obsolete-runtime-tests-restriction.
-- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Sep 2019 00:23:11 +0000
"""
)
self.assertTrue(all_sha_prefixed(cl[0]))
class BlockEnsureFirstLineTests(TestCase):
def test_ensure_first_line(self):
cl = Changelog(
"""\
lintian-brush (0.28) UNRELEASED; urgency=medium
* [217263e] Add fixer for obsolete-runtime-tests-restriction.
-- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Sep 2019 00:23:11 +0000
"""
)
changeblock_ensure_first_line(
cl[0], "QA Upload.", maintainer=("Jelmer Vernooij", "jelmer@debian.org")
)
self.assertEqual(
"""\
lintian-brush (0.28) UNRELEASED; urgency=medium
* QA Upload.
* [217263e] Add fixer for obsolete-runtime-tests-restriction.
-- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Sep 2019 00:23:11 +0000
""",
str(cl),
)
def test_before_author_block(self):
cl = Changelog(
"""\
lintian-brush (0.28) UNRELEASED; urgency=medium
[ Joe Example ]
* [217263e] Add fixer for obsolete-runtime-tests-restriction.
-- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Sep 2019 00:23:11 +0000
"""
)
changeblock_ensure_first_line(cl[0], "QA Upload.")
self.assertEqual(
"""\
lintian-brush (0.28) UNRELEASED; urgency=medium
* QA Upload.
[ Joe Example ]
* [217263e] Add fixer for obsolete-runtime-tests-restriction.
-- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Sep 2019 00:23:11 +0000
""",
str(cl),
)
def test_exists(self):
cl = Changelog(
"""\
lintian-brush (0.28) UNRELEASED; urgency=medium
* QA Upload.
* [217263e] Add fixer for obsolete-runtime-tests-restriction.
-- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Sep 2019 00:23:11 +0000
"""
)
changeblock_ensure_first_line(cl[0], "QA Upload.")
self.assertEqual(
"""\
lintian-brush (0.28) UNRELEASED; urgency=medium
* QA Upload.
* [217263e] Add fixer for obsolete-runtime-tests-restriction.
-- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Sep 2019 00:23:11 +0000
""",
str(cl),
)
def test_different_author(self):
cl = Changelog(
"""\
lintian-brush (0.28) UNRELEASED; urgency=medium
* [217263e] Add fixer for obsolete-runtime-tests-restriction.
-- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Sep 2019 00:23:11 +0000
"""
)
changeblock_ensure_first_line(
cl[0], "QA Upload.", maintainer=("Joe Example", "joe@example.com")
)
self.assertEqual(
"""\
lintian-brush (0.28) UNRELEASED; urgency=medium
* QA Upload.
[ Jelmer Vernooij ]
* [217263e] Add fixer for obsolete-runtime-tests-restriction.
-- Joe Example <joe@example.com> Mon, 02 Sep 2019 00:23:11 +0000
""",
str(cl),
)
class ReleaseTests(TestCase):
def test_already_updated(self):
cl = Changelog(
"""\
lintian-brush (0.28) unstable; urgency=medium
* [217263e] Add fixer for obsolete-runtime-tests-restriction.
-- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Sep 2019 00:23:11 +0000
"""
)
release(
cl,
timestamp=1604934305,
localtime=False,
maintainer=("Jelmer Vernooij", "jelmer@debian.org"),
)
self.assertEqual(
str(cl),
"""\
lintian-brush (0.28) unstable; urgency=medium
* [217263e] Add fixer for obsolete-runtime-tests-restriction.
-- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Sep 2019 00:23:11 +0000
""",
)
def test_updated(self):
cl = Changelog(
"""\
lintian-brush (0.28) UNRELEASED; urgency=medium
* [217263e] Add fixer for obsolete-runtime-tests-restriction.
-- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Sep 2019 00:23:11 +0000
"""
)
release(
cl,
timestamp=1604934305,
localtime=False,
maintainer=("Jelmer Vernooij", "jelmer@debian.org"),
)
self.assertEqual(
str(cl),
"""\
lintian-brush (0.28) unstable; urgency=medium
* [217263e] Add fixer for obsolete-runtime-tests-restriction.
-- Jelmer Vernooij <jelmer@debian.org> Mon, 09 Nov 2020 15:05:05 -0000
""",
)
def test_different_author(self):
cl = Changelog(
"""\
lintian-brush (0.28) UNRELEASED; urgency=medium
* [217263e] Add fixer for obsolete-runtime-tests-restriction.
-- Joe Example <joe@example.com> Mon, 02 Sep 2019 00:23:11 +0000
"""
)
release(
cl,
timestamp=1604934305,
localtime=False,
maintainer=("Jelmer Vernooij", "jelmer@debian.org"),
)
self.assertEqual(
str(cl),
"""\
lintian-brush (0.28) unstable; urgency=medium
[ Joe Example ]
* [217263e] Add fixer for obsolete-runtime-tests-restriction.
-- Jelmer Vernooij <jelmer@debian.org> Mon, 09 Nov 2020 15:05:05 -0000
""",
)
class FindLastDistributionTests(TestCase):
def create_changelog(self, *distributions):
changelog = Changelog()
changes = [" [ A. Hacker ]", " * Something"]
author = "J. Maintainer <maint@example.com"
for distro in distributions:
changelog.new_block(changes=changes, author=author, distributions=distro)
return changelog
def test_first(self):
changelog = self.create_changelog("unstable")
self.assertEqual("unstable", find_last_distribution(changelog))
def test_second(self):
changelog = self.create_changelog("unstable", "UNRELEASED")
self.assertEqual("UNRELEASED", changelog.distributions)
self.assertEqual("unstable", find_last_distribution(changelog))
def test_empty(self):
changelog = self.create_changelog()
self.assertEqual(None, find_last_distribution(changelog))
def test_only_unreleased(self):
changelog = self.create_changelog("UNRELEASED")
self.assertEqual(None, find_last_distribution(changelog))
class ChangelogInfoTests(TestCase):
def test_find_extra_authors_none(self):
changes = [" * Do foo", " * Do bar"]
authors = find_extra_authors(changes)
self.assertEqual([], authors)
def test_find_extra_authors(self):
changes = [
" * Do foo",
"",
" [ A. Hacker ]",
" * Do bar",
"",
" [ B. Hacker ]",
" [ A. Hacker}",
]
authors = find_extra_authors(changes)
self.assertEqual(["A. Hacker", "B. Hacker"], authors)
self.assertEqual([str] * len(authors), list(map(type, authors)))
def test_find_extra_authors_utf8(self):
changes = [
" * Do foo",
"",
" [ \xe1. Hacker ]",
" * Do bar",
"",
" [ \xe7. Hacker ]",
" [ A. Hacker}",
]
authors = find_extra_authors(changes)
self.assertEqual(["\xe1. Hacker", "\xe7. Hacker"], authors)
self.assertEqual([str] * len(authors), list(map(type, authors)))
def test_find_extra_authors_iso_8859_1(self):
# We try to treat lines as utf-8, but if that fails to decode, we fall
# back to iso-8859-1
changes = [
" * Do foo",
"",
" [ \xe1. Hacker ]",
" * Do bar",
"",
" [ \xe7. Hacker ]",
" [ A. Hacker}",
]
authors = find_extra_authors(changes)
self.assertEqual(["\xe1. Hacker", "\xe7. Hacker"], authors)
self.assertEqual([str] * len(authors), list(map(type, authors)))
def test_find_extra_authors_no_changes(self):
authors = find_extra_authors([])
self.assertEqual([], authors)
def assert_thanks_is(self, changes, expected_thanks):
thanks = find_thanks(changes)
self.assertEqual(expected_thanks, thanks)
self.assertEqual([str] * len(thanks), list(map(type, thanks)))
def test_find_thanks_no_changes(self):
self.assert_thanks_is([], [])
def test_find_thanks_none(self):
changes = [" * Do foo", " * Do bar"]
self.assert_thanks_is(changes, [])
def test_find_thanks(self):
changes = [" * Thanks to A. Hacker"]
self.assert_thanks_is(changes, ["A. Hacker"])
changes = [" * Thanks to James A. Hacker"]
self.assert_thanks_is(changes, ["James A. Hacker"])
changes = [" * Thankyou to B. Hacker"]
self.assert_thanks_is(changes, ["B. Hacker"])
changes = [" * thanks to A. Hacker"]
self.assert_thanks_is(changes, ["A. Hacker"])
changes = [" * thankyou to B. Hacker"]
self.assert_thanks_is(changes, ["B. Hacker"])
changes = [" * Thanks A. Hacker"]
self.assert_thanks_is(changes, ["A. Hacker"])
changes = [" * Thankyou B. Hacker"]
self.assert_thanks_is(changes, ["B. Hacker"])
changes = [" * Thanks to Mark A. Super-Hacker"]
self.assert_thanks_is(changes, ["Mark A. Super-Hacker"])
changes = [" * Thanks to A. Hacker <ahacker@example.com>"]
self.assert_thanks_is(changes, ["A. Hacker <ahacker@example.com>"])
changes = [" * Thanks to Adeodato Sim\xc3\xb3"]
self.assert_thanks_is(changes, ["Adeodato Sim\xc3\xb3"])
changes = [" * Thanks to \xc1deodato Sim\xc3\xb3"]
self.assert_thanks_is(changes, ["\xc1deodato Sim\xc3\xb3"])
class UpstreamMergeChangelogLineTests(TestCase):
def test_release(self):
self.assertEqual("New upstream release.", upstream_merge_changelog_line("1.0"))
def test_bzr_snapshot(self):
self.assertEqual(
"New upstream snapshot.", upstream_merge_changelog_line("1.0+bzr3")
)
def test_git_snapshot(self):
self.assertEqual(
"New upstream snapshot.", upstream_merge_changelog_line("1.0~git20101212")
)
def test_plus(self):
self.assertEqual(
"New upstream release.", upstream_merge_changelog_line("1.0+dfsg1")
)
class TakeUploadershipTests(TestCase):
def test_already_uploader(self):
cl = Changelog(
"""\
lintian-brush (0.28) UNRELEASED; urgency=medium
* Add fixer for obsolete-runtime-tests-restriction.
-- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Sep 2019 00:23:11 +0000
"""
)
take_uploadership(cl[0], ("Jelmer Vernooij", "jelmer@debian.org"))
self.assertEqual(
"""\
lintian-brush (0.28) UNRELEASED; urgency=medium
* Add fixer for obsolete-runtime-tests-restriction.
-- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Sep 2019 00:23:11 +0000
""",
str(cl),
)
def test_other_author(self):
cl = Changelog(
"""\
lintian-brush (0.28) UNRELEASED; urgency=medium
* Add fixer for obsolete-runtime-tests-restriction.
-- Joe Example <joe@example.com> Mon, 02 Sep 2019 00:23:11 +0000
"""
)
take_uploadership(cl[0], ("Jelmer Vernooij", "jelmer@debian.org"))
self.assertEqual(
"""\
lintian-brush (0.28) UNRELEASED; urgency=medium
[ Joe Example ]
* Add fixer for obsolete-runtime-tests-restriction.
-- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Sep 2019 00:23:11 +0000
""",
str(cl),
)
def test_other_author_2(self):
cl = Changelog(
"""\
lintian-brush (0.28) UNRELEASED; urgency=medium
[ Jane Example ]
* Add fixer for obsolete-runtime-tests-restriction.
-- Joe Example <joe@example.com> Mon, 02 Sep 2019 00:23:11 +0000
"""
)
take_uploadership(cl[0], ("Jelmer Vernooij", "jelmer@debian.org"))
self.assertEqual(
"""\
lintian-brush (0.28) UNRELEASED; urgency=medium
[ Jane Example ]
* Add fixer for obsolete-runtime-tests-restriction.
-- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Sep 2019 00:23:11 +0000
""",
str(cl),
)
def test_other_author_empty(self):
cl = Changelog(
"""\
lintian-brush (0.28) UNRELEASED; urgency=medium
-- Joe Example <joe@example.com> Mon, 02 Sep 2019 00:23:11 +0000
"""
)
take_uploadership(cl[0], ("Jelmer Vernooij", "jelmer@debian.org"))
self.assertEqual(
"""\
lintian-brush (0.28) UNRELEASED; urgency=medium
-- Jelmer Vernooij <jelmer@debian.org> Mon, 02 Sep 2019 00:23:11 +0000
""",
str(cl),
)
|