Skip to content

Commit b16a1be

Browse files
committed
Initial implementation of GitLab statistics
Issue: #12789 Signed-off-by: Yuri Konotopov <[email protected]>
1 parent 5292182 commit b16a1be

File tree

9 files changed

+325
-69
lines changed

9 files changed

+325
-69
lines changed

tests/unit/packaging/test_models.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,52 @@ def test_verified_github_open_issueo_info_url_is_none_without_verified_url(
961961
release = DBReleaseFactory.create()
962962
assert release.verified_github_open_issue_info_url is None
963963

964+
@pytest.mark.parametrize(
965+
("url", "expected"),
966+
[
967+
(
968+
"https://gitlab.com/someuser/someproject",
969+
"someuser/someproject",
970+
),
971+
(
972+
"https://gitlab.com/someuser/someproject/",
973+
"someuser/someproject",
974+
),
975+
(
976+
"https://gitlab.com/someuser/someproject/-/tree/stable-9",
977+
"someuser/someproject",
978+
),
979+
(
980+
"https://www.gitlab.com/someuser/someproject",
981+
"someuser/someproject",
982+
),
983+
("https://gitlab.com/someuser/", None),
984+
("https://google.com/pypi/warehouse/tree/main", None),
985+
("https://google.com", None),
986+
("incorrect url", None),
987+
(
988+
"https://gitlab.com/someuser/someproject.git",
989+
"someuser/someproject",
990+
),
991+
(
992+
"https://www.gitlab.com/someuser/someproject.git/",
993+
"someuser/someproject",
994+
),
995+
("[email protected]:definex/dsgnutils.git", None),
996+
],
997+
)
998+
def test_verified_gitlab_repository(self, db_session, url, expected):
999+
release = DBReleaseFactory.create()
1000+
release.project_urls["Homepage"] = {"url": url, "verified": True}
1001+
assert release.verified_gitlab_repository == expected
1002+
1003+
def test_verified_gitlab_repository_is_none_without_verified_url(
1004+
self,
1005+
db_session,
1006+
):
1007+
release = DBReleaseFactory.create()
1008+
assert release.verified_gitlab_repository is None
1009+
9641010
def test_trusted_published_none(self, db_session):
9651011
release = DBReleaseFactory.create()
9661012

tests/unit/test_csp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ def test_includeme():
250250
"'self'",
251251
"https://github.com/api/repos/",
252252
"https://github.com/api/search/issues",
253+
"https://gitlab.com",
253254
"https://*.google-analytics.com",
254255
"https://*.analytics.google.com",
255256
"https://*.googletagmanager.com",

warehouse/csp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def _connect_src_settings(config) -> list:
9797
SELF,
9898
"https://github.com/api/repos/",
9999
"https://github.com/api/search/issues",
100+
"https://gitlab.com",
100101
"https://*.google-analytics.com",
101102
"https://*.analytics.google.com",
102103
"https://*.googletagmanager.com",

0 commit comments

Comments
 (0)