def get_conduit_and_cache_for_args(self, args): key = (args.instance_uri, args.arcyd_user, args.arcyd_cert, args.https_proxy) if key not in self._conduits_caches: # create an array so that the 'connect' closure binds to the # 'conduit' variable as we'd expect, otherwise it'll just # modify a local variable and this 'conduit' will remain 'None' # XXX: we can _process_repo better in python 3.x (nonlocal?) conduit = [None] def connect(): # XXX: we'll rebind in python 3.x, instead # nonlocal conduit conduit[0] = phlsys_conduit.MultiConduit( args.instance_uri, args.arcyd_user, args.arcyd_cert, https_proxy=args.https_proxy) abdt_tryloop.tryloop(connect, abdt_errident.CONDUIT_CONNECT, args.instance_uri) multi_conduit = conduit[0] cache = phlcon_reviewstatecache.make_from_conduit(multi_conduit) arcyd_conduit = abdt_conduit.Conduit(multi_conduit, cache) self._conduits_caches[key] = (arcyd_conduit, cache) else: arcyd_conduit, cache = self._conduits_caches[key] return arcyd_conduit, cache
def get_conduit_and_cache_for_args(self, args): key = ( args.instance_uri, args.arcyd_user, args.arcyd_cert, args.https_proxy ) if key not in self._conduits_caches: # create an array so that the 'connect' closure binds to the # 'conduit' variable as we'd expect, otherwise it'll just # modify a local variable and this 'conduit' will remain 'None' # XXX: we can _process_repo better in python 3.x (nonlocal?) conduit = [None] def connect(): # XXX: we'll rebind in python 3.x, instead # nonlocal conduit conduit[0] = phlsys_conduit.MultiConduit( args.instance_uri, args.arcyd_user, args.arcyd_cert, https_proxy=args.https_proxy) abdt_tryloop.tryloop( connect, abdt_errident.CONDUIT_CONNECT, args.instance_uri) multi_conduit = conduit[0] cache = phlcon_reviewstatecache.make_from_conduit(multi_conduit) arcyd_conduit = abdt_conduit.Conduit(multi_conduit, cache) self._conduits_caches[key] = (arcyd_conduit, cache) else: arcyd_conduit, cache = self._conduits_caches[key] return arcyd_conduit, cache
def setUp(self): self.test_data = phldef_conduit self.sys_conduit = phlsys_conduit.MultiConduit( self.test_data.TEST_URI, self.test_data.PHAB.user, self.test_data.PHAB.certificate) self.reviewstate_cache = phlcon_reviewstatecache.make_from_conduit( self.sys_conduit) self.conduit = abdt_conduit.Conduit( self.sys_conduit, self.reviewstate_cache)
def test_A_Breathing(self): test_data = phldef_conduit conduit = phlsys_conduit.Conduit( test_data.TEST_URI, test_data.PHAB.user, test_data.PHAB.certificate) revision_id = phlcon_differential.create_empty_revision(conduit) cache = phlcon_reviewstatecache.make_from_conduit(conduit) # shouldn't have active reviews to start with self.assertEqual(set(), cache.active_reviews) # assert it's in 'needs review' self.assertEqual( cache.get_state(revision_id).status, phlcon_differential.ReviewStates.needs_review) # should now have cached the review self.assertEqual(set((revision_id,)), cache.active_reviews) # change real state to 'abandoned' phlcon_differential.create_comment( conduit, revisionId=revision_id, action=phlcon_differential.Action.abandon) # check that the cache still reports 'needs_review' self.assertEqual( cache.get_state(revision_id).status, phlcon_differential.ReviewStates.needs_review) # refresh the cache cache.refresh_active_reviews() # check that the cache now reports 'abandoned' self.assertEqual( cache.get_state(revision_id).status, phlcon_differential.ReviewStates.abandoned)
def test_A_Breathing(self): test_data = phldef_conduit conduit = phlsys_conduit.Conduit(test_data.TEST_URI, test_data.PHAB.user, test_data.PHAB.certificate) revision_id = phlcon_differential.create_empty_revision(conduit) cache = phlcon_reviewstatecache.make_from_conduit(conduit) # shouldn't have active reviews to start with self.assertEqual(set(), cache.active_reviews) # assert it's in 'needs review' self.assertEqual( cache.get_state(revision_id).status, phlcon_differential.ReviewStates.needs_review) # should now have cached the review self.assertEqual(set((revision_id, )), cache.active_reviews) # change real state to 'abandoned' phlcon_differential.create_comment( conduit, revisionId=revision_id, action=phlcon_differential.Action.abandon) # check that the cache still reports 'needs_review' self.assertEqual( cache.get_state(revision_id).status, phlcon_differential.ReviewStates.needs_review) # refresh the cache cache.refresh_active_reviews() # check that the cache now reports 'abandoned' self.assertEqual( cache.get_state(revision_id).status, phlcon_differential.ReviewStates.abandoned)