def test_enterpriseids_to_objects(self):
     expected = {}
     for x in range(5):
         person = self.factory.makePerson()
         upload = self.factory.makePackageUpload()
         expected['lp-development:Person:%d' % person.id] = person
         expected['lp-development:PackageUpload:%d' % upload.id] = upload
     IStore(expected.values()[0].__class__).invalidate()
     with StormStatementRecorder() as recorder:
         objects = enterpriseids_to_objects(expected.keys())
     self.assertThat(recorder, HasQueryCount(Equals(2)))
     self.assertContentEqual(expected.keys(), objects.keys())
     self.assertContentEqual(expected.values(), objects.values())
Пример #2
0
 def test_enterpriseids_to_objects(self):
     expected = {}
     for x in range(5):
         person = self.factory.makePerson()
         upload = self.factory.makePackageUpload()
         expected["lp-development:Person:%d" % person.id] = person
         expected["lp-development:PackageUpload:%d" % upload.id] = upload
     IStore(expected.values()[0].__class__).invalidate()
     with StormStatementRecorder() as recorder:
         objects = enterpriseids_to_objects(expected.keys())
     self.assertThat(recorder, HasQueryCount(Equals(2)))
     self.assertContentEqual(expected.keys(), objects.keys())
     self.assertContentEqual(expected.values(), objects.values())
Пример #3
0
 def receive(self, obj=None, operation=None, actorobj=None, limit=None):
     if obj:
         obj = self._convert_to_enterpriseid(obj)
     if actorobj:
         actorobj = self._convert_to_enterpriseid(actorobj)
     action = self.__get_timeline_action(
         "receive", obj, operation, actorobj)
     try:
         logs = super(AuditorClient, self).receive(
             obj, operation, actorobj, limit)
     finally:
         action.finish()
     # Process the actors and objects back from enterprise ids.
     eids = set()
     for entry in logs['log-entries']:
         eids |= set([entry['actor'], entry['object']])
     map_eids_to_obj = enterpriseids_to_objects(eids)
     for entry in logs['log-entries']:
         entry['actor'] = map_eids_to_obj.get(entry['actor'], None)
         entry['object'] = map_eids_to_obj.get(entry['object'], None)
     return logs['log-entries']
Пример #4
0
 def receive(self, obj=None, operation=None, actorobj=None, limit=None):
     if obj:
         obj = self._convert_to_enterpriseid(obj)
     if actorobj:
         actorobj = self._convert_to_enterpriseid(actorobj)
     action = self.__get_timeline_action("receive", obj, operation,
                                         actorobj)
     try:
         logs = super(AuditorClient, self).receive(obj, operation, actorobj,
                                                   limit)
     finally:
         action.finish()
     # Process the actors and objects back from enterprise ids.
     eids = set()
     for entry in logs['log-entries']:
         eids |= set([entry['actor'], entry['object']])
     map_eids_to_obj = enterpriseids_to_objects(eids)
     for entry in logs['log-entries']:
         entry['actor'] = map_eids_to_obj.get(entry['actor'], None)
         entry['object'] = map_eids_to_obj.get(entry['object'], None)
     return logs['log-entries']
 def test_enterpriseids_to_objects_non_existent_id(self):
     objects = enterpriseids_to_objects(
         ['lp-development:PackageUpload:10000'])
     self.assertEqual({}, objects)
Пример #6
0
 def test_enterpriseids_to_objects_non_existent_id(self):
     objects = enterpriseids_to_objects(["lp-development:PackageUpload:10000"])
     self.assertEqual({}, objects)