예제 #1
0
 def test_can_return_ids(self):
     # create() can be asked to return the created IDs instead of objects.
     job = IStore(Job).add(Job())
     IStore(Job).flush()
     wanted = [(None, job, BranchJobType.RECLAIM_BRANCH_SPACE)]
     with StormStatementRecorder() as recorder:
         [created_id] = bulk.create(
             (BranchJob.branch, BranchJob.job, BranchJob.job_type),
             wanted, get_primary_keys=True)
     self.assertThat(recorder, HasQueryCount(Equals(1)))
     [reclaimjob] = ReclaimBranchSpaceJob.iterReady()
     self.assertEqual(created_id, reclaimjob.context.id)
예제 #2
0
 def test_can_return_ids(self):
     # create() can be asked to return the created IDs instead of objects.
     job = IStore(Job).add(Job())
     IStore(Job).flush()
     wanted = [(None, job, BranchJobType.RECLAIM_BRANCH_SPACE)]
     with StormStatementRecorder() as recorder:
         [created_id] = bulk.create(
             (BranchJob.branch, BranchJob.job, BranchJob.job_type),
             wanted,
             get_primary_keys=True)
     self.assertThat(recorder, HasQueryCount(Equals(1)))
     [reclaimjob] = ReclaimBranchSpaceJob.iterReady()
     self.assertEqual(created_id, reclaimjob.context.id)
예제 #3
0
 def test_load_can_be_skipped(self):
     # create() can be told not to load the created rows.
     job = IStore(Job).add(Job())
     IStore(Job).flush()
     wanted = [(None, job, BranchJobType.RECLAIM_BRANCH_SPACE)]
     with StormStatementRecorder() as recorder:
         self.assertIs(
             None,
             bulk.create(
                 (BranchJob.branch, BranchJob.job, BranchJob.job_type),
                 wanted, get_objects=False))
     self.assertThat(recorder, HasQueryCount(Equals(1)))
     [reclaimjob] = ReclaimBranchSpaceJob.iterReady()
     branchjob = reclaimjob.context
     self.assertEqual(
         wanted, [(branchjob.branch, branchjob.job, branchjob.job_type)])
예제 #4
0
 def test_load_can_be_skipped(self):
     # create() can be told not to load the created rows.
     job = IStore(Job).add(Job())
     IStore(Job).flush()
     wanted = [(None, job, BranchJobType.RECLAIM_BRANCH_SPACE)]
     with StormStatementRecorder() as recorder:
         self.assertIs(
             None,
             bulk.create(
                 (BranchJob.branch, BranchJob.job, BranchJob.job_type),
                 wanted,
                 get_objects=False))
     self.assertThat(recorder, HasQueryCount(Equals(1)))
     [reclaimjob] = ReclaimBranchSpaceJob.iterReady()
     branchjob = reclaimjob.context
     self.assertEqual(
         wanted, [(branchjob.branch, branchjob.job, branchjob.job_type)])