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

Commit c10a950

Browse files
committed
add unittests for utils.getConfigurationFile
1 parent 56858c5 commit c10a950

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/test_utils.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,5 +597,33 @@ def getresponse(self):
597597
self.assertFalse(response)
598598

599599

600+
class TestGetConfigurationFile(unittest.TestCase):
601+
602+
def setUp(self):
603+
class MockResponseStringIo:
604+
605+
def __init__(self, *args, **kwargs):
606+
self.response = None
607+
608+
def request(self, *args, **kwargs):
609+
self.response = "Test1 line 1\nTest2 line 2\nTest3 line 3"
610+
611+
def getresponse(self):
612+
return ContextualStringIO(self.response)
613+
614+
self.mockresponse = MockResponseStringIo
615+
616+
def test_getConfigurationFile(self):
617+
from WmAgentScripts.utils import getConfigurationFile, getConfigurationLine
618+
619+
with patch('WmAgentScripts.utils.make_x509_conn', self.mockresponse):
620+
response = getConfigurationFile(
621+
url='http://someurl.com/',
622+
cacheid='cacheid'
623+
)
624+
self.assertEqual(
625+
response, "Test1 line 1\nTest2 line 2\nTest3 line 3")
626+
627+
600628
if __name__ == '__main__':
601629
unittest.main()

0 commit comments

Comments
 (0)