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

Commit 8d5b1ff

Browse files
committed
add unittests for utils.getWMStats
1 parent 8745af1 commit 8d5b1ff

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

tests/test_utils.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,5 +429,24 @@ def test_read_file(self):
429429
self.assertEqual(textcontent, '{}')
430430

431431

432+
class TestGetWMStats(unittest.TestCase):
433+
434+
def test_getWMStats(self):
435+
class MockResponseStringIo:
436+
def __init__(self, *args, **kwargs):
437+
self.response = None, 404
438+
439+
def request(self, *args, **kwargs):
440+
self.response = {"result": [200]}
441+
442+
def getresponse(self):
443+
return ContextualStringIO(json.dumps(self.response))
444+
445+
from WmAgentScripts.utils import getWMStats
446+
with patch('WmAgentScripts.utils.make_x509_conn', MockResponseStringIo):
447+
response = getWMStats(url='http://someurl.com/')
448+
self.assertEqual(response, 200)
449+
450+
432451
if __name__ == '__main__':
433452
unittest.main()

0 commit comments

Comments
 (0)