From 6d6a40b8c0f55d03a32242d2d432248bac8aa21f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Wed, 29 Aug 2018 11:26:19 +0200 Subject: [PATCH] Empty lists don't seem to be stored in MongoDB any more It looks like with the new Eve (or one of its dependencies) empty lists aren't stored any more; rather than storing `{'org_roles': []}`, it skips the `'org_roles'` key altogether. Not sure what caused this, as it was mentioned in neither the Eve nor the PyMongo changelog. --- tests/test_api/test_organizations.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_api/test_organizations.py b/tests/test_api/test_organizations.py index abd99c0c..77c5b873 100644 --- a/tests/test_api/test_organizations.py +++ b/tests/test_api/test_organizations.py @@ -254,8 +254,8 @@ class OrganizationPatchTest(AbstractPillarTest): db = self.app.db('organizations') db_org = db.find_one(org_id) - self.assertEqual([], db_org['members']) - self.assertEqual([], db_org['unknown_members']) + self.assertEqual([], db_org.get('members', [])) + self.assertEqual([], db_org.get('unknown_members', [])) def test_remove_user_by_email(self): self.enter_app_context() @@ -1056,7 +1056,7 @@ class IPRangeLoginRolesTest(AbstractIPRangeSingleOrgTest): 'token_hashed': hash_auth_token('usertoken'), 'expire_time': {'$gt': datetime.datetime.now(tz_util.utc)}, }) - self.assertEqual(ip_roles, set(token['org_roles'])) + self.assertEqual(ip_roles, set(token.get('org_roles', []))) # The IP-based roles should also be persisted in the user document. users_coll = self.app.db('users')