| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,6 @@ | |||
| 1 | - import time | ||
| 2 | 1 | import tempfile | |
| 2 | + import time | ||
| 3 | + import uuid | ||
| 3 | 4 | from pathlib import Path | |
| 4 | 5 | from random import randint | |
| 5 | 6 | from subprocess import check_output | |
@@ -13,16 +14,6 @@ | |||
| 13 | 14 | TEST_DIR = Path(__file__).resolve().parent | |
| 14 | 15 | ||
| 15 | 16 | ||
| 16 | - def random_id(): | ||
| 17 | - """ | ||
| 18 | - Helper to ensure new resource creation does not clash with | ||
| 19 | - existing resources, for example when a previous test deleted a | ||
| 20 | - resource but GitLab is still deleting it asynchronously in the | ||
| 21 | - background. TODO: Expand to make it 100% safe. | ||
| 22 | - """ | ||
| 23 | - return randint(9, 9999) | ||
| 24 | - | ||
| 25 | - | ||
| 26 | 17 | def reset_gitlab(gl): | |
| 27 | 18 | # previously tools/reset_gitlab.py | |
| 28 | 19 | for project in gl.projects.list(): | |
@@ -125,7 +116,7 @@ def gl(gitlab_config): | |||
| 125 | 116 | @pytest.fixture(scope="module") | |
| 126 | 117 | def group(gl): | |
| 127 | 118 | """Group fixture for group API resource tests.""" | |
| 128 | - _id = random_id() | ||
| 119 | + _id = uuid.uuid4().hex | ||
| 129 | 120 | data = { | |
| 130 | 121 | "name": f"test-group-{_id}", | |
| 131 | 122 | "path": f"group-{_id}", | |
@@ -143,7 +134,7 @@ def group(gl): | |||
| 143 | 134 | @pytest.fixture(scope="module") | |
| 144 | 135 | def project(gl): | |
| 145 | 136 | """Project fixture for project API resource tests.""" | |
| 146 | - _id = random_id() | ||
| 137 | + _id = uuid.uuid4().hex | ||
| 147 | 138 | name = f"test-project-{_id}" | |
| 148 | 139 | ||
| 149 | 140 | project = gl.projects.create(name=name) | |
@@ -159,7 +150,7 @@ def project(gl): | |||
| 159 | 150 | @pytest.fixture(scope="module") | |
| 160 | 151 | def user(gl): | |
| 161 | 152 | """User fixture for user API resource tests.""" | |
| 162 | - _id = random_id() | ||
| 153 | + _id = uuid.uuid4().hex | ||
| 163 | 154 | email = f"user{_id}@email.com" | |
| 164 | 155 | username = f"user{_id}" | |
| 165 | 156 | name = f"User {_id}" | |
@@ -178,7 +169,7 @@ def user(gl): | |||
| 178 | 169 | @pytest.fixture(scope="module") | |
| 179 | 170 | def issue(project): | |
| 180 | 171 | """Issue fixture for issue API resource tests.""" | |
| 181 | - _id = random_id() | ||
| 172 | + _id = uuid.uuid4().hex | ||
| 182 | 173 | data = {"title": f"Issue {_id}", "description": f"Issue {_id} description"} | |
| 183 | 174 | ||
| 184 | 175 | return project.issues.create(data) | |
@@ -187,7 +178,7 @@ def issue(project): | |||
| 187 | 178 | @pytest.fixture(scope="module") | |
| 188 | 179 | def label(project): | |
| 189 | 180 | """Label fixture for project label API resource tests.""" | |
| 190 | - _id = random_id() | ||
| 181 | + _id = uuid.uuid4().hex | ||
| 191 | 182 | data = { | |
| 192 | 183 | "name": f"prjlabel{_id}", | |
| 193 | 184 | "description": f"prjlabel1 {_id} description", | |
@@ -200,7 +191,7 @@ def label(project): | |||
| 200 | 191 | @pytest.fixture(scope="module") | |
| 201 | 192 | def group_label(group): | |
| 202 | 193 | """Label fixture for group label API resource tests.""" | |
| 203 | - _id = random_id() | ||
| 194 | + _id = uuid.uuid4().hex | ||
| 204 | 195 | data = { | |
| 205 | 196 | "name": f"grplabel{_id}", | |
| 206 | 197 | "description": f"grplabel1 {_id} description", | |
@@ -213,7 +204,7 @@ def group_label(group): | |||
| 213 | 204 | @pytest.fixture(scope="module") | |
| 214 | 205 | def variable(project): | |
| 215 | 206 | """Variable fixture for project variable API resource tests.""" | |
| 216 | - _id = random_id() | ||
| 207 | + _id = uuid.uuid4().hex | ||
| 217 | 208 | data = {"key": f"var{_id}", "value": f"Variable {_id}"} | |
| 218 | 209 | ||
| 219 | 210 | return project.variables.create(data) | |
@@ -222,7 +213,7 @@ def variable(project): | |||
| 222 | 213 | @pytest.fixture(scope="module") | |
| 223 | 214 | def deploy_token(project): | |
| 224 | 215 | """Deploy token fixture for project deploy token API resource tests.""" | |
| 225 | - _id = random_id() | ||
| 216 | + _id = uuid.uuid4().hex | ||
| 226 | 217 | data = { | |
| 227 | 218 | "name": f"token-{_id}", | |
| 228 | 219 | "username": "root", | |
@@ -236,7 +227,7 @@ def deploy_token(project): | |||
| 236 | 227 | @pytest.fixture(scope="module") | |
| 237 | 228 | def group_deploy_token(group): | |
| 238 | 229 | """Deploy token fixture for group deploy token API resource tests.""" | |
| 239 | - _id = random_id() | ||
| 230 | + _id = uuid.uuid4().hex | ||
| 240 | 231 | data = { | |
| 241 | 232 | "name": f"group-token-{_id}", | |
| 242 | 233 | "username": "root", | |
| Back | FazBrowse Home | New Git URL |
0 commit comments