Beispiel #1
0
    def test_render__remote(self):
        source = Root()
        config = Config()
        config["output"]["componants"] = "remote"

        template_dir = self.template.env.loader.searchpath[0]
        if os.path.exists(
                os.path.join(template_dir, "resource", "js", "combined.js")):
            shutil.move(
                os.path.join(template_dir, "resource", "js", "combined.js"),
                "/tmp/apidoc_combined.js")

        try:
            self.template.output = os.path.join(self.temp_dir, "foo",
                                                "index.html")
            self.template.render(source, config)

            files = [f for f in os.listdir(os.path.join(self.temp_dir, "foo"))]
            self.assertIn("index.html", files)
            self.assertIn("font", files)
            self.assertIn("css", files)
            self.assertIn("js", files)
            files_js = [
                f for f in os.listdir(os.path.join(self.temp_dir, "foo", "js"))
            ]
            self.assertNotIn("jquery.min.js", files_js)
        finally:
            if os.path.exists("/tmp/apidoc_combined.js"):
                shutil.move(
                    "/tmp/apidoc_combined.js",
                    os.path.join(template_dir, "resource", "js",
                                 "combined.js"))
Beispiel #2
0
    def test_validate(self):
        config = Config()
        config["output"]["componants"] = "local"
        config["output"]["layout"] = "default"
        config["input"]["locations"] = [os.path.dirname(__file__), __file__]
        config["input"]["arguments"] = {"foo": "bar"}

        self.config.validate(config)
Beispiel #3
0
    def test_create_from_config(self):
        config = Config()

        response = self.template.create_from_config(config)

        self.assertIsInstance(response, TemplateService)
        self.assertEqual('default.html', response.input)
        self.assertEqual('stdout', response.output)
Beispiel #4
0
    def test_render__output(self):
        source = Root()
        config = Config()

        self.template.output = "stdout"

        out = StringIO()
        self.template.render(source, config, out=out)
        output = out.getvalue().strip()

        files = [f for f in os.listdir(self.temp_dir)]
        self.assertEqual(0, len(files))
        self.assertNotEqual(0, len(output))
Beispiel #5
0
    def test_render__template(self):
        source = Root()
        config = Config()
        config["output"]["template"] = __file__

        self.template.output = os.path.join(self.temp_dir, "index.html")
        self.template.render(source, config)

        files = [f for f in os.listdir(os.path.join(self.temp_dir))]
        self.assertIn("index.html", files)
        self.assertNotIn("font", files)
        self.assertNotIn("css", files)
        self.assertNotIn("js", files)
Beispiel #6
0
    def test_render__remote(self):
        source = Root()
        config = Config()
        config["output"]["componants"] = "remote"

        self.template.output = os.path.join(self.temp_dir, "foo", "index.html")
        self.template.render(source, config)
        self.template.render(source, config)

        files = [f for f in os.listdir(os.path.join(self.temp_dir, "foo"))]
        self.assertIn("index.html", files)
        self.assertIn("font", files)
        self.assertIn("css", files)
        self.assertIn("js", files)
        files_js = [f for f in os.listdir(os.path.join(self.temp_dir, "foo", "js"))]
        self.assertNotIn("jquery.min.js", files_js)
Beispiel #7
0
    def test_get_template_from_config__file(self):
        config = Config()
        config["output"]["template"] = __file__
        response = self.config.get_template_from_config(config)

        self.assertIsNotNone(response)
Beispiel #8
0
    def test_get_template_from_config__default(self):
        config = Config()
        config["output"]["template"] = "default"
        response = self.config.get_template_from_config(config)

        self.assertIsNotNone(response)
Beispiel #9
0
 def test_validate__empty(self):
     self.config.validate(Config())
Beispiel #10
0
 def test_validate__wrong_arguments(self):
     config = Config()
     config["input"]["arguments"] = ["bla"]
     with self.assertRaises(ValueError):
         self.config.validate(config)
Beispiel #11
0
 def test_validate__wrong_file(self):
     config = Config()
     config["input"]["locations"] = ["bla"]
     with self.assertRaises(ValueError):
         self.config.validate(config)
Beispiel #12
0
 def test_validate__wrong_layout(self):
     config = Config()
     config["output"]["layout"] = "bla"
     with self.assertRaises(ValueError):
         self.config.validate(config)
Beispiel #13
0
def before_scenario(context, scenario):
    context.temp_dir = tempfile.mkdtemp()
    context.conf_files = []
    context.object_config = Config()
Beispiel #14
0
 def test_validate__wrong_directories(self):
     config = Config()
     config["input"]["directories"] = ["bla"]
     with self.assertRaises(ValueError):
         self.config.validate(config)