|
2 | 2 | import stat
|
3 | 3 | import subprocess
|
4 | 4 | import tempfile
|
| 5 | +import time |
5 | 6 |
|
6 | 7 | import requests
|
| 8 | +from grab import Grab |
7 | 9 |
|
8 | 10 | import pytest
|
9 |
| -from grab import Grab |
10 | 11 |
|
11 | 12 |
|
12 | 13 | @pytest.fixture(autouse=True)
|
@@ -155,13 +156,33 @@ def make_project(self, **kwargs):
|
155 | 156 | data = response.json()
|
156 | 157 | return data["id"], self.git_url + data["path_with_namespace"] + ".git"
|
157 | 158 |
|
| 159 | + def delete_project(self, project_id): |
| 160 | + """Make a project and return (id, ssh url).""" |
| 161 | + project_url = self.http_url + "api/v4/projects/%s" % project_id |
| 162 | + response = self.session.delete(project_url) |
| 163 | + # the delete is asynchronus so wait for it |
| 164 | + response.raise_for_status() |
| 165 | + for _ in range(5): |
| 166 | + time.sleep(1) |
| 167 | + response = self.session.get(project_url) |
| 168 | + if response.status_code == 404: |
| 169 | + return |
| 170 | + raise Exception("Project not deleted in time.") |
| 171 | + |
158 | 172 | yield Info()
|
159 | 173 |
|
160 | 174 |
|
161 |
| -def test_smoke(gitlab): |
| 175 | +def test_mirror(gitlab): |
162 | 176 | """Check that a sync runs first time."""
|
163 | 177 | gitlab_sync = gitlab.make_runner()
|
164 |
| - gitlab.make_project(name="lulz") |
| 178 | + project_id, _ = gitlab.make_project(name="lulz") |
| 179 | + gitlab_sync("local-update", check=True) |
| 180 | + project_absolute_path = gitlab.sync_root / gitlab.username / "lulz" |
| 181 | + assert project_absolute_path.is_dir() |
| 182 | + |
165 | 183 | gitlab_sync("local-update", check=True)
|
166 |
| - assert (gitlab.sync_root / gitlab.username / "lulz").is_dir() |
| 184 | + assert project_absolute_path.is_dir() |
| 185 | + |
| 186 | + gitlab.delete_project(project_id) |
167 | 187 | gitlab_sync("local-update", check=True)
|
| 188 | + assert not project_absolute_path.is_dir() |
0 commit comments