-
Notifications
You must be signed in to change notification settings - Fork 27
/
test_app.py
54 lines (40 loc) · 1.42 KB
/
test_app.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
import pytest
from address_book import app, AddressBook, Address
class TestAddressBook(object):
def test_load_from_file(self):
pass
def test_get_address(self):
address = Address(
id=0,
name="Toto",
address="Tata",
email="[email protected]",
phone_numbers=["555 555-5555"]
)
book = AddressBook([address])
a = book.get_address(0)
assert a.id == 0
assert a.name == "Toto"
assert a.address == "Tata"
assert a.email == "[email protected]"
assert a.phone_numbers == ["555 555-5555"]
def test_load_from_file(self):
#TODO : test qui assure que le fichier JSON est lu et que la classe est instanciée
pass
class TestApp(object):
def test_index(self):
#TODO : rajouter un test qui assure que l'index retourne un 200 avec le nom des personnes du carnet d'adresse
pass
def test_address(self):
client = app.test_client()
response = client.get("/0")
assert response.status_code == 200
assert b"Gaston Lagaffe" in response.data
def test_address_does_not_exist(self):
client = app.test_client()
response = client.get("/999")
assert response.status_code == 404
def test_new_address(self):
client = app.test_client()
response = client.get("/new")
assert response.status_code == 200