Skip to content

Commit eebf86e

Browse files
committed
Bitbucket: Add AppUser enrollments for User class appears #1570
1 parent b090c2e commit eebf86e

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

atlassian/bitbucket/cloud/common/comments.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from ..base import BitbucketCloudBase
22
from ..common.users import User
3+
from ..common.users import AppUser
34

45

56
class Comment(BitbucketCloudBase):
@@ -31,6 +32,9 @@ def markup(self):
3132
@property
3233
def user(self):
3334
"""User object with user information of the comment."""
35+
if self.get_data("user")["type"] == "app_user":
36+
# If the participant is an app user, return an AppUser instance
37+
return AppUser(None, self.get_data("user"), **self._new_session_args)
3438
return User(None, self.get_data("user"), **self._new_session_args)
3539

3640
def update(self, **kwargs):

atlassian/bitbucket/cloud/common/users.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ def __init__(self, data, *args, **kwargs):
8787
@property
8888
def user(self):
8989
"""User object with user information of the participant."""
90-
if self.get_data("type") == "app_user":
90+
if self.get_data("user")["type"] == "app_user":
9191
# If the participant is an app user, return an AppUser instance
92-
return AppUser(None, self.get_data("app_user"), **self._new_session_args)
92+
return AppUser(None, self.get_data("user"), **self._new_session_args)
9393
return User(None, self.get_data("user"), **self._new_session_args)
9494

9595
@property

atlassian/bitbucket/cloud/repositories/commits.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from ..base import BitbucketCloudBase
44
from ..common.builds import Build
55
from ..common.comments import Comment
6-
from ..common.users import Participant, User
6+
from ..common.users import Participant, User, AppUser
77

88

99
class Commits(BitbucketCloudBase):
@@ -89,6 +89,9 @@ def date(self):
8989
@property
9090
def author(self):
9191
"""User object of the author."""
92+
if self.get_data("author")["type"] == "app_user":
93+
# If the author is an app user, return an AppUser instance
94+
return AppUser(None, self.get_data("author").get("user"), **self._new_session_args)
9295
return User(None, self.get_data("author").get("user"))
9396

9497
def parents(self):

atlassian/bitbucket/cloud/repositories/pullRequests.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from ...cloud.repositories.commits import Commit
66
from ..common.builds import Build
77
from ..common.comments import Comment
8-
from ..common.users import User, Participant
8+
from ..common.users import User, Participant, AppUser
99

1010

1111
class PullRequests(BitbucketCloudBase):
@@ -209,6 +209,9 @@ def declined_reason(self):
209209
@property
210210
def author(self):
211211
"""User object of the author"""
212+
if self.get_data("author")["type"] == "app_user":
213+
# If the author is an app user, return an AppUser instance
214+
return AppUser(None, self.get_data("author"), **self._new_session_args)
212215
return User(None, self.get_data("author"))
213216

214217
@property
@@ -451,11 +454,17 @@ def is_resolved(self):
451454
@property
452455
def creator(self):
453456
"""User object with user information of the task creator"""
457+
if self.get_data("creator")["type"] == "app_user":
458+
# If the creator is an app user, return an AppUser instance
459+
return AppUser(None, self.get_data("creator"), **self._new_session_args)
454460
return User(None, self.get_data("creator"), **self._new_session_args)
455461

456462
@property
457463
def resolved_by(self):
458464
"""User object with user information of the task resolver"""
465+
if self.get_data("resolved_by")["type"] == "app_user":
466+
# If the resolver is an app user, return an AppUser instance
467+
return AppUser(None, self.get_data("resolved_by"), **self._new_session_args)
459468
return User(None, self.get_data("resolved_by"), **self._new_session_args)
460469

461470
def update(self, raw_message):

atlassian/bitbucket/cloud/repositories/refs.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# coding=utf-8
22

33
from ..base import BitbucketCloudBase
4-
from ..common.users import User
4+
from ..common.users import User, AppUser
55

66

77
class Refs(BitbucketCloudBase):
@@ -120,6 +120,9 @@ def __init__(self, data, *args, **kwargs):
120120
@property
121121
def author(self):
122122
"""User object of the author."""
123+
if self.get_data("author")["type"] == "app_user":
124+
# If the author is an app user, return an AppUser instance
125+
return AppUser(None, self.get_data("author").get("user"), **self._new_session_args)
123126
return User(None, self.get_data("author"))
124127

125128

0 commit comments

Comments
 (0)