Skip to content
This repository was archived by the owner on Sep 12, 2024. It is now read-only.

Commit eea926f

Browse files
committed
add unittests for utils.getNodesId
1 parent c63cb43 commit eea926f

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

tests/test_utils.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,5 +487,41 @@ def getresponse(self):
487487
'someSite1': False})
488488

489489

490+
class TestGetNodesId(unittest.TestCase):
491+
492+
def test_getNodesId(self):
493+
class MockResponseStringIo:
494+
def __init__(self, *args, **kwargs):
495+
self.response = None
496+
497+
def request(self, *args, **kwargs):
498+
self.response = {"phedex": {
499+
"node": [
500+
{
501+
"name": "someSite",
502+
"id": "someId",
503+
},
504+
{
505+
"name": "someSite1",
506+
"id": "someId1",
507+
},
508+
],
509+
"type": "xfer"
510+
}}
511+
512+
def getresponse(self):
513+
return ContextualStringIO(json.dumps(self.response))
514+
515+
from WmAgentScripts.utils import getNodesId
516+
with patch('WmAgentScripts.utils.make_x509_conn', MockResponseStringIo):
517+
response = getNodesId(
518+
url='http://someurl.com/'
519+
)
520+
self.assertDictEqual(
521+
response, {
522+
'someSite': 'someId',
523+
'someSite1': 'someId1'})
524+
525+
490526
if __name__ == '__main__':
491527
unittest.main()

0 commit comments

Comments
 (0)