예제 #1
0
파일: test_routing.py 프로젝트: zxy-zxy/hug
class TestCLIRouter(TestRouter):
    """A collection of tests to ensure the CLIRouter object works as expected"""
    route = CLIRouter(name='cli',
                      version=1,
                      doc='Hi there!',
                      transform='transform',
                      output='output')

    def test_name(self):
        """Test to ensure the name can be replaced on the fly"""
        new_route = self.route.name('new name')
        assert new_route != self.route
        assert new_route.route['name'] == 'new name'
        assert new_route.route['transform'] == 'transform'
        assert new_route.route['output'] == 'output'

    def test_version(self):
        """Test to ensure the version can be replaced on the fly"""
        new_route = self.route.version(2)
        assert new_route != self.route
        assert new_route.route['version'] == 2
        assert new_route.route['transform'] == 'transform'
        assert new_route.route['output'] == 'output'

    def test_doc(self):
        """Test to ensure the documentation can be replaced on the fly"""
        new_route = self.route.doc('FAQ')
        assert new_route != self.route
        assert new_route.route['doc'] == 'FAQ'
        assert new_route.route['transform'] == 'transform'
        assert new_route.route['output'] == 'output'
예제 #2
0
class TestCLIRouter(TestRouter):
    """A collection of tests to ensure the CLIRouter object works as expected"""

    route = CLIRouter(
        name="cli", version=1, doc="Hi there!", transform="transform", output="output"
    )

    def test_name(self):
        """Test to ensure the name can be replaced on the fly"""
        new_route = self.route.name("new name")
        assert new_route != self.route
        assert new_route.route["name"] == "new name"
        assert new_route.route["transform"] == "transform"
        assert new_route.route["output"] == "output"

    def test_version(self):
        """Test to ensure the version can be replaced on the fly"""
        new_route = self.route.version(2)
        assert new_route != self.route
        assert new_route.route["version"] == 2
        assert new_route.route["transform"] == "transform"
        assert new_route.route["output"] == "output"

    def test_doc(self):
        """Test to ensure the documentation can be replaced on the fly"""
        new_route = self.route.doc("FAQ")
        assert new_route != self.route
        assert new_route.route["doc"] == "FAQ"
        assert new_route.route["transform"] == "transform"
        assert new_route.route["output"] == "output"
예제 #3
0
파일: test_route.py 프로젝트: wujm2007/hug
 def test_cli(self):
     """Test to ensure you can dynamically create a CLI route attached to a hug API"""
     assert self.router.cli().route == CLIRouter(api=api).route