-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_dojo.py
87 lines (75 loc) · 2.73 KB
/
test_dojo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import pytest
from dojo import parse_url
def test_google_example():
url = "http://www.google.com/mail/user=fulano"
result = parse_url(url)
assert "http" == result["protocol"]
assert "www.google.com/mail/user=fulano" == result["dpath"]
assert "" == result["query"]
def test_google_example():
url = "http://www.google.com/mail?user=fulano"
result = parse_url(url)
assert "http" == result["protocol"]
assert "www.google.com/mail" == result["dpath"]
assert "user=fulano" == result["query"]
assert "" == result["user"]
assert "" == result["password"]
def test_sadfasdfasd():
url = "https://sadfasdfasd"
result = parse_url(url)
assert "https" == result["protocol"]
assert "sadfasdfasd" == result["dpath"]
assert "" == result["query"]
assert "" == result["user"]
assert "" == result["password"]
def test_reinaldo_ssh():
url = "ssh://[email protected]"
result = parse_url(url)
assert "ssh" == result["protocol"]
assert "127.0.0.1" == result["dpath"]
assert "" == result["query"]
assert "reinaldo" == result["user"]
assert "" == result["password"]
@pytest.mark.parametrize("url", ["invalida", "pastel", "dojo"])
def test_invalid_url(url):
with pytest.raises(ValueError):
parse_url(url)
def teste_qualquercoisa():
url = "ftp://qualquercoisa"
result = parse_url(url)
assert "ftp" == result["protocol"]
assert "qualquercoisa" == result["dpath"]
assert "" == result["query"]
assert "" == result["user"]
assert "" == result["password"]
def teste_usuariosenha():
url = "ssh://usuario:senha@localhost"
result = parse_url(url)
assert "ssh" == result["protocol"]
assert "localhost" == result["dpath"]
assert "" == result["query"]
assert "usuario" == result["user"]
assert "senha" == result["password"]
def test_automate_bash():
url = (
"https://egghead.io/courses/automate-daily"
"-development-tasks-with-bash?utm_source=d"
"rip&utm_medium=email&utm_term=bash&utm_co"
"ntent=automate-with-bash"
)
result = parse_url(url)
assert "https" == result["protocol"]
assert "egghead.io/courses/automate-daily-development-tasks-with-bash" \
== result["dpath"]
assert "utm_source=drip&utm_medium=email&utm_term=bash&utm_co" \
"ntent=automate-with-bash" == result["query"]
assert "" == result["user"]
assert "" == result["password"]
def teste_usuariosenha_queried():
url = "http://senha:usuario@localhost/?umaquery=1"
result = parse_url(url)
assert "http" == result["protocol"]
assert "localhost/" == result["dpath"]
assert "umaquery=1" == result["query"]
assert "senha" == result["user"]
assert "usuario" == result["password"]