|
| 1 | +from unittest import mock |
| 2 | + |
| 3 | + |
| 4 | +from backport import util |
| 5 | + |
| 6 | + |
| 7 | +def test_title_normalization(): |
| 8 | + title = "abcd" |
| 9 | + body = "1234" |
| 10 | + assert util.normalize_title(title, body) == title |
| 11 | + |
| 12 | + title = "[2.7] bpo-29243: Fix Makefile with respect to --enable-optimizations …" |
| 13 | + body = "…(GH-1478)\r\n\r\nstuff" |
| 14 | + expected = '[2.7] bpo-29243: Fix Makefile with respect to --enable-optimizations (GH-1478)' |
| 15 | + assert util.normalize_title(title, body) == expected |
| 16 | + |
| 17 | + title = "[2.7] bpo-29243: Fix Makefile with respect to --enable-optimizations …" |
| 18 | + body = "…(GH-1478)" |
| 19 | + assert util.normalize_title(title, body) == expected |
| 20 | + |
| 21 | + title = "[2.7] bpo-29243: Fix Makefile with respect to --enable-optimizations (GH-14…" |
| 22 | + body = "…78)" |
| 23 | + assert util.normalize_title(title, body) == expected |
| 24 | + |
| 25 | + |
| 26 | +def test_get_participants_different_creator_and_committer(): |
| 27 | + assert util.get_participants("miss-islington", "bedevere-bot") \ |
| 28 | + == "@miss-islington and @bedevere-bot" |
| 29 | + |
| 30 | + |
| 31 | +def test_get_participants_same_creator_and_committer(): |
| 32 | + assert util.get_participants("miss-islington", |
| 33 | + "miss-islington") == "@miss-islington" |
| 34 | + |
| 35 | + |
| 36 | +@mock.patch('subprocess.check_output') |
| 37 | +def test_is_cpython_repo_contains_first_cpython_commit(subprocess_check_output): |
| 38 | + mock_output = b"""commit 7f777ed95a19224294949e1b4ce56bbffcb1fe9f |
| 39 | +Author: Guido van Rossum <[email protected]> |
| 40 | +Date: Thu Aug 9 14:25:15 1990 +0000 |
| 41 | +
|
| 42 | + Initial revision""" |
| 43 | + subprocess_check_output.return_value = mock_output |
| 44 | + assert util.is_cpython_repo() |
| 45 | + |
| 46 | + |
| 47 | +def test_is_not_cpython_repo(): |
| 48 | + assert util.is_cpython_repo() == False |
0 commit comments