Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
suejung-sentry committed Jan 29, 2025
1 parent 3b28bbb commit f1eddb4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions tasks/sync_teams.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,14 @@ def run_impl(self, db_session, ownerid, *, username=None, **kwargs):
ownerid=ownerid,
),
)
for org in removed_orgs:
org.plan_activated_users.remove(ownerid)
for org_ownerid in removed_orgs:
org = db_session.query(Owner).filter(Owner.ownerid == org_ownerid).first()
if org and ownerid in org.plan_activated_users:
log.info(

Check warning on line 64 in tasks/sync_teams.py

View check run for this annotation

Codecov Notifications / codecov/patch

tasks/sync_teams.py#L64

Added line #L64 was not covered by tests
"Removing user from org's plan_activated_users",
extra=dict(user_ownerid=ownerid, org_ownerid=org_ownerid)
)
org.plan_activated_users.remove(ownerid)

Check warning on line 68 in tasks/sync_teams.py

View check run for this annotation

Codecov Notifications / codecov/patch

tasks/sync_teams.py#L68

Added line #L68 was not covered by tests

owner.updatestamp = datetime.now()
owner.organizations = team_ids
Expand Down
2 changes: 2 additions & 0 deletions tasks/tests/unit/test_sync_teams_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ def test_team_removed(self, mocker, mock_configuration, dbsession, codecov_vcr):
service="github",
unencrypted_oauth_token=token,
)
prev_team.plan_activated_users = [user.ownerid]
dbsession.add(user)
dbsession.flush()
SyncTeamsTask().run_impl(dbsession, user.ownerid, using_integration=False)
assert prev_team.ownerid not in user.organizations
assert user.ownerid not in prev_team.plan_activated_users

def test_team_data_updated(
self, mocker, mock_configuration, dbsession, codecov_vcr
Expand Down

0 comments on commit f1eddb4

Please sign in to comment.