|
1 | 1 | import base64 |
| 2 | +import tarfile |
2 | 3 | import time |
| 4 | +import zipfile |
| 5 | +from io import BytesIO |
3 | 6 |
|
4 | 7 | import pytest |
5 | 8 |
|
@@ -48,14 +51,34 @@ def test_repository_tree(project): |
48 | 51 | blob = project.repository_raw_blob(blob_id) |
49 | 52 | assert blob.decode() == "Initial content" |
50 | 53 |
|
| 54 | + snapshot = project.snapshot() |
| 55 | + assert isinstance(snapshot, bytes) |
| 56 | + |
| 57 | + |
| 58 | +def test_repository_archive(project): |
51 | 59 | archive = project.repository_archive() |
52 | 60 | assert isinstance(archive, bytes) |
53 | 61 |
|
54 | 62 | archive2 = project.repository_archive("master") |
55 | 63 | assert archive == archive2 |
56 | 64 |
|
57 | | - snapshot = project.snapshot() |
58 | | - assert isinstance(snapshot, bytes) |
| 65 | + |
| 66 | +@pytest.mark.parametrize( |
| 67 | + "format,assertion", |
| 68 | + [ |
| 69 | + ("tbz", tarfile.is_tarfile), |
| 70 | + ("tbz2", tarfile.is_tarfile), |
| 71 | + ("tb2", tarfile.is_tarfile), |
| 72 | + ("bz2", tarfile.is_tarfile), |
| 73 | + ("tar", tarfile.is_tarfile), |
| 74 | + ("tar.gz", tarfile.is_tarfile), |
| 75 | + ("tar.bz2", tarfile.is_tarfile), |
| 76 | + ("zip", zipfile.is_zipfile), |
| 77 | + ], |
| 78 | +) |
| 79 | +def test_repository_archive_formats(project, format, assertion): |
| 80 | + archive = project.repository_archive(format=format) |
| 81 | + assert assertion(BytesIO(archive)) |
59 | 82 |
|
60 | 83 |
|
61 | 84 | def test_create_commit(project): |
|
0 commit comments