MCPcopy Index your code
hub / github.com/SourceCode-AI/aura / test_package_score

Function test_package_score

tests/test_package.py:67–103  ·  view source on GitHub ↗
(mock1, mock_github, mock_pypi_rest_api, mock_pypi_stats)

Source from the content-addressed store, hash-verified

65@responses.activate
66@patch("aura.package.get_reverse_dependencies", return_value=REQUESTS_DEPS)
67def test_package_score(mock1, mock_github, mock_pypi_rest_api, mock_pypi_stats):
68 mock_github(responses)
69 mock_pypi_rest_api(responses)
70
71 pkg = package.PackageScore("requests")
72 pkg.now = pytz.UTC.localize(datetime.datetime.fromisoformat("2020-04-18T14:21:43.572676"))
73
74 assert pkg.package_name == "requests"
75 assert pkg.pkg.info["info"]["name"] == "requests"
76 assert pkg.github is not None
77 assert pkg.github.owner == "psf"
78 assert pkg.github.name == "requests"
79
80 matrix = pkg.get_score_matrix()
81
82 scores = {x["slug"]: x["normalized"] for x in matrix["entries"]}
83
84 assert scores["github_contributors"] == 2
85 assert scores["github_forks"] == 4
86 assert scores["github_stars"] == 5
87 assert scores["has_documentation"] == 1
88 assert scores["has_homepage"] == 1
89 assert scores["has_sdist"] == 1
90 assert scores["has_source_repository"] == 1
91 assert scores["has_wheel"] == 1
92 assert scores["new_on_github"] == 1
93 assert scores["recent_commit"] == 1
94 assert scores["multiple_releases"] == 3
95 assert matrix["total"] >= 19
96
97 # Make the package seem outdated
98 pkg.now = pytz.UTC.localize(
99 datetime.datetime.utcnow() + datetime.timedelta(365)
100 )
101 matrix = pkg.get_score_matrix()
102 scores = {x["slug"]: x["normalized"] for x in matrix["entries"]}
103 assert scores["recent_commit"] == 0
104
105
106@responses.activate

Callers

nothing calls this directly

Calls 3

get_score_matrixMethod · 0.95
mock_githubFunction · 0.85
mock_pypi_rest_apiFunction · 0.85

Tested by

no test coverage detected