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 lesson visibility toggling for single user syncing #11359

Merged
Show file tree
Hide file tree
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
52 changes: 52 additions & 0 deletions kolibri/core/auth/test/test_morango_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ def test_scenarios(self, servers):
s1.create_model(Role, collection_id=fac.id, user_id=alk_user.id, kind="admin")
s0.create_model(Role, collection_id=fac.id, user_id=alk_user.id, kind="admin")
s1.sync(s0, facility)
s2.sync(s0, facility)
role = Role.objects.using(s1.db_alias).get(user=alk_user)
admin_role = Store.objects.using(s1.db_alias).get(id=role.id)
self.assertTrue(admin_role.conflicting_serialized_data)
Expand All @@ -397,6 +398,41 @@ def test_scenarios(self, servers):
)
self.assertTrue(Store.objects.using(s1.db_alias).get(id=alk_user.id).deleted)

# assert deleted object is transitively propagated
s2.sync(s1, facility)
self.assertFalse(
FacilityUser.objects.using(s2.db_alias)
.filter(username="Antemblowind")
.exists()
)
self.assertTrue(Store.objects.using(s2.db_alias).get(id=alk_user.id).deleted)

# assert deletion takes priority over update
alk_user = FacilityUser.objects.using(s0.db_alias).create(
username="Antemblowind", facility=facility
)
# Sync to both devices
s1.sync(s0, facility)
s2.sync(s0, facility)

# delete on s0
s0.delete_model(FacilityUser, id=alk_user.id)
# update on s1
s1.update_model(FacilityUser, alk_user.id, username="Antemblowind2")
# Sync deletion to s2
s2.sync(s0, facility)
self.assertFalse(
FacilityUser.objects.using(s2.db_alias).filter(id=alk_user.id).exists()
)
# Sync update to s2
s2.sync(s1, facility)
self.assertFalse(
FacilityUser.objects.using(s2.db_alias).filter(id=alk_user.id).exists()
)
self.assertFalse(
FacilityUser.objects.using(s1.db_alias).filter(id=alk_user.id).exists()
)

# # role deletion and re-creation
# Change roles for users
alto_user = FacilityUser.objects.using(s1.db_alias).get(
Expand Down Expand Up @@ -847,6 +883,22 @@ def test_single_user_assignment_sync(self, servers):
self.assert_existence(
self.tablet, kind, assignment_id, should_exist=False
)
if disable_assignment == self.deactivate:
# If we're deactivating the assignment, try reactivating it to check that we
# can make it active again
self.set_active_state(self.laptop_a, kind, assignment_id, True)
self.sync_full_facility_servers()
self.assert_existence(
self.tablet, kind, assignment_id, should_exist=False
)
self.assert_existence(
self.laptop_b, kind, assignment_id, should_exist=True
)
self.sync_single_user(self.laptop_a)
# import IPython; IPython.embed()
self.assert_existence(
self.tablet, kind, assignment_id, should_exist=True
)

# Create exam on Laptop A, single-user sync to tablet, then modify exam on Laptop A and
# single-user sync again to check that "updating" works
Expand Down
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ more-itertools==5.0.0 # Last Python 2.7 friendly release # pyup: <6.0
le-utils==0.2.1
jsonfield==2.0.2
requests-toolbelt==0.9.1
morango==0.6.16
morango==0.6.18
tzlocal==2.1
pytz==2022.1
python-dateutil==2.8.2
Expand Down