-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_model.py
40 lines (25 loc) · 1.04 KB
/
test_model.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
from contacts_model import Contact
from typing import Any
Contact.load_db()
def test_contacts_all() -> None:
assert Contact.all()[0].id == 2
assert Contact.all()[0].first == "Carson"
def test_contacts_search() -> None:
assert Contact.search("carson")[0].id == 2
assert Contact.search("carson")[0].first == "Carson"
def test_contacts_validate_pass() -> None:
c: Contact = Contact(None, "Jane", "Doe", "555-555-5555", "[email protected]")
assert c.validate()
def test_contacts_validate_email_missing() -> None:
c: Contact = Contact(None, "Jane", "Doe", "555-555-5555")
assert not c.validate()
def test_contacts_validate_email_not_unique() -> None:
c: Contact = Contact(None, "Jane", "Doe", "555-555-5555" "[email protected]")
assert not c.validate()
def test_contacts_find() -> None:
assert Contact.find(2)
assert not Contact.find(200)
def test_contacts_delete() -> None:
contact: Any | None = Contact.find(Contact.all()[-1].id)
if contact is not None:
assert Contact.delete(contact)