diff options
author | Jonas Haag <jonas@lophus.org> | 2015-07-17 17:09:37 +0200 |
---|---|---|
committer | Jonas Haag <jonas@lophus.org> | 2015-07-17 19:47:44 +0200 |
commit | 0f1b01b7aeed53b49e92667651df9e3e4bfc4376 (patch) | |
tree | 83da730c8384c361bc978a3cdf6f92196bfda77d /tests | |
parent | 2a297f46fa49a005894453f103ea681cd095c460 (diff) |
Add test for #130
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/repos/scripts/no-newline-at-end-of-file | 12 | ||||
-rwxr-xr-x | tests/repos/scripts/test_repo | 6 | ||||
-rw-r--r-- | tests/test_views.py | 8 | ||||
-rw-r--r-- | tests/utils.py | 13 |
4 files changed, 35 insertions, 4 deletions
diff --git a/tests/repos/scripts/no-newline-at-end-of-file b/tests/repos/scripts/no-newline-at-end-of-file new file mode 100755 index 0000000..e88f048 --- /dev/null +++ b/tests/repos/scripts/no-newline-at-end-of-file @@ -0,0 +1,12 @@ +#!/bin/bash +git init + +echo 1 > test +echo -n 2 >> test +git add test +git commit -m old + +echo 1 > test +echo 2 >> test +git add test +git commit -m new diff --git a/tests/repos/scripts/test_repo b/tests/repos/scripts/test_repo new file mode 100755 index 0000000..04d59ae --- /dev/null +++ b/tests/repos/scripts/test_repo @@ -0,0 +1,6 @@ +#!/bin/bash -e +git init + +echo Hello World > README +git add README +git commit -m "First commit" diff --git a/tests/test_views.py b/tests/test_views.py index 3b4a821..385940c 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -12,3 +12,11 @@ def test_download(): tarball = tarfile.TarFile.gzopen("test.tar.gz", fileobj=response_body) with contextlib.closing(tarball): assert tarball.extractfile('README').read() == b'Hello World\n' + + +def test_no_newline_at_end_of_file(): + with serve(): + response = requests.get(TEST_REPO_NO_NEWLINE_URL + "commit/HEAD/").content + assert "No newline at end of file" in response + assert "2<del></del>" in response + assert "2<ins></ins>" in response diff --git a/tests/utils.py b/tests/utils.py index a0ae32b..5475d2b 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -6,20 +6,25 @@ import threading import klaus - -TEST_REPO = os.path.abspath("tests/repos/test_repo") -TEST_REPO_URL = "test_repo/" TEST_SITE_NAME = "Some site" HTDIGEST_FILE = "tests/credentials.htdigest" + +TEST_REPO = os.path.abspath("tests/repos/build/test_repo") +TEST_REPO_URL = "test_repo/" UNAUTH_TEST_SERVER = "http://invalid:password@localhost:9876/" UNAUTH_TEST_REPO_URL = UNAUTH_TEST_SERVER + TEST_REPO_URL AUTH_TEST_SERVER = "http://testuser:testpassword@localhost:9876/" AUTH_TEST_REPO_URL = AUTH_TEST_SERVER + TEST_REPO_URL +TEST_REPO_NO_NEWLINE = os.path.abspath("tests/repos/build/no-newline-at-end-of-file") +TEST_REPO_NO_NEWLINE_URL = UNAUTH_TEST_SERVER + "no-newline-at-end-of-file/" + +ALL_TEST_REPOS = [TEST_REPO, TEST_REPO_NO_NEWLINE] + @contextlib.contextmanager def serve(*args, **kwargs): - app = klaus.make_app([TEST_REPO], TEST_SITE_NAME, *args, **kwargs) + app = klaus.make_app(ALL_TEST_REPOS, TEST_SITE_NAME, *args, **kwargs) server = werkzeug.serving.make_server("localhost", 9876, app) thread = threading.Thread(target=server.serve_forever) thread.start() |