示例#1
0
    def test_basic(self):
        result = parse(["/foo exact http://giraffe.com/bar"])

        assert result == [
            Redirect(
                src="/foo", dst="http://giraffe.com/bar", internal=False, prefix=False
            )
        ]
    def test_basic(self):
        result = parse(["/foo exact http://giraffe.com/bar"])

        assert result == [
            Redirect(
                src="/foo", dst="http://giraffe.com/bar", internal=False, prefix=False
            )
        ]
示例#3
0
    def test_basic(self):
        result = parse(['/foo exact http://giraffe.com/bar'])

        assert result == [
            Redirect(src='/foo',
                     dst='http://giraffe.com/bar',
                     internal=False,
                     prefix=False),
        ]
示例#4
0
    def test_multiline(self):
        result = parse(['/foo exact http://giraffe.com/bar',
                        '/bar prefix http://elephant.org/',
                        '/baz/bat internal-exact tapir',
                        '/qux internal-prefix donkey'])

        assert result == [
            Redirect(src='/foo', dst='http://giraffe.com/bar', internal=False, prefix=False),
            Redirect(src='/bar', dst='http://elephant.org/', internal=False, prefix=True),
            Redirect(src='/baz/bat', dst='tapir', internal=True, prefix=False),
            Redirect(src='/qux', dst='donkey', internal=True, prefix=True),
        ]
示例#5
0
    def test_ignores_whitespace(self, data):
        line = [
            data.draw(st.text(alphabet=WHITESPACE)),
            '/foo',
            data.draw(st.text(alphabet=WHITESPACE, min_size=1)),
            'exact',
            data.draw(st.text(alphabet=WHITESPACE, min_size=1)),
            'http://giraffe.com/bar',
            data.draw(st.text(alphabet=WHITESPACE)),
        ]

        result = parse([''.join(line)])

        assert result == [
            Redirect(src='/foo', dst='http://giraffe.com/bar', internal=False, prefix=False),
        ]
示例#6
0
    def test_multiline(self):
        result = parse([
            "/foo exact http://giraffe.com/bar",
            "/bar prefix http://elephant.org/",
            "/baz/bat internal-exact tapir",
            "/qux internal-prefix donkey",
        ])

        assert result == [
            Redirect(src="/foo",
                     dst="http://giraffe.com/bar",
                     internal=False,
                     prefix=False),
            Redirect(src="/bar",
                     dst="http://elephant.org/",
                     internal=False,
                     prefix=True),
            Redirect(src="/baz/bat", dst="tapir", internal=True, prefix=False),
            Redirect(src="/qux", dst="donkey", internal=True, prefix=True),
        ]
示例#7
0
    def test_multiline(self):
        result = parse(
            [
                "/foo exact http://giraffe.com/bar",
                "/bar prefix http://elephant.org/",
                "/baz/bat internal-exact tapir",
                "/qux internal-prefix donkey",
            ]
        )

        assert result == [
            Redirect(
                src="/foo", dst="http://giraffe.com/bar", internal=False, prefix=False
            ),
            Redirect(
                src="/bar", dst="http://elephant.org/", internal=False, prefix=True
            ),
            Redirect(src="/baz/bat", dst="tapir", internal=True, prefix=False),
            Redirect(src="/qux", dst="donkey", internal=True, prefix=True),
        ]
示例#8
0
    def test_ignores_comment_lines(self, lines):
        result = parse(["#" + l for l in lines])

        assert result == []
示例#9
0
    def test_ignores_whitespace_only_lines(self, lines):
        result = parse(lines)

        assert result == []
示例#10
0
 def test_unknown_type_raises(self):
     with pytest.raises(ParseError) as e:
         parse(["/foo magic http://giraffe.com/bar"])
     assert "type" in str(e.value)
示例#11
0
    def test_ignores_comment_lines(self, lines):
        result = parse(["#" + l for l in lines])

        assert result == []
示例#12
0
    def test_ignores_whitespace_only_lines(self, lines):
        result = parse(lines)

        assert result == []
示例#13
0
文件: redirects_test.py 项目: gnott/h
    def test_basic(self):
        result = parse(['/foo exact http://giraffe.com/bar'])

        assert result == [
            Redirect(src='/foo', dst='http://giraffe.com/bar', internal=False, prefix=False),
        ]
示例#14
0
 def test_unknown_type_raises(self):
     with pytest.raises(ParseError) as e:
         parse(['/foo magic http://giraffe.com/bar'])
     assert 'type' in e.value.message
示例#15
0
 def test_misformatted_line_raises(self):
     with pytest.raises(ParseError) as e:
         parse(['/foo exact somethingelse http://giraffe.com/bar'])
     assert 'invalid' in e.value.message
示例#16
0
 def test_misformatted_line_raises(self):
     with pytest.raises(ParseError) as e:
         parse(["/foo exact somethingelse http://giraffe.com/bar"])
     assert "invalid" in str(e.value)
示例#17
0
 def test_unknown_type_raises(self):
     with pytest.raises(ParseError) as e:
         parse(["/foo magic http://giraffe.com/bar"])
     assert "type" in str(e.value)
示例#18
0
 def test_misformatted_line_raises(self):
     with pytest.raises(ParseError) as e:
         parse(["/foo exact somethingelse http://giraffe.com/bar"])
     assert "invalid" in str(e.value)