diff --git a/gitea/gitea.py b/gitea/gitea.py index 99b0ed5..4bce164 100644 --- a/gitea/gitea.py +++ b/gitea/gitea.py @@ -184,7 +184,7 @@ class Repository(GiteaApiObject): def get_issues_state(self, state) -> List[GiteaApiObject]: """Get issues of state Issue.open or Issue.closed of a repository.""" - assert state in [Issue.open, Issue.closed] + assert state in [Issue.OPENED, Issue.CLOSED] index = 1 issues = [] while True: @@ -587,7 +587,7 @@ class Gitea: def get_user_by_email(self, email: str) -> User: users = self.get_users() for user in users: - if user.email == email: + if user.email == email or email in user.emails: return user return None diff --git a/test_api.py b/test_api.py index ae8b61d..272f36b 100644 --- a/test_api.py +++ b/test_api.py @@ -119,12 +119,18 @@ def test_create_issue(): assert issue.body == "Body text with this issue" def test_delete_repo_userowned(): - org = User.request(gitea, test_user) - repo = Repository.request(gitea, org.username, test_repo) + user = User.request(gitea, test_user) + repo = Repository.request(gitea, user.username, test_repo) repo.delete() with pytest.raises(NotFoundException) as e: Repository.request(gitea, test_user, test_repo) +def test_secundary_email(): + SECONDARYMAIL = "secondarytest@test.org" # set up with real email + sec_user = gitea.get_user_by_email(SECONDARYMAIL) + assert SECONDARYMAIL in sec_user.emails + assert sec_user.username == "test" + def test_delete_repo_orgowned(): org = Organization.request(gitea, test_org) repo = Repository.request(gitea, org.username, test_repo)