Esempio n. 1
0
 def test_delete_orphans(self):
     # When users are deleted, their UIDs are generally not deleted.  We
     # never delete rows from that table in order to guarantee no
     # duplicates.  However, some external testing frameworks want to be
     # able to reset the UID table, so they can use this interface to do
     # so.  See LP: #1420083.
     #
     # Create some users.
     manager = getUtility(IUserManager)
     users_by_uid = {}
     with transaction():
         for i in range(10):
             user = manager.create_user()
             users_by_uid[user.user_id] = user
             # The testing infrastructure does not record the UIDs for new
             # user options, so do that now to mimic the real system.
             UID.record(user.user_id)
     # We now have 10 unique uids.
     self.assertEqual(len(users_by_uid), 10)
     # Now delete all the users.
     with transaction():
         for user in list(users_by_uid.values()):
             manager.delete_user(user)
     # There are still 10 unique uids in the database.
     self.assertEqual(UID.get_total_uid_count(), 10)
     # Cull the orphan UIDs.
     content, response = call_api(
         'http://localhost:9001/3.0/reserved/uids/orphans', method='DELETE')
     self.assertEqual(response.status, 204)
     # Now there are no uids in the table.
     config.db.abort()
     self.assertEqual(UID.get_total_uid_count(), 0)
Esempio n. 2
0
 def test_delete_orphans(self):
     # When users are deleted, their UIDs are generally not deleted.  We
     # never delete rows from that table in order to guarantee no
     # duplicates.  However, some external testing frameworks want to be
     # able to reset the UID table, so they can use this interface to do
     # so.  See LP: #1420083.
     #
     # Create some users.
     manager = getUtility(IUserManager)
     users_by_uid = {}
     with transaction():
         for i in range(10):
             user = manager.create_user()
             users_by_uid[user.user_id] = user
             # The testing infrastructure does not record the UIDs for new
             # user options, so do that now to mimic the real system.
             UID.record(user.user_id)
     # We now have 10 unique uids.
     self.assertEqual(len(users_by_uid), 10)
     # Now delete all the users.
     with transaction():
         for user in list(users_by_uid.values()):
             manager.delete_user(user)
     # There are still 10 unique uids in the database.
     self.assertEqual(UID.get_total_uid_count(), 10)
     # Cull the orphan UIDs.
     content, response = call_api(
         'http://localhost:9001/3.0/reserved/uids/orphans',
         method='DELETE')
     self.assertEqual(response.status, 204)
     # Now there are no uids in the table.
     config.db.abort()
     self.assertEqual(UID.get_total_uid_count(), 0)
Esempio n. 3
0
 def test_get_total_uid_count(self):
     # The reserved REST API needs this.
     for i in range(10):
         UID.record(uuid.uuid4())
     self.assertEqual(UID.get_total_uid_count(), 10)
Esempio n. 4
0
 def test_get_total_uid_count(self):
     # The reserved REST API needs this.
     for i in range(10):
         UID.record(uuid.uuid4())
     self.assertEqual(UID.get_total_uid_count(), 10)