Example #1
0
 def test_gen_reload_queries_with_compound_primary_keys(self):
     # gen_reload_queries() does not like compound primary keys.
     db_queries = bulk.gen_reload_queries([BugAffectsPerson()])
     self.assertRaisesWithContent(
         AssertionError,
         'Compound primary keys are not supported: BugAffectsPerson.', list,
         db_queries)
Example #2
0
 def test_gen_reload_queries_with_compound_primary_keys(self):
     # gen_reload_queries() does not like compound primary keys.
     db_queries = bulk.gen_reload_queries([BugAffectsPerson()])
     self.assertRaisesWithContent(
         AssertionError,
         'Compound primary keys are not supported: BugAffectsPerson.',
         list, db_queries)
Example #3
0
 def test_gen_reload_queries_with_single_object(self):
     # gen_reload_queries() should generate a single query for a
     # single object.
     db_objects = [self.factory.makeSourcePackageName()]
     db_queries = list(bulk.gen_reload_queries(db_objects))
     self.failUnlessEqual(1, len(db_queries))
     db_query = db_queries[0]
     self.failUnlessEqual(db_objects, list(db_query))
Example #4
0
 def test_gen_reload_queries_with_single_object(self):
     # gen_reload_queries() should generate a single query for a
     # single object.
     db_objects = [self.factory.makeSourcePackageName()]
     db_queries = list(bulk.gen_reload_queries(db_objects))
     self.failUnlessEqual(1, len(db_queries))
     db_query = db_queries[0]
     self.failUnlessEqual(db_objects, list(db_query))
Example #5
0
 def test_gen_reload_queries_with_multiple_similar_objects(self):
     # gen_reload_queries() should generate a single query to load
     # multiple objects of the same type.
     db_objects = set(
         self.factory.makeSourcePackageName() for i in range(5))
     db_queries = list(bulk.gen_reload_queries(db_objects))
     self.failUnlessEqual(1, len(db_queries))
     db_query = db_queries[0]
     self.failUnlessEqual(db_objects, set(db_query))
Example #6
0
 def test_gen_reload_queries_with_multiple_similar_objects(self):
     # gen_reload_queries() should generate a single query to load
     # multiple objects of the same type.
     db_objects = set(self.factory.makeSourcePackageName()
                      for i in range(5))
     db_queries = list(bulk.gen_reload_queries(db_objects))
     self.failUnlessEqual(1, len(db_queries))
     db_query = db_queries[0]
     self.failUnlessEqual(db_objects, set(db_query))
Example #7
0
 def test_gen_reload_queries_with_mixed_objects(self):
     # gen_reload_queries() should return one query for each
     # distinct object type in the given objects.
     db_objects = set(self.factory.makeSourcePackageName()
                      for i in range(5))
     db_objects.update(self.factory.makeComponent() for i in range(5))
     db_queries = list(bulk.gen_reload_queries(db_objects))
     self.failUnlessEqual(2, len(db_queries))
     db_objects_loaded = set()
     for db_query in db_queries:
         objects = set(db_query)
         # None of these objects should have been loaded before.
         self.failUnlessEqual(set(),
                              objects.intersection(db_objects_loaded))
         db_objects_loaded.update(objects)
     self.failUnlessEqual(db_objects, db_objects_loaded)
Example #8
0
 def test_gen_reload_queries_with_mixed_objects(self):
     # gen_reload_queries() should return one query for each
     # distinct object type in the given objects.
     db_objects = set(
         self.factory.makeSourcePackageName() for i in range(5))
     db_objects.update(
         self.factory.makeComponent() for i in range(5))
     db_queries = list(bulk.gen_reload_queries(db_objects))
     self.failUnlessEqual(2, len(db_queries))
     db_objects_loaded = set()
     for db_query in db_queries:
         objects = set(db_query)
         # None of these objects should have been loaded before.
         self.failUnlessEqual(
             set(), objects.intersection(db_objects_loaded))
         db_objects_loaded.update(objects)
     self.failUnlessEqual(db_objects, db_objects_loaded)
Example #9
0
 def test_gen_reload_queries_with_mixed_stores(self):
     # gen_reload_queries() returns one query for each distinct
     # store even for the same object type.
     db_object = self.factory.makeComponent()
     db_object_type = bulk.get_type(db_object)
     # Commit so the database object is available in both master
     # and slave stores.
     transaction.commit()
     db_objects = set(
         (IMasterStore(db_object).get(db_object_type, db_object.id),
          ISlaveStore(db_object).get(db_object_type, db_object.id)))
     db_queries = list(bulk.gen_reload_queries(db_objects))
     self.failUnlessEqual(2, len(db_queries))
     db_objects_loaded = set()
     for db_query in db_queries:
         objects = set(db_query)
         # None of these objects should have been loaded before.
         self.failUnlessEqual(
             set(), objects.intersection(db_objects_loaded))
         db_objects_loaded.update(objects)
     self.failUnlessEqual(db_objects, db_objects_loaded)
Example #10
0
 def test_gen_reload_queries_with_mixed_stores(self):
     # gen_reload_queries() returns one query for each distinct
     # store even for the same object type.
     db_object = self.factory.makeComponent()
     db_object_type = bulk.get_type(db_object)
     # Commit so the database object is available in both master
     # and slave stores.
     transaction.commit()
     db_objects = set(
         (IMasterStore(db_object).get(db_object_type, db_object.id),
          ISlaveStore(db_object).get(db_object_type, db_object.id)))
     db_queries = list(bulk.gen_reload_queries(db_objects))
     self.failUnlessEqual(2, len(db_queries))
     db_objects_loaded = set()
     for db_query in db_queries:
         objects = set(db_query)
         # None of these objects should have been loaded before.
         self.failUnlessEqual(set(),
                              objects.intersection(db_objects_loaded))
         db_objects_loaded.update(objects)
     self.failUnlessEqual(db_objects, db_objects_loaded)
Example #11
0
 def test_gen_reload_queries_with_empty_list(self):
     self.failUnlessEqual([], list(bulk.gen_reload_queries([])))
Example #12
0
 def test_gen_reload_queries_with_non_Storm_objects(self):
     # gen_reload_queries() does not like non-Storm objects.
     self.assertRaises(
         ClassInfoError, list, bulk.gen_reload_queries(['bogus']))
Example #13
0
 def test_gen_reload_queries_with_empty_list(self):
     self.failUnlessEqual([], list(bulk.gen_reload_queries([])))
Example #14
0
 def test_gen_reload_queries_with_non_Storm_objects(self):
     # gen_reload_queries() does not like non-Storm objects.
     self.assertRaises(ClassInfoError, list,
                       bulk.gen_reload_queries(['bogus']))