Example #1
0
    def test_config_get(self):
        """Test get"""

        _cfg = configparser.RawConfigParser()
        _cfg.add_section("TestApp")
        cfg = mock.create_autospec(Configuration)
        cfg._log = logging.getLogger("config_get")
        cfg._config = _cfg
        cfg.jobtype = "TestApp2"

        param = Configuration.get(cfg, "endpoint")
        self.assertIsNone(param)

        cfg.jobtype = "TestApp"
        param = Configuration.get(cfg, "endpoint")
        self.assertIsNone(param)

        cfg._config.set("TestApp", "endpoint", "http://test")
        param = Configuration.get(cfg, "endpoint")
        self.assertEqual(param, "http://test")

        param = Configuration.get(cfg, 42)
        self.assertIsNone(param)
    def test_config_get(self):
        """Test get"""

        _cfg = configparser.RawConfigParser()
        _cfg.add_section("TestApp")
        cfg = mock.create_autospec(Configuration)
        cfg._log = logging.getLogger("config_get")
        cfg._config = _cfg
        cfg.jobtype = "TestApp2"

        param = Configuration.get(cfg, "endpoint")
        self.assertIsNone(param)

        cfg.jobtype = "TestApp"
        param = Configuration.get(cfg, "endpoint")
        self.assertIsNone(param)

        cfg._config.set("TestApp", "endpoint", "http://test")
        param = Configuration.get(cfg, "endpoint")
        self.assertEqual(param, "http://test")

        param = Configuration.get(cfg, 42)
        self.assertIsNone(param)