Skip to content
This repository has been archived by the owner on Aug 29, 2019. It is now read-only.

Commit

Permalink
move subscriber: modified to include addl parameter
Browse files Browse the repository at this point in the history
Move can accept last_followup_message_number_sent param
  • Loading branch information
Mike Druger committed Dec 6, 2012
1 parent 5a04d00 commit 2fc1886
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 3 additions & 2 deletions aweber_api/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def delete(self):
self.adapter.request('DELETE', self.url, response='status')
return True

def move(self, list_):
def move(self, list_, **kwargs):
"""Invoke the API method to MOVE an entry resource to a
different List.
Expand All @@ -55,8 +55,9 @@ def move(self, list_):
"""
params = {'ws.op': 'move',
'list_link': list_.self_link}
params.update(kwargs)
response = self.adapter.request('POST', self.url, params,
response='headers')
response='headers')

new_resource = response['location']
self._diff = {}
Expand Down
10 changes: 9 additions & 1 deletion tests/test_aweber_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,11 @@ def setUp(self):
self.subscriber = self.aweber.load_from_url(subscriber_url)
self.subscriber._diff['name'] = 'Joe Schmoe'
self.list = self.aweber.load_from_url(new_list_url)
self.move_subscriber()

def move_subscriber(self, **kwargs):
self.aweber.adapter.requests = []
self.resp = self.subscriber.move(self.list)
self.resp = self.subscriber.move(self.list, **kwargs)
self.move_req = self.aweber.adapter.requests[0]
self.get_req = self.aweber.adapter.requests[1]

Expand Down Expand Up @@ -182,6 +184,12 @@ def test_should_refresh_subscriber_resource(self):
def test_should_reset_diff(self):
self.assertEqual(self.subscriber._diff, {})

def test_should_accept_last_followup_message_number_sent(self):
self.move_subscriber(last_followup_message_number_sent=999)
expected_params = {'ws.op': 'move', 'list_link': self.list.self_link,
'last_followup_message_number_sent': 999}

self.assertEqual(self.move_req['data'], expected_params)

class TestSavingSubscriberData(SubscriberTestCase):

Expand Down

0 comments on commit 2fc1886

Please sign in to comment.