This repository was archived by the owner on Sep 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -523,5 +523,48 @@ def getresponse(self):
523523 'someSite1' : 'someId1' })
524524
525525
526+ class TestGetDatasetFileLocations (unittest .TestCase ):
527+ def test_getDatasetFileLocations (self ):
528+ class MockResponseStringIo :
529+ def __init__ (self , * args , ** kwargs ):
530+ self .response = None
531+
532+ def request (self , * args , ** kwargs ):
533+ self .response = {"phedex" : {
534+ "block" : [{
535+ "file" : [
536+ {
537+ "name" : "someSite" ,
538+ "decision" : "approved" ,
539+ "replica" : [{
540+ "node" : "someNode"
541+ }]
542+ },
543+ {
544+ "name" : "someSite1" ,
545+ "decision" : "pending" ,
546+ "replica" : [{
547+ "node" : "someNode1"
548+ }]
549+ },
550+ ],
551+ }]}
552+ }
553+
554+ def getresponse (self ):
555+ return ContextualStringIO (json .dumps (self .response ))
556+ from WmAgentScripts .utils import getDatasetFileLocations
557+ with patch ('WmAgentScripts.utils.make_x509_conn' , MockResponseStringIo ):
558+ response = getDatasetFileLocations (
559+ url = 'http://someurl.com/' ,
560+ dataset = 'somedataset'
561+ )
562+ print response
563+ self .assertDictEqual (
564+ response , {
565+ 'someSite' : set (['someNode' ]),
566+ 'someSite1' : set (['someNode1' ])})
567+
568+
526569if __name__ == '__main__' :
527570 unittest .main ()
You can’t perform that action at this time.
0 commit comments