Skip to content

Commit

Permalink
fix: simplify boolean and add another test
Browse files Browse the repository at this point in the history
Signed-off-by: jmeridth <[email protected]>
  • Loading branch information
jmeridth committed Apr 2, 2024
1 parent 444a846 commit bbed3d5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 2 additions & 4 deletions evergreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,9 @@ def main(): # pragma: no cover
def is_repo_created_date_before(repo_created_at: str, created_after_date: str):
"""Check if the repository was created before the created_after_date"""
repo_created_at_date = datetime.fromisoformat(repo_created_at).replace(tzinfo=None)
if created_after_date and repo_created_at_date < datetime.strptime(
return created_after_date and repo_created_at_date < datetime.strptime(
created_after_date, "%Y-%m-%d"
):
return True
return False
)


def is_dependabot_security_updates_enabled(owner, repo, access_token):
Expand Down
9 changes: 9 additions & 0 deletions test_evergreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,15 @@ def test_is_repo_created_date_has_no_time_zone(self):

self.assertTrue(result)

def test_is_created_after_date_is_empty_string(self):
"""Test the repo.created_at date is after created_after_date."""
repo_created_at = "2020-01-01"
created_after_date = ""

result = is_repo_created_date_before(repo_created_at, created_after_date)

self.assertFalse(result)


if __name__ == "__main__":
unittest.main()

0 comments on commit bbed3d5

Please sign in to comment.