Exemplo n.º 1
0
class ModuleHelperTestCase(unittest.TestCase):
    def setUp(self):
        class MockModule:
            pass

        fields = [
            "name", "upstream_url", "request_host", "uris", "strip_uri",
            "preserve_host"
        ]
        self.helper = ModuleHelper(fields)
        self.module = MockModule()
        self.module.params = {
            "kong_admin_uri": mock_kong_admin_url,
            "name": "mockbin",
            "request_host": "mockbin.com",
            "uris": "/mockbin",
            "strip_uri": True,
            "preserve_host": False,
            "upstream_url": "http://mockbin.com",
            "state": "present"
        }

    def test_prepare_inputs(self):

        url, data, state = self.helper.prepare_inputs(self.module)

        assert url == mock_kong_admin_url
        assert state == "present"
        for field in self.helper.fields:
            value = data.get(field, None)
            assert value is not None, \
             "Expect field {} to be set. Actual value was {}" . format (field, value)
Exemplo n.º 2
0
    def setUp(self):
        class MockModule:
            pass

        fields = [
            "name", "upstream_url", "request_host", "uris", "strip_uri",
            "preserve_host"
        ]
        self.helper = ModuleHelper(fields)
        self.module = MockModule()
        self.module.params = {
            "kong_admin_uri": mock_kong_admin_url,
            "name": "mockbin",
            "request_host": "mockbin.com",
            "uris": "/mockbin",
            "strip_uri": True,
            "preserve_host": False,
            "upstream_url": "http://mockbin.com",
            "state": "present"
        }
Exemplo n.º 3
0
    def setUp(self):
        class MockModule:
            pass

        fields = [
            'name', 'upstream_url', 'request_host', 'uris', 'strip_uri',
            'preserve_host'
        ]

        self.helper = ModuleHelper(fields)
        self.module = MockModule()
        self.module.params = {
            "kong_admin_uri": "http://192.168.99.100:8001",
            "name": "mockbin",
            "upstream_url": "http://mockbin.com",
            "request_host": "mockbin.com"
        }
Exemplo n.º 4
0
	def setUp(self):
		class MockModule: 
			pass
		fields = [
            "name", 
            "upstream_url", 
            "request_host", 
            "request_path", 
            "strip_request_path", 
            "preserve_host"
        ]
		self.helper = ModuleHelper(fields)
		self.module = MockModule()
		self.module.params = {
			"kong_admin_uri": mock_kong_admin_url,
            "name": "mockbin", 
            "request_host": "mockbin.com", 
            "request_path": "/mockbin", 
            "strip_request_path": True, 
            "preserve_host": False,
            "upstream_url": "http://mockbin.com",
			"state": "present"
		}
Exemplo n.º 5
0
class ModuleHelperTestCase(unittest.TestCase):

	def setUp(self):
		class MockModule: 
			pass
		fields = [
            "name", 
            "upstream_url", 
            "request_host", 
            "request_path", 
            "strip_request_path", 
            "preserve_host"
        ]
		self.helper = ModuleHelper(fields)
		self.module = MockModule()
		self.module.params = {
			"kong_admin_uri": mock_kong_admin_url,
            "name": "mockbin", 
            "request_host": "mockbin.com", 
            "request_path": "/mockbin", 
            "strip_request_path": True, 
            "preserve_host": False,
            "upstream_url": "http://mockbin.com",
			"state": "present"
		}

	def test_prepare_inputs(self):
		
		url, data, state = self.helper.prepare_inputs(self.module)

		assert url == mock_kong_admin_url
		assert state == "present"
		for field in self.helper.fields:
			value = data.get(field, None)
			assert value is not None, \
				"Expect field {} to be set. Actual value was {}" . format (field, value)