Skip to content

Commit f6d6dee

Browse files
authored
Merge pull request #250 from sommersoft/fix_hacktober
Fix Hacktoberfest Labelling & CircuitPython.org Contributing JSON Source
2 parents b81efd7 + f568ed2 commit f6d6dee

File tree

3 files changed

+47
-8
lines changed

3 files changed

+47
-8
lines changed

adabot/lib/assign_hacktober_label.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ def assign_hacktoberfest(repo, issues=None, remove_labels=False, dry_run=False):
154154
update_issue = True
155155

156156
if update_issue:
157+
label_names.append("Hacktober")
157158
params = {"labels": label_names}
158159
if not dry_run:
159160
result = github.patch(

adabot/update_cp_org_libraries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ def main(
171171
logger.info("Run Date: %s", run_time.strftime("%d %B %Y, %I:%M%p"))
172172

173173
if output_file:
174+
logger.info(" - Report output will be saved to: %s", output_file)
174175
file_handler = logging.FileHandler(output_file)
175176
logger.addHandler(file_handler)
176-
logger.info(" - Report output will be saved to: %s", output_file)
177177

178178
if cache_http:
179179
cpy_vals.github.setup_cache(cache_ttl)

tests/integration/test_update_cp_org_libraries.py

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
"""Integration tests for 'adabot/update_cp_org_libraries.py'"""
2424

25+
import json
26+
2527
import pytest # pylint: disable=unused-import
2628

2729
from adabot.lib import common_funcs
@@ -31,9 +33,45 @@
3133
# pylint: disable=unused-argument
3234
def mock_list_repos(*args, **kwargs):
3335
"""Function to monkeypatch `common_funcs.list_repos()` for a shorter set of repos."""
34-
return [
35-
github_requests.get("/repos/adafruit/Adafruit_CircuitPython_TestRepo").json()
36-
]
36+
repos = []
37+
result = github_requests.get(
38+
"/search/repositories",
39+
params={
40+
"q": "Adafruit_CircuitPython user:adafruit archived:false fork:true",
41+
"per_page": 100,
42+
"sort": "updated",
43+
"order": "asc",
44+
},
45+
)
46+
47+
if result.ok:
48+
repos.extend(
49+
repo
50+
for repo in result.json()["items"]
51+
if (
52+
repo["owner"]["login"] == "adafruit"
53+
and (
54+
repo["name"].startswith("Adafruit_CircuitPython")
55+
or repo["name"] == "circuitpython"
56+
)
57+
)
58+
)
59+
60+
repo_names = [repo["name"] for repo in repos]
61+
62+
if kwargs.get("include_repos", False):
63+
for repo in kwargs["include_repos"]:
64+
if repo not in repo_names:
65+
add_repo = github_requests.get("/repos/adafruit/" + repo)
66+
if add_repo.ok:
67+
repos.append(add_repo.json())
68+
else:
69+
print("list_repos(): Failed to retrieve '{}'".format(repo))
70+
71+
if len(repos) > 5:
72+
repos = repos[:5]
73+
74+
return repos
3775

3876

3977
# pylint: disable=unused-argument
@@ -54,7 +92,7 @@ def test_update_cp_org_libraries(monkeypatch):
5492
monkeypatch.setattr(common_funcs, "list_repos", mock_list_repos)
5593
monkeypatch.setattr(update_cp_org_libraries, "get_contributors", mock_get_contribs)
5694

57-
update_cp_org_libraries.main()
95+
update_cp_org_libraries.main(loglevel="INFO")
5896

5997

6098
# pylint: disable=invalid-name
@@ -66,8 +104,8 @@ def test_update_cp_org_libraries_output_file(monkeypatch, tmp_path, capsys):
66104

67105
tmp_output_file = tmp_path / "output_test.txt"
68106

69-
update_cp_org_libraries.main(output_file=tmp_output_file)
107+
update_cp_org_libraries.main(loglevel="INFO", output_file=tmp_output_file)
70108

71-
captured = capsys.readouterr()
109+
output = tmp_output_file.read_text()
72110

73-
assert tmp_output_file.read_text() == captured.out
111+
assert json.loads(output)

0 commit comments

Comments
 (0)