Skip to content

Commit b0f6f88

Browse files
authored
Add unit tests for Emails class functionality
1 parent 71f5b39 commit b0f6f88

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

Week05/test_emails_yasin_soytas.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import pytest
2+
from emails_yasin_soytas import Emails
3+
4+
5+
def test_class_exists():
6+
assert Emails is not None
7+
8+
9+
def test_is_subclass_of_list():
10+
assert issubclass(Emails, list)
11+
12+
13+
def test_empty_constructor():
14+
e = Emails()
15+
assert isinstance(e, list)
16+
assert len(e) == 0
17+
18+
19+
def test_valid_emails_added():
20+
emails = Emails(["test@example.com", "user@mail.com"])
21+
assert "test@example.com" in emails
22+
assert "user@mail.com" in emails
23+
assert len(emails) == 2
24+
25+
26+
def test_emails_lowercase():
27+
emails = Emails(["TEST@EXAMPLE.COM"])
28+
assert "test@example.com" in emails
29+
30+
31+
def test_no_duplicates():
32+
emails = Emails(["test@example.com", "TEST@EXAMPLE.COM"])
33+
assert len(emails) == 1
34+
35+
36+
def test_invalid_emails_not_added():
37+
emails = Emails(["testexample.com", 123, None, "hello"])
38+
assert len(emails) == 0
39+
40+
41+
def test_mixed_input():
42+
emails = Emails([
43+
"A@A.COM",
44+
"b@b.com",
45+
"invalid",
46+
42,
47+
"a@a.com"
48+
])
49+
assert emails == ["a@a.com", "b@b.com"]
50+
51+
52+
53+
def test_instance_type():
54+
emails = Emails(["x@y.com"])
55+
assert isinstance(emails, Emails)

0 commit comments

Comments
 (0)