Skip to content

Commit 8dc71ed

Browse files
committed
Ensure that missing attrs raise an error
1 parent fd894f7 commit 8dc71ed

5 files changed

Lines changed: 31 additions & 0 deletions

File tree

tests/resources/test_company.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import pytest
22

33
from userlist.resources.company import Company
4+
from userlist.resources.relationship import Relationship
45

56

67
def test_company_creation_with_basic_fields():
@@ -28,3 +29,9 @@ def test_company_creation_with_none_data():
2829
def test_company_creation_with_string():
2930
company = Company("company-123")
3031
assert company.data["identifier"] == "company-123"
32+
33+
34+
def test_company_missing_attr():
35+
company = Company({"identifier": "company-123"})
36+
with pytest.raises(AttributeError):
37+
_ = company.non_existent_attribute

tests/resources/test_event.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,9 @@ def test_event_creation_with_all_fields():
2828
def test_event_creation_with_none_data():
2929
with pytest.raises(ValueError, match="data parameter is required"):
3030
Event(None)
31+
32+
33+
def test_event_missing_attr():
34+
event = Event({"name": "logged_in"})
35+
with pytest.raises(AttributeError):
36+
_ = event.non_existent_attribute

tests/resources/test_message.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,9 @@ def test_message_creation_with_all_fields():
2525
def test_message_creation_with_none_data():
2626
with pytest.raises(ValueError, match="data parameter is required"):
2727
Message(None)
28+
29+
30+
def test_message_missing_attr():
31+
message = Message({"template": "welcome_email"})
32+
with pytest.raises(AttributeError):
33+
_ = message.non_existent_attribute

tests/resources/test_relationship.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,9 @@ def test_relationship_creation_with_all_fields():
2424
def test_relationship_creation_with_none_data():
2525
with pytest.raises(ValueError, match="data parameter is required"):
2626
Relationship(None)
27+
28+
29+
def test_relationship_missing_attr():
30+
relationship = Relationship({"user": "user-123", "company": "company-123"})
31+
with pytest.raises(AttributeError):
32+
_ = relationship.non_existent_attribute

tests/resources/test_user.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,9 @@ def test_user_creation_with_none_data():
2727
def test_user_creation_with_string():
2828
user = User("user-123")
2929
assert user.identifier == "user-123"
30+
31+
32+
def test_user_missing_attr():
33+
user = User({"identifier": "user-123"})
34+
with pytest.raises(AttributeError):
35+
_ = user.non_existent_attribute

0 commit comments

Comments
 (0)