Skip to content

Commit

Permalink
Move event_timestamp into ChangeEventsAPISession
Browse files Browse the repository at this point in the history
  • Loading branch information
hunner committed Apr 22, 2021
1 parent 4ae7cd3 commit bd634df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions pdpyras.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,10 +629,6 @@ def user_agent(self):
sys.version_info.minor
)

@property
def event_timestamp(self):
return datetime.now(timezone.utc).isoformat()

class EventsAPISession(PDSession):

"""
Expand Down Expand Up @@ -811,6 +807,10 @@ class ChangeEventsAPISession(PDSession):
def auth_header(self):
return {}

@property
def event_timestamp(self):
return datetime.now(timezone.utc).isoformat()

def prepare_headers(self, method):
"""Add user agent and content type headers for Change Events API requests."""
headers = deepcopy(self.headers)
Expand Down
4 changes: 2 additions & 2 deletions test_pdpyras.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ def test_truncated_token(self):


class ChangeEventsSessionTest(SessionTest):
@patch('pdpyras.PDSession.event_timestamp', datetime.datetime(2020, 3, 25).replace(tzinfo=datetime.timezone.utc).isoformat())
@patch('pdpyras.ChangeEventsAPISession.event_timestamp', datetime.datetime(2020, 3, 25).replace(tzinfo=datetime.timezone.utc).isoformat())
def test_submit_change_event(self):
sess = pdpyras.ChangeEventsAPISession('routingkey')
parent = MagicMock()
Expand Down Expand Up @@ -655,7 +655,7 @@ def test_submit_change_event(self):
'links': [{'href':'https://http.cat/502.jpg'}]
},
parent.request.call_args[1]['json'])
@patch('pdpyras.PDSession.event_timestamp', datetime.datetime(2020, 3, 25).replace(tzinfo=datetime.timezone.utc).isoformat())
@patch('pdpyras.ChangeEventsAPISession.event_timestamp', datetime.datetime(2020, 3, 25).replace(tzinfo=datetime.timezone.utc).isoformat())
def test_submit_lite_change_event(self):
sess = pdpyras.ChangeEventsAPISession('routingkey')
parent = MagicMock()
Expand Down

0 comments on commit bd634df

Please sign in to comment.