Skip to content

Commit

Permalink
User-set timestamps now assumed to be in milliseconds
Browse files Browse the repository at this point in the history
  • Loading branch information
fblundun committed Apr 22, 2014
1 parent 98a5244 commit 86d5e5f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions snowplow_tracker/payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ def set_timestamp(self, tstamp=None):
:param tstamp: Timestamp value
"""
if tstamp is None:
tstamp = time.time()
if tstamp and isinstance(tstamp, (int, float)):
value = int(tstamp * 1000)
value = int(time.time() * 1000)
elif tstamp and isinstance(tstamp, (int, float)):
value = int(tstamp)
else:
value = tstamp
self.context["dtm"] = value
Expand Down
4 changes: 2 additions & 2 deletions snowplow_tracker/test/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_integration_ecommerce_transaction_item(self):
def test_integration_ecommerce_transaction(self):
t = tracker.Tracker("localhost")
with HTTMock(pass_response_content):
t.track_ecommerce_transaction("6a8078be", 45, city="London", currency="GBP", items=
t.track_ecommerce_transaction("6a8078be", 35, city="London", currency="GBP", items=
[{
"sku": "pbz0026",
"price": 20,
Expand All @@ -80,7 +80,7 @@ def test_integration_ecommerce_transaction(self):
"quantity": 1
}])

expected_fields = {"e": "tr", "tr_id": "6a8078be", "tr_tt": "45", "tr_ci": "London", "tr_cu": "GBP"}
expected_fields = {"e": "tr", "tr_id": "6a8078be", "tr_tt": "35", "tr_ci": "London", "tr_cu": "GBP"}
for key in expected_fields:
self.assertEquals(from_querystring(key, querystrings[-3]), expected_fields[key])

Expand Down
2 changes: 1 addition & 1 deletion snowplow_tracker/test/unit/test_payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def test_set_timestamp_2(self):

def test_set_timestamp(self):
p = payload.Payload()
p.set_timestamp(12345654321)
p.set_timestamp(12345654321000)
self.assertEquals(p.context["dtm"], 12345654321000)

def test_add_unstruct_1(self):
Expand Down
2 changes: 1 addition & 1 deletion snowplow_tracker/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def http_get(self, payload):
r = requests.get(self.collector_uri, params=payload.context)
code = r.status_code
if code in HTTP_ERRORS:
return (False, "Host [" + r.url + "] not found (possible connectivity error")
return (False, "Host [" + r.url + "] not found (possible connectivity error)")
elif code < 0 or code > 600:
return (False, code)
elif code >= 400 and code < 500:
Expand Down

0 comments on commit 86d5e5f

Please sign in to comment.