Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion snowplow_tracker/subject.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ def set_viewport(self, width: int, height: int) -> "Subject":
def set_color_depth(self, depth: int) -> "Subject":
"""
:param depth: Depth of the color on the screen
:type depth: int
:type depth: int,>0
:rtype: subject
"""
greater_than(depth, 0)
self.standard_nv_pairs["cd"] = depth
return self

Expand Down
8 changes: 8 additions & 0 deletions snowplow_tracker/test/unit/test_subject.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ def test_subject_1(self) -> None:
with pytest.raises(KeyError):
s.standard_nv_pairs["tnuid"]

def test_set_color_depth_rejects_non_positive(self) -> None:
s = _subject.Subject()
with pytest.raises(ValueError):
s.set_color_depth(0)
with pytest.raises(ValueError):
s.set_color_depth(-1)
s.set_color_depth(1) # positive value must succeed

def test_combine_subject(self) -> None:
s = _subject.Subject()
s.set_color_depth(10)
Expand Down
Loading