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 all commits
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
10 changes: 10 additions & 0 deletions tasks/sync_teams.py
Original file line number Diff line number Diff line change
@@ -58,6 +58,16 @@
ownerid=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 66 in tasks/sync_teams.py

Codecov Notifications / codecov/patch

tasks/sync_teams.py#L66

Added line #L66 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 70 in tasks/sync_teams.py

Codecov Notifications / codecov/patch

tasks/sync_teams.py#L70

Added line #L70 was not covered by tests

owner.updatestamp = datetime.now()
owner.organizations = team_ids
3 changes: 3 additions & 0 deletions tasks/tests/unit/test_sync_teams_task.py
Original file line number Diff line number Diff line change
@@ -37,10 +37,13 @@ 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.add(prev_team)
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.