-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Warsame
committed
Sep 27, 2025
1 parent
b5ea680
commit 291c00f
Showing
19 changed files
with
267 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,31 @@ | ||
from acmecli.metrics.bus_factor_metric import BusFactorMetric | ||
|
||
def test_bus_factor_dict_input(): | ||
def test_bus_factor_many_contributors_even(): | ||
metric = BusFactorMetric() | ||
# contributors dict: name -> count | ||
mv = metric.score({"contributors": {"alice": 10, "bob": 5}}) | ||
assert 0.0 <= mv.value <= 1.0 | ||
mv = metric.score({"contributors": {"a": 5, "b": 5, "c": 5, "d": 5, "e": 5, "f": 5}}) | ||
assert mv.value > 0.5 | ||
|
||
def test_bus_factor_one_contributor(): | ||
metric = BusFactorMetric() | ||
mv = metric.score({"contributors": {"alice": 50}}) | ||
assert mv.value < 0.5 | ||
|
||
def test_bus_factor_zero_contrib(): | ||
metric = BusFactorMetric() | ||
mv = metric.score({"contributors": {}}) | ||
assert mv.value == 0.0 | ||
assert mv.value == 0.0 | ||
|
||
def test_bus_factor_org_name(): | ||
metric = BusFactorMetric() | ||
mv = metric.score({"contributors": {"a": 10}, "full_name": "ACMECorp/repo"}) | ||
assert mv.value >= 0.1 | ||
|
||
def test_bus_factor_forks(): | ||
metric = BusFactorMetric() | ||
mv = metric.score({"contributors": {"a": 5, "b": 5}, "forks": 100}) | ||
assert mv.value > 0.1 | ||
|
||
def test_bus_factor_latency(): | ||
metric = BusFactorMetric() | ||
mv = metric.score({"contributors": {"a": 1}}) | ||
assert mv.latency_ms >= 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from acmecli.cache import SimpleCache | ||
|
||
def test_cache_set_get(): | ||
cache = SimpleCache() | ||
cache.set("foo", "bar") | ||
assert cache.get("foo") == "bar" | ||
|
||
def test_cache_miss(): | ||
cache = SimpleCache() | ||
assert cache.get("missing") is None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import subprocess | ||
|
||
def test_run_test_success(): | ||
result = subprocess.run(["python", "run", "test"], capture_output=True, text=True) | ||
assert "test cases passed" in result.stdout | ||
|
||
def test_run_score_failure(): | ||
result = subprocess.run(["python", "run", "score", "NON_EXISTENT.txt"], capture_output=True, text=True) | ||
assert result.returncode != 0 | ||
assert "Usage" in result.stdout or "error" in result.stderr.lower() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from acmecli.github_handler import fetch_github_metadata | ||
|
||
def test_fetch_github_metadata_valid(): | ||
# Use a public repo; adjust as needed for your logic | ||
url = "https://github.com/AF-Warsame/test" | ||
meta = fetch_github_metadata(url) | ||
assert isinstance(meta, dict) or meta is not None | ||
|
||
def test_fetch_github_metadata_invalid(): | ||
url = "https://github.com/invalid/repo" | ||
meta = fetch_github_metadata(url) | ||
assert meta is None or meta == {} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from acmecli.metrics.hf_downloads_metric import HFDownloadsMetric | ||
|
||
def test_downloads_zero(): | ||
metric = HFDownloadsMetric() | ||
mv = metric.score({"downloads": 0}) | ||
assert mv.value == 0.0 | ||
|
||
def test_downloads_high(): | ||
metric = HFDownloadsMetric() | ||
mv = metric.score({"downloads": 20000}) | ||
assert mv.value == 1.0 | ||
|
||
def test_downloads_medium(): | ||
metric = HFDownloadsMetric() | ||
mv = metric.score({"downloads": 5000}) | ||
assert 0.0 < mv.value < 1.0 | ||
|
||
def test_downloads_none(): | ||
metric = HFDownloadsMetric() | ||
mv = metric.score({}) | ||
assert mv.value == 0.0 | ||
|
||
def test_downloads_latency(): | ||
metric = HFDownloadsMetric() | ||
mv = metric.score({"downloads": 100}) | ||
assert mv.latency_ms >= 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from acmecli.hf_handler import fetch_hf_metadata | ||
|
||
def test_fetch_hf_metadata_valid(): | ||
url = "https://huggingface.co/bert-base-uncased" | ||
meta = fetch_hf_metadata(url) | ||
assert isinstance(meta, dict) or meta is not None | ||
|
||
def test_fetch_hf_metadata_invalid(): | ||
url = "https://huggingface.co/invalid" | ||
meta = fetch_hf_metadata(url) | ||
assert meta is None or meta == {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from acmecli.reporter import Reporter | ||
|
||
def test_reporter_format(): | ||
reporter = Reporter() | ||
data = {"foo": "bar"} | ||
out = reporter.format(data) | ||
assert '"foo": "bar"' in out or "'foo': 'bar'" in out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from acmecli.scoring import compute_netscore | ||
|
||
def test_compute_netscore_typical(): | ||
scores = [0.9, 0.8, 0.7] | ||
weights = [0.5, 0.3, 0.2] | ||
net = compute_netscore(scores, weights) | ||
assert 0.0 <= net <= 1.0 | ||
|
||
def test_compute_netscore_zero(): | ||
scores = [0, 0, 0] | ||
weights = [0.5, 0.3, 0.2] | ||
net = compute_netscore(scores, weights) | ||
assert net == 0.0 |
Oops, something went wrong.