def test_02_condParser(self, mk_getSelectedCatalogs, mk_getEligibleCatalogs): """Test behavior of write methode when using FCConditionParser""" fc = FileCatalog( catalogs=["c1_True_True_True_2_0_2_0", "c2_False_True_True_3_0_1_0", "c3_False_True_True_3_0_1_0"] ) # No condition for c3, so it should always pass fcConditions = {"c1": "Filename=find('c1_pass')", "c2": "Filename=find('c2_pass')"} # Everything pass everywhere lfn1 = "/lhcb/c1_pass/c2_pass/lfn1" lfn2 = "/lhcb/c1_pass/c2_pass/lfn2" res = fc.write1([lfn1, lfn2], fcConditions=fcConditions) self.assertTrue(res["OK"]) self.assertEqual(sorted(res["Value"]["Successful"]), sorted([lfn1, lfn2])) self.assertEqual(sorted(res["Value"]["Successful"][lfn1]), sorted(["c1", "c2", "c3"])) self.assertEqual(sorted(res["Value"]["Successful"][lfn2]), sorted(["c1", "c2", "c3"])) self.assertTrue(not res["Value"]["Failed"]) # Everything pass for the master, only lfn2 for c2 lfn1 = "/lhcb/c1_pass/lfn1" lfn2 = "/lhcb/c1_pass/c2_pass/lfn2" res = fc.write1([lfn1, lfn2], fcConditions=fcConditions) self.assertTrue(res["OK"]) self.assertEqual(sorted(res["Value"]["Successful"]), sorted([lfn1, lfn2])) self.assertEqual(sorted(res["Value"]["Successful"][lfn1]), ["c1", "c3"]) self.assertEqual(sorted(res["Value"]["Successful"][lfn2]), sorted(["c1", "c2", "c3"])) self.assertTrue(not res["Value"]["Failed"]) # One is not valid for the master, so we do nothing lfn1 = "/lhcb/c2_pass/lfn1" lfn2 = "/lhcb/c1_pass/c2_pass/lfn2" res = fc.write1([lfn1, lfn2], fcConditions=fcConditions) self.assertTrue(not res["OK"])
def test_01_oneMasterNormal(self, mk_getSelectedCatalogs, mk_getEligibleCatalogs): """Test behavior with one master and only standard read methods""" fc = FileCatalog(catalogs=[ 'c1_True_True_True_2_0_2_0', 'c2_False_True_True_3_0_1_0' ]) # Test a write method which is not in the master catalog with self.assertRaises(AttributeError): fc.write4('/lhcb/toto') # Test a write method which works for everybody lfn = '/lhcb/toto' res = fc.write1(lfn) self.assertTrue(res['OK']) self.assertTrue(lfn in res['Value']['Successful']) self.assertEqual(sorted(['c1', 'c2']), sorted(res['Value']['Successful'][lfn].keys())) self.assertTrue(not res['Value']['Failed']) # Test a write method that only the master has lfn = '/lhcb/toto' res = fc.write2(lfn) self.assertTrue(res['OK']) self.assertTrue(lfn in res['Value']['Successful']) self.assertEqual(['c1'], res['Value']['Successful'][lfn].keys()) self.assertTrue(not res['Value']['Failed']) # Test a write method that makes an error for master # We should get an error lfn = '/lhcb/c1/Error' res = fc.write1(lfn) self.assertTrue(not res['OK']) # Test a write method that fails for master # The lfn should be in failed and only attempted for the master lfn = '/lhcb/c1/Failed' res = fc.write1(lfn) self.assertTrue(res['OK']) self.assertTrue(not res['Value']['Successful']) self.assertEqual(['c1'], res['Value']['Failed'][lfn].keys()) # Test a write method that makes an error for non master # The lfn should be in failed for non master and successful for the master lfn = '/lhcb/c2/Error' res = fc.write1(lfn) self.assertTrue(res['OK']) self.assertEqual(['c1'], res['Value']['Successful'][lfn].keys()) self.assertEqual(['c2'], res['Value']['Failed'][lfn].keys()) # Test a write method that fails for non master # The lfn should be in failed for non master and successful for the master lfn = '/lhcb/c2/Failed' res = fc.write1(lfn) self.assertTrue(res['OK']) self.assertEqual(['c1'], res['Value']['Successful'][lfn].keys()) self.assertEqual(['c2'], res['Value']['Failed'][lfn].keys())
def test_01_oneMasterNormal( self, mk_getSelectedCatalogs, mk_getEligibleCatalogs ): """Test behavior with one master and only standard read methods""" fc = FileCatalog( catalogs = ['c1_True_True_True_2_0_2_0', 'c2_False_True_True_3_0_1_0'] ) # Test a write method which is not in the master catalog with self.assertRaises( AttributeError ): fc.write4( '/lhcb/toto' ) # Test a write method which works for everybody lfn = '/lhcb/toto' res = fc.write1( lfn ) self.assert_( res['OK'] ) self.assert_( lfn in res['Value']['Successful'] ) self.assertEqual( sorted( ['c1', 'c2'] ), sorted( res['Value']['Successful'][lfn].keys() ) ) self.assert_( not res['Value']['Failed'] ) # Test a write method that only the master has lfn = '/lhcb/toto' res = fc.write2( lfn ) self.assert_( res['OK'] ) self.assert_( lfn in res['Value']['Successful'] ) self.assertEqual( ['c1'], res['Value']['Successful'][lfn].keys() ) self.assert_( not res['Value']['Failed'] ) # Test a write method that makes an error for master # We should get an error lfn = '/lhcb/c1/Error' res = fc.write1( lfn ) self.assert_( not res['OK'] ) # Test a write method that fails for master # The lfn should be in failed and only attempted for the master lfn = '/lhcb/c1/Failed' res = fc.write1( lfn ) self.assert_( res['OK'] ) self.assert_( not res['Value']['Successful'] ) self.assertEqual( ['c1'], res['Value']['Failed'][lfn].keys() ) # Test a write method that makes an error for non master # The lfn should be in failed for non master and successful for the master lfn = '/lhcb/c2/Error' res = fc.write1( lfn ) self.assert_( res['OK'] ) self.assertEqual( ['c1'], res['Value']['Successful'][lfn].keys() ) self.assertEqual( ['c2'], res['Value']['Failed'][lfn].keys() ) # Test a write method that fails for non master # The lfn should be in failed for non master and successful for the master lfn = '/lhcb/c2/Failed' res = fc.write1( lfn ) self.assert_( res['OK'] ) self.assertEqual( ['c1'], res['Value']['Successful'][lfn].keys() ) self.assertEqual( ['c2'], res['Value']['Failed'][lfn].keys() )
def test_01_oneMasterNormal(self, mk_getSelectedCatalogs, mk_getEligibleCatalogs): """Test behavior with one master and only standard read methods""" fc = FileCatalog(catalogs=["c1_True_True_True_2_0_2_0", "c2_False_True_True_3_0_1_0"]) # Test a write method which is not in the master catalog with self.assertRaises(AttributeError): fc.write4("/lhcb/toto") # Test a write method which works for everybody lfn = "/lhcb/toto" res = fc.write1(lfn) self.assertTrue(res["OK"]) self.assertTrue(lfn in res["Value"]["Successful"]) self.assertEqual(sorted(["c1", "c2"]), sorted(res["Value"]["Successful"][lfn])) self.assertTrue(not res["Value"]["Failed"]) # Test a write method that only the master has lfn = "/lhcb/toto" res = fc.write2(lfn) self.assertTrue(res["OK"]) self.assertTrue(lfn in res["Value"]["Successful"]) self.assertEqual(["c1"], sorted(res["Value"]["Successful"][lfn])) self.assertTrue(not res["Value"]["Failed"]) # Test a write method that makes an error for master # We should get an error lfn = "/lhcb/c1/Error" res = fc.write1(lfn) self.assertTrue(not res["OK"]) # Test a write method that fails for master # The lfn should be in failed and only attempted for the master lfn = "/lhcb/c1/Failed" res = fc.write1(lfn) self.assertTrue(res["OK"]) self.assertTrue(not res["Value"]["Successful"]) self.assertEqual(["c1"], sorted(res["Value"]["Failed"][lfn])) # Test a write method that makes an error for non master # The lfn should be in failed for non master and successful for the master lfn = "/lhcb/c2/Error" res = fc.write1(lfn) self.assertTrue(res["OK"]) self.assertEqual(["c1"], sorted(res["Value"]["Successful"][lfn])) self.assertEqual(["c2"], sorted(res["Value"]["Failed"][lfn])) # Test a write method that fails for non master # The lfn should be in failed for non master and successful for the master lfn = "/lhcb/c2/Failed" res = fc.write1(lfn) self.assertTrue(res["OK"]) self.assertEqual(["c1"], sorted(res["Value"]["Successful"][lfn])) self.assertEqual(["c2"], sorted(res["Value"]["Failed"][lfn]))
def test_02_condParser(self, mk_getSelectedCatalogs, mk_getEligibleCatalogs): """Test behavior of write methode when using FCConditionParser""" fc = FileCatalog(catalogs=[ 'c1_True_True_True_2_0_2_0', 'c2_False_True_True_3_0_1_0', 'c3_False_True_True_3_0_1_0' ]) # No condition for c3, so it should always pass fcConditions = { 'c1': "Filename=find('c1_pass')", 'c2': "Filename=find('c2_pass')" } # Everything pass everywhere lfn1 = '/lhcb/c1_pass/c2_pass/lfn1' lfn2 = '/lhcb/c1_pass/c2_pass/lfn2' res = fc.write1([lfn1, lfn2], fcConditions=fcConditions) self.assertTrue(res['OK']) self.assertEqual(sorted(res['Value']['Successful']), sorted([lfn1, lfn2])) self.assertEqual(sorted(res['Value']['Successful'][lfn1]), sorted(['c1', 'c2', 'c3'])) self.assertEqual(sorted(res['Value']['Successful'][lfn2]), sorted(['c1', 'c2', 'c3'])) self.assertTrue(not res['Value']['Failed']) # Everything pass for the master, only lfn2 for c2 lfn1 = '/lhcb/c1_pass/lfn1' lfn2 = '/lhcb/c1_pass/c2_pass/lfn2' res = fc.write1([lfn1, lfn2], fcConditions=fcConditions) self.assertTrue(res['OK']) self.assertEqual(sorted(res['Value']['Successful']), sorted([lfn1, lfn2])) self.assertEqual(sorted(res['Value']['Successful'][lfn1]), ['c1', 'c3']) self.assertEqual(sorted(res['Value']['Successful'][lfn2]), sorted(['c1', 'c2', 'c3'])) self.assertTrue(not res['Value']['Failed']) # One is not valid for the master, so we do nothing lfn1 = '/lhcb/c2_pass/lfn1' lfn2 = '/lhcb/c1_pass/c2_pass/lfn2' res = fc.write1([lfn1, lfn2], fcConditions=fcConditions) self.assertTrue(not res['OK'])
def test_02_condParser( self, mk_getSelectedCatalogs, mk_getEligibleCatalogs ): """Test behavior of write methode when using FCConditionParser""" fc = FileCatalog( catalogs = ['c1_True_True_True_2_0_2_0', 'c2_False_True_True_3_0_1_0', 'c3_False_True_True_3_0_1_0'] ) # No condition for c3, so it should always pass fcConditions = { 'c1' : "Filename=find('c1_pass')", 'c2' : "Filename=find('c2_pass')"} # Everything pass everywhere lfn1 = '/lhcb/c1_pass/c2_pass/lfn1' lfn2 = '/lhcb/c1_pass/c2_pass/lfn2' res = fc.write1( [lfn1, lfn2], fcConditions = fcConditions ) self.assert_( res['OK'] ) self.assertEqual( sorted( res['Value']['Successful'] ), sorted( [lfn1, lfn2] ) ) self.assertEqual( sorted( res['Value']['Successful'][lfn1] ), sorted( ['c1', 'c2', 'c3'] ) ) self.assertEqual( sorted( res['Value']['Successful'][lfn2] ), sorted( ['c1', 'c2', 'c3'] ) ) self.assert_( not res['Value']['Failed'] ) # Everything pass for the master, only lfn2 for c2 lfn1 = '/lhcb/c1_pass/lfn1' lfn2 = '/lhcb/c1_pass/c2_pass/lfn2' res = fc.write1( [lfn1, lfn2], fcConditions = fcConditions ) self.assert_( res['OK'] ) self.assertEqual( sorted( res['Value']['Successful'] ), sorted( [lfn1, lfn2] ) ) self.assertEqual( sorted( res['Value']['Successful'][lfn1] ) , ['c1', 'c3'] ) self.assertEqual( sorted( res['Value']['Successful'][lfn2] ), sorted( ['c1', 'c2','c3'] ) ) self.assert_( not res['Value']['Failed'] ) # One is not valid for the master, so we do nothing lfn1 = '/lhcb/c2_pass/lfn1' lfn2 = '/lhcb/c1_pass/c2_pass/lfn2' res = fc.write1( [lfn1, lfn2], fcConditions = fcConditions ) self.assert_( not res['OK'] )