Esempio n. 1
0
 def test_insights_config_default_port(self):
     """Testing insights configure default port."""
     sys.argv = ["/bin/qpc", "insights", "config", "--host", "console.insights.test"]
     CLI().main()
     config = read_insights_config()
     self.assertEqual(config["host"], "console.insights.test")
     self.assertEqual(config["port"], DEFAULT_PORT_INSIGHTS_CONFIG)
     self.assertEqual(config["use_http"], DEFAULT_USE_HTTP_INSIGHTS_CONFIG)
Esempio n. 2
0
 def test_insights_config_default_host(self):
     """Testing insights configure default host."""
     sys.argv = ["/bin/qpc", "insights", "config", "--port", "200"]
     CLI().main()
     config = read_insights_config()
     self.assertEqual(config["host"], DEFAULT_HOST_INSIGHTS_CONFIG)
     self.assertEqual(config["port"], 200)
     self.assertEqual(config["use_http"], DEFAULT_USE_HTTP_INSIGHTS_CONFIG)
Esempio n. 3
0
    def test_invalid_configuration(self):
        """Test reading bad JSON on cli start."""
        write_insights_config({})

        config = read_insights_config()
        self.assertEqual(config["host"], DEFAULT_HOST_INSIGHTS_CONFIG)
        self.assertEqual(config["port"], DEFAULT_PORT_INSIGHTS_CONFIG)
        self.assertEqual(config["use_http"], DEFAULT_USE_HTTP_INSIGHTS_CONFIG)
Esempio n. 4
0
    def _get_base_url(self):
        insights_config = read_insights_config()

        if insights_config["use_http"]:
            protocol = "http://"
        else:
            protocol = "https://"
        host = insights_config["host"]
        port = insights_config["port"]

        base_url = f"{protocol}{host}:{port}"
        return base_url
Esempio n. 5
0
 def test_success_config_insights(self):
     """Testing insights configure green path."""
     sys.argv = [
         "/bin/qpc",
         "insights",
         "config",
         "--host",
         "console.insights.test",
         "--port",
         "200",
         "--use-http",
     ]
     CLI().main()
     config = read_insights_config()
     self.assertEqual(config["host"], "console.insights.test")
     self.assertEqual(config["port"], 200)
     self.assertEqual(config["use_http"], True)
Esempio n. 6
0
 def test_success_default_config_no_args(self):
     """Testing if method returns default config dict when no arguments."""
     config = read_insights_config()
     self.assertDictEqual(config, DEFAULT_INSIGHTS_CONFIG)
     self.assertFalse(os.path.exists(utils.INSIGHTS_CONFIG))