Klaus Demo ~jonashaag/klaus / 0f1b01b
Add test for #130 Jonas Haag 6 years ago
5 changed file(s) with 43 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
0 #!/bin/sh
1 ( rm -rf tests/repos/test_repo
2 mkdir -p tests/repos/test_repo
3 cd tests/repos/test_repo
4 git init
5 echo Hello World > README
6 git add README
7 git commit -a -m "First commit"
0 #!/bin/sh -e
1 ( cd tests/repos/
2 rm -rf build
3 for maker in scripts/*; do
4 builddir="build/`basename $maker`"
5 mkdir -p $builddir
6 ( cd $builddir; ../../$maker )
7 done
88 )
99
1010 py.test tests/ -v
0 #!/bin/bash
1 git init
2
3 echo 1 > test
4 echo -n 2 >> test
5 git add test
6 git commit -m old
7
8 echo 1 > test
9 echo 2 >> test
10 git add test
11 git commit -m new
0 #!/bin/bash -e
1 git init
2
3 echo Hello World > README
4 git add README
5 git commit -m "First commit"
1111 tarball = tarfile.TarFile.gzopen("test.tar.gz", fileobj=response_body)
1212 with contextlib.closing(tarball):
1313 assert tarball.extractfile('README').read() == b'Hello World\n'
14
15
16 def test_no_newline_at_end_of_file():
17 with serve():
18 response = requests.get(TEST_REPO_NO_NEWLINE_URL + "commit/HEAD/").content
19 assert "No newline at end of file" in response
20 assert "2<del></del>" in response
21 assert "2<ins></ins>" in response
55
66 import klaus
77
8
9 TEST_REPO = os.path.abspath("tests/repos/test_repo")
10 TEST_REPO_URL = "test_repo/"
118 TEST_SITE_NAME = "Some site"
129 HTDIGEST_FILE = "tests/credentials.htdigest"
10
11 TEST_REPO = os.path.abspath("tests/repos/build/test_repo")
12 TEST_REPO_URL = "test_repo/"
1313 UNAUTH_TEST_SERVER = "http://invalid:password@localhost:9876/"
1414 UNAUTH_TEST_REPO_URL = UNAUTH_TEST_SERVER + TEST_REPO_URL
1515 AUTH_TEST_SERVER = "http://testuser:testpassword@localhost:9876/"
1616 AUTH_TEST_REPO_URL = AUTH_TEST_SERVER + TEST_REPO_URL
1717
18 TEST_REPO_NO_NEWLINE = os.path.abspath("tests/repos/build/no-newline-at-end-of-file")
19 TEST_REPO_NO_NEWLINE_URL = UNAUTH_TEST_SERVER + "no-newline-at-end-of-file/"
20
21 ALL_TEST_REPOS = [TEST_REPO, TEST_REPO_NO_NEWLINE]
22
1823
1924 @contextlib.contextmanager
2025 def serve(*args, **kwargs):
21 app = klaus.make_app([TEST_REPO], TEST_SITE_NAME, *args, **kwargs)
26 app = klaus.make_app(ALL_TEST_REPOS, TEST_SITE_NAME, *args, **kwargs)
2227 server = werkzeug.serving.make_server("localhost", 9876, app)
2328 thread = threading.Thread(target=server.serve_forever)
2429 thread.start()