|
| 1 | +from nose.tools import eq_ |
| 2 | + |
| 3 | +from moban_jinja2_github.issues import github_expand |
| 4 | + |
| 5 | + |
| 6 | +def test_github_expand(): |
| 7 | + inputs = [ |
| 8 | + ["fix `#12`", "project", "organisation"], |
| 9 | + ["fix `#13` too", "project", "organisation"], |
| 10 | + ["`#14` works", "project", "organisation"], |
| 11 | + ["`PR#15` works", "project", "organisation"], |
| 12 | + ["`repo#PR#15` works", "project", "organisation"], |
| 13 | + ["`cool#16` works", "project", "organisation"], |
| 14 | + ["`microsoft#cool#PR#17` works", "project", "organisation"], |
| 15 | + ["this `cool##18`", "project", "organisation"], |
| 16 | + ["`goog#cool#19` works", "project", "organisation"], |
| 17 | + ["`twitter#cool#weird#19` works", "project", "organisation"], |
| 18 | + ["wont work", "project", "organisation"], |
| 19 | + ["`wont work either`", "prj", "org"], |
| 20 | + ["some `weird` `case` `#10` is", "prj", "org"], |
| 21 | + ] |
| 22 | + expectations = [ |
| 23 | + "fix `#12 <https://github.com/organisation/project/issues/12>`_", |
| 24 | + "fix `#13 <https://github.com/organisation/project/issues/13>`_ too", |
| 25 | + "`#14 <https://github.com/organisation/project/issues/14>`_ works", |
| 26 | + "`#15 <https://github.com/organisation/project/pull/15>`_ works", |
| 27 | + "`repo#15 <https://github.com/organisation/repo/pull/15>`_ works", |
| 28 | + "`cool#16 <https://github.com/organisation/cool/issues/16>`_ works", |
| 29 | + "`cool#17 <https://github.com/microsoft/cool/pull/17>`_ works", |
| 30 | + "this `cool#18 <https://github.com/organisation/cool/issues/18>`_", |
| 31 | + "`goog#19 <https://github.com/organisation/goog/issues/19>`_ works", |
| 32 | + "`cool#19 <https://github.com/twitter/cool/issues/19>`_ works", |
| 33 | + "wont work", |
| 34 | + "`wont work either`", |
| 35 | + "some `weird` `case` `#10 <https://github.com/org/prj/issues/10>`_ is", |
| 36 | + ] |
| 37 | + for input_line, expect in zip(inputs, expectations): |
| 38 | + actual = github_expand(*input_line) |
| 39 | + eq_(actual, expect) |
0 commit comments