def test_add_items_perf(self):
     db_path = self.cfg['cache-directory'] + '/object_cache.db'
     # test_table = [
     #     {
     #         'constructor': {
     #             'path': db_path,
     #             'workspace_url':  self.cfg['workspace-url'],
     #             'token': self.token,
     #             'username': self.username
     #         },
     #         'add_items': [[
     #             [1, 'me', 'hi'],
     #             [4, 'you', 'hello']
     #         ]]
     #     }
     # ]
     constructor = {
         'path': db_path,
         'workspace_url': self.cfg['workspace-url'],
         'token': self.token,
         'username': self.username
     }
     data = {'field1': 'value1', 'field2': 'value2', 'field3': 1234}
     test_data = ([i, 'eapearson', json.dumps(data)]
                  for i in xrange(0, 1000))
     # for test_data in test_table:
     try:
         cache = PermissionsCache(**constructor)
         cache.initialize()
         start = time.time()
         print('START')
         # print(test_data)
         cache.add_items(test_data)
         elapsed = time.time() - start
         print('END %s' % (elapsed / 1000))
         all = cache.get_all_items()
         self.assertGreater(len(all), 0)
         # TODO: test that the items are present and the only ones.
         self.assertTrue(True)
     except ValueError as err:
         print('ERROR!', err)
         self.assertTrue(False)
 def test_get_items(self):
     db_path = self.cfg['cache-directory'] + '/object_cache.db'
     test_table = [{
         'constructor': {
             'path': db_path,
             'workspace_url': self.cfg['workspace-url'],
             'token': self.token,
             'username': self.username
         },
         'add_items': [[[34742, 'eapearson', 'hi'],
                        [34742, 'eapearson', 'hello']]],
         'get_items': [[[34742, 'eapearson'], [34599, 'eapearson']]]
     }]
     for test in test_table:
         try:
             cache = PermissionsCache(**test['constructor'])
             cache.initialize()
             cache.add_items(*test['add_items'])
             items = cache.get_items(*test['get_items'])
             self.assertGreater(len(items), 0)
             self.assertTrue(True)
         except ValueError as err:
             self.assertTrue(False)
 def test_add_items(self):
     db_path = self.cfg['cache-directory'] + '/object_cache.db'
     test_table = [{
         'constructor': {
             'path': db_path,
             'workspace_url': self.cfg['workspace-url'],
             'token': self.token,
             'username': self.username
         },
         'add_items': [[[1, 'me', 'hi'], [4, 'you', 'hello']]]
     }]
     for test in test_table:
         try:
             cache = PermissionsCache(**test['constructor'])
             cache.initialize()
             cache.add_items(*test['add_items'])
             all = cache.get_all_items()
             self.assertGreater(len(all), 0)
             # TODO: test that the items are present and the only ones.
             self.assertTrue(True)
         except ValueError as err:
             print('ERROR!', err)
             self.assertTrue(False)