Download:
child 164:3c8449c7f119
parent 162:233f06c7a492
163:876252149291
Anton Shestakov <av6@dwimlabs.net>, Tue, 19 Jul 2016 12:41:27 +0800
tests: test adapters

1 файлов изменено, 57 вставок(+), 0 удалений(-) [+]
tests/test_adapters.py file | annotate | diff | comparison | revisions
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_adapters.py Tue Jul 19 12:41:27 2016 +0800
@@ -0,0 +1,57 @@
+from datetime import datetime
+
+from candolint import adapters
+from candolint.models import Project, Change
+
+
+project = Project(
+ url='https://example.com/alice/test-adapters',
+ domain='example.com',
+ user='alice',
+ name='test-adapters')
+change = Change(
+ rev=42,
+ node='92cfceb',
+ branch='default',
+ date=datetime.now(),
+ author='alice',
+ message='component: do a thing',
+ project=project)
+line = {'filename': 'a/b.py', 'line_number': 101}
+
+
+def test_hosting_adapter():
+ adapter = adapters.HostingAdapter(project)
+ assert adapter.get_commit_url(change) == '#'
+ assert adapter.get_branch_url(change) == '#'
+ assert adapter.get_line_url(change, line) == '#'
+
+
+def test_bitbucket_adapter():
+ adapter = adapters.BitbucketAdapter(project)
+ assert adapter.get_commit_url(change) == \
+ 'https://example.com/alice/test-adapters/commits/92cfceb'
+ assert adapter.get_branch_url(change) == \
+ 'https://example.com/alice/test-adapters/branch/default'
+ assert adapter.get_line_url(change, line) == \
+ 'https://example.com/alice/test-adapters/src/92cfceb/a/b.py#b.py-101'
+
+
+def test_github_adapter():
+ adapter = adapters.GithubAdapter(project)
+ assert adapter.get_commit_url(change) == \
+ 'https://example.com/alice/test-adapters/commits/92cfceb'
+ assert adapter.get_branch_url(change) == \
+ 'https://example.com/alice/test-adapters/tree/default'
+ assert adapter.get_line_url(change, line) == \
+ 'https://example.com/alice/test-adapters/blob/92cfceb/a/b.py#L101'
+
+
+def test_hgweb_adapter():
+ adapter = adapters.HgwebAdapter(project)
+ assert adapter.get_commit_url(change) == \
+ 'https://example.com/alice/test-adapters/rev/92cfceb'
+ assert adapter.get_branch_url(change) == \
+ 'https://example.com/alice/test-adapters/log/default'
+ assert adapter.get_line_url(change, line) == \
+ 'https://example.com/alice/test-adapters/file/92cfceb/a/b.py#l101'