Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Sync plan_activated_users during sync_teams #902

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix test
  • Loading branch information
suejung-sentry committed Jan 29, 2025
commit f1eddb415c00082cc35eba784508b1b8027f3a84
10 changes: 8 additions & 2 deletions tasks/sync_teams.py
Original file line number Diff line number Diff line change
@@ -58,8 +58,14 @@
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

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

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
2 changes: 2 additions & 0 deletions tasks/tests/unit/test_sync_teams_task.py
Original file line number Diff line number Diff line change
@@ -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
Loading
Oops, something went wrong.