-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
PagePing
, PageView
, and StructuredEvent
property getters (c…
…lose #361)
- Loading branch information
Showing
6 changed files
with
104 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import pytest | ||
|
||
from snowplow_tracker.events.page_ping import PagePing | ||
|
||
|
||
class TestPagePing: | ||
def test_getters(self): | ||
pp = PagePing("url", "title", "referrer", 1, 2, 3, 4) | ||
assert pp.page_url == "url" | ||
assert pp.page_title == "title" | ||
assert pp.referrer == "referrer" | ||
assert pp.min_x == 1 | ||
assert pp.max_x == 2 | ||
assert pp.min_y == 3 | ||
assert pp.max_y == 4 | ||
|
||
def test_setters(self): | ||
pp = PagePing("url") | ||
pp.page_title = "title" | ||
pp.referrer = "referrer" | ||
pp.min_x = 1 | ||
pp.max_x = 2 | ||
pp.min_y = 3 | ||
pp.max_y = 4 | ||
assert pp.page_title == "title" | ||
assert pp.referrer == "referrer" | ||
assert pp.min_x == 1 | ||
assert pp.max_x == 2 | ||
assert pp.min_y == 3 | ||
assert pp.max_y == 4 | ||
assert pp.page_url == "url" | ||
|
||
def test_page_url_non_empty_string(self): | ||
pp = PagePing("url") | ||
pp.page_url = "new_url" | ||
assert pp.page_url == "new_url" | ||
with pytest.raises(ValueError): | ||
pp.page_url = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import pytest | ||
|
||
from snowplow_tracker.events.page_view import PageView | ||
|
||
|
||
class TestPageView: | ||
def test_getters(self): | ||
pv = PageView("url", "title", "referrer") | ||
assert pv.page_url == "url" | ||
assert pv.page_title == "title" | ||
assert pv.referrer == "referrer" | ||
|
||
def test_setters(self): | ||
pv = PageView("url", "title", "referrer") | ||
pv.page_url = "new_url" | ||
pv.page_title = "new_title" | ||
pv.referrer = "new_referrer" | ||
assert pv.page_url == "new_url" | ||
assert pv.page_title == "new_title" | ||
assert pv.referrer == "new_referrer" | ||
|
||
def test_page_url_non_empty_string(self): | ||
pv = PageView("url") | ||
pv.page_url = "new_url" | ||
assert pv.page_url == "new_url" | ||
with pytest.raises(ValueError): | ||
pv.page_url = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from snowplow_tracker.events.structured_event import StructuredEvent | ||
|
||
|
||
class TestStructuredEvent: | ||
def test_getters(self): | ||
se = StructuredEvent("category", "action", "label", "property", 1) | ||
assert se.category == "category" | ||
assert se.action == "action" | ||
assert se.label == "label" | ||
assert se.property_ == "property" | ||
assert se.value == 1 | ||
|
||
def test_setters(self): | ||
se = StructuredEvent("category", "action") | ||
se.category = "new_category" | ||
se.action = "new_action" | ||
se.label = "new_label" | ||
se.property_ = "new_property" | ||
se.value = 2 | ||
assert se.category == "new_category" | ||
assert se.action == "new_action" | ||
assert se.label == "new_label" | ||
assert se.property_ == "new_property" | ||
assert se.value == 2 |