Skip to content

Initial implementation of GitLab statistics #15931

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Sep 19, 2024
Merged
46 changes: 46 additions & 0 deletions tests/unit/packaging/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,52 @@ def test_verified_github_open_issueo_info_url_is_none_without_verified_url(
release = DBReleaseFactory.create()
assert release.verified_github_open_issue_info_url is None

@pytest.mark.parametrize(
("url", "expected"),
[
(
"https://gitlab.com/someuser/someproject",
"someuser/someproject",
),
(
"https://gitlab.com/someuser/someproject/",
"someuser/someproject",
),
(
"https://gitlab.com/someuser/someproject/-/tree/stable-9",
"someuser/someproject",
),
(
"https://www.gitlab.com/someuser/someproject",
"someuser/someproject",
),
("https://gitlab.com/someuser/", None),
("https://google.com/pypi/warehouse/tree/main", None),
("https://google.com", None),
("incorrect url", None),
(
"https://gitlab.com/someuser/someproject.git",
"someuser/someproject",
),
(
"https://www.gitlab.com/someuser/someproject.git/",
"someuser/someproject",
),
("[email protected]:definex/dsgnutils.git", None),
],
)
def test_verified_gitlab_repository(self, db_session, url, expected):
release = DBReleaseFactory.create()
release.project_urls["Homepage"] = {"url": url, "verified": True}
assert release.verified_gitlab_repository == expected

def test_verified_gitlab_repository_is_none_without_verified_url(
self,
db_session,
):
release = DBReleaseFactory.create()
assert release.verified_gitlab_repository is None

def test_trusted_published_none(self, db_session):
release = DBReleaseFactory.create()

Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_csp.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ def test_includeme():
"'self'",
"https://github.com/api/repos/",
"https://github.com/api/search/issues",
"https://gitlab.com/api/",
"https://*.google-analytics.com",
"https://*.analytics.google.com",
"https://*.googletagmanager.com",
Expand Down
1 change: 1 addition & 0 deletions warehouse/csp.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def _connect_src_settings(config) -> list:
SELF,
"https://github.com/api/repos/",
"https://github.com/api/search/issues",
"https://gitlab.com/api/",
"https://*.google-analytics.com",
"https://*.analytics.google.com",
"https://*.googletagmanager.com",
Expand Down
Loading