Add test for #130
Jonas Haag
6 years ago
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
|
8 | 8 |
)
|
9 | 9 |
|
10 | 10 |
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"
|
11 | 11 |
tarball = tarfile.TarFile.gzopen("test.tar.gz", fileobj=response_body)
|
12 | 12 |
with contextlib.closing(tarball):
|
13 | 13 |
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
|
5 | 5 |
|
6 | 6 |
import klaus
|
7 | 7 |
|
8 | |
|
9 | |
TEST_REPO = os.path.abspath("tests/repos/test_repo")
|
10 | |
TEST_REPO_URL = "test_repo/"
|
11 | 8 |
TEST_SITE_NAME = "Some site"
|
12 | 9 |
HTDIGEST_FILE = "tests/credentials.htdigest"
|
|
10 |
|
|
11 |
TEST_REPO = os.path.abspath("tests/repos/build/test_repo")
|
|
12 |
TEST_REPO_URL = "test_repo/"
|
13 | 13 |
UNAUTH_TEST_SERVER = "http://invalid:password@localhost:9876/"
|
14 | 14 |
UNAUTH_TEST_REPO_URL = UNAUTH_TEST_SERVER + TEST_REPO_URL
|
15 | 15 |
AUTH_TEST_SERVER = "http://testuser:testpassword@localhost:9876/"
|
16 | 16 |
AUTH_TEST_REPO_URL = AUTH_TEST_SERVER + TEST_REPO_URL
|
17 | 17 |
|
|
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 |
|
18 | 23 |
|
19 | 24 |
@contextlib.contextmanager
|
20 | 25 |
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)
|
22 | 27 |
server = werkzeug.serving.make_server("localhost", 9876, app)
|
23 | 28 |
thread = threading.Thread(target=server.serve_forever)
|
24 | 29 |
thread.start()
|