2015-02-24 10:38:57 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
# Copyright (C) 2015 GNS3 Technologies Inc.
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
from gns3server.web.documentation import Documentation
|
|
|
|
from gns3server.handlers import *
|
|
|
|
from gns3server.web.route import Route
|
|
|
|
|
|
|
|
|
|
|
|
def test_documentation_write(tmpdir):
|
|
|
|
os.makedirs(str(tmpdir / "api/examples"))
|
2016-03-07 14:01:35 +00:00
|
|
|
with open(str(tmpdir / "api/examples/hypervisor_post_projectsprojectidvirtualboxvms.txt"), "w+") as f:
|
2015-02-24 10:38:57 +00:00
|
|
|
f.write("curl test")
|
|
|
|
|
|
|
|
Documentation(Route, str(tmpdir)).write()
|
|
|
|
|
|
|
|
assert os.path.exists(str(tmpdir / "api"))
|
2016-03-07 14:01:35 +00:00
|
|
|
assert os.path.exists(str(tmpdir / "api" / "v1" / "hypervisor"))
|
|
|
|
assert os.path.exists(str(tmpdir / "api" / "v1" / "hypervisor" / "virtualbox.rst"))
|
|
|
|
assert os.path.exists(str(tmpdir / "api" / "v1" / "hypervisor" / "virtualbox"))
|
|
|
|
assert os.path.exists(str(tmpdir / "api" / "v1" / "hypervisor" / "virtualbox" / "virtualboxvms.rst"))
|
|
|
|
with open(str(tmpdir / "api" / "v1" / "hypervisor" / "virtualbox" / "projectsprojectidvirtualboxvms.rst")) as f:
|
2015-02-24 10:38:57 +00:00
|
|
|
content = f.read()
|
|
|
|
assert "Sample session" in content
|
2016-03-07 14:01:35 +00:00
|
|
|
assert "literalinclude:: ../../../examples/hypervisor_post_projectsprojectidvirtualboxvms.txt" in content
|
2016-03-04 16:50:17 +00:00
|
|
|
|
|
|
|
assert os.path.exists(str(tmpdir / "api" / "v1" / "controller" / "server.rst"))
|