Beispiel #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
            )
        ]
Beispiel #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),
        ]
Beispiel #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),
        ]
Beispiel #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),
        ]
Beispiel #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),
        ]
Beispiel #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),
        ]
Beispiel #8
0
    def test_ignores_comment_lines(self, lines):
        result = parse(["#" + l for l in lines])

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

        assert result == []
Beispiel #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)
Beispiel #11
0
    def test_ignores_comment_lines(self, lines):
        result = parse(["#" + l for l in lines])

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

        assert result == []
Beispiel #13
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),
        ]
Beispiel #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
Beispiel #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
Beispiel #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)
Beispiel #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)
Beispiel #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)