Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jefer94 committed Dec 17, 2024
1 parent 9426c99 commit aa42a80
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def handle(self, *args, **options):

def github(self):
ids = []
allowed_users = ["breatheco-de", "4GeeksAcademy", "4geeksacademy"]
processed = set()
for settings in AcademyAuthSettings.objects.filter(
github_owner__isnull=False, github_owner__credentialsgithub__isnull=False
Expand All @@ -31,22 +32,20 @@ def github(self):
continue

processed.add(key)
allowed_users = ["breatheco-de", "4GeeksAcademy", "4geeksacademy"]

while True:
items = RepositoryDeletionOrder.objects.filter(
provider=RepositoryDeletionOrder.Provider.GITHUB,
notified_at=None,
status=RepositoryDeletionOrder.Status.TRANSFERRING,
repository_user__in=allowed_users,
).exclude(id__in=ids)[:100]

if len(items) == 0:
break

for deletion_order in items:
ids.append(deletion_order.id)
if deletion_order.repository_user not in allowed_users:
continue

if deletion_order.repository_name.endswith(".git"):
deletion_order.repository_name = deletion_order.repository_name[:-4]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ def test_one_repo__pending__user_not_found(database: capyc.Database, patch_get,
},
{
"method": "GET",
"url": f"https://api.github.com/orgs/{model.academy_auth_settings.github_username}/curso-nodejs-4geeks/events?page=1&per_page=30",
"url": f"https://api.github.com/repos/{model.academy_auth_settings.github_username}/curso-nodejs-4geeks/events?page=1&per_page=30",
"expected": [],
"code": 200,
"headers": {},
Expand Down Expand Up @@ -598,7 +598,7 @@ def test_one_repo__pending__user_found(
},
{
"method": "GET",
"url": f"https://api.github.com/orgs/{model.academy_auth_settings.github_username}/curso-nodejs-4geeks-{parsed_name}/events?page=1&per_page=30",
"url": f"https://api.github.com/repos/{model.academy_auth_settings.github_username}/curso-nodejs-4geeks-{parsed_name}/events?page=1&per_page=30",
"expected": [event],
"code": 200,
"headers": {},
Expand Down Expand Up @@ -679,7 +679,7 @@ def test_one_repo__pending__user_found__inferred(database: capyc.Database, patch
},
{
"method": "GET",
"url": f"https://api.github.com/orgs/{model.academy_auth_settings.github_username}/curso-nodejs-4geeks/events?page=1&per_page=30",
"url": f"https://api.github.com/repos/{model.academy_auth_settings.github_username}/curso-nodejs-4geeks/events?page=1&per_page=30",
"expected": [event],
"code": 200,
"headers": {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ def test_one_repo__pending__user_found(
"provider": "GITHUB",
"repository_name": f"curso-nodejs-4geeks-{parsed_name}",
"repository_user": github_username,
"status": "PENDING",
"status": "TRANSFERRING",
"status_text": None,
"notified_at": None,
},
],
)
Expand All @@ -137,7 +138,7 @@ def test_one_repo__pending__user_found(
[
{
"method": "GET",
"url": f"https://api.github.com/orgs/{model.academy_auth_settings.github_username}/curso-nodejs-4geeks-{parsed_name}/events?page=1&per_page=30",
"url": f"https://api.github.com/repos/{model.academy_auth_settings.github_username}/curso-nodejs-4geeks-{parsed_name}/events?page=1&per_page=30",
"expected": [event],
"code": 200,
"headers": {},
Expand Down Expand Up @@ -174,8 +175,9 @@ def test_one_repo__pending__user_found__inferred(
"provider": "GITHUB",
"repository_name": "curso-nodejs-4geeks",
"repository_user": github_username,
"status": "PENDING",
"status": "TRANSFERRING",
"status_text": None,
"notified_at": None,
},
],
)
Expand All @@ -185,7 +187,7 @@ def test_one_repo__pending__user_found__inferred(
[
{
"method": "GET",
"url": f"https://api.github.com/orgs/{model.academy_auth_settings.github_username}/curso-nodejs-4geeks/events?page=1&per_page=30",
"url": f"https://api.github.com/repos/{model.academy_auth_settings.github_username}/curso-nodejs-4geeks/events?page=1&per_page=30",
"expected": [event],
"code": 200,
"headers": {},
Expand Down

0 comments on commit aa42a80

Please sign in to comment.