def test_update_edit_params(): ''' Test basic update editing with all the params ''' mocked_api = MagicMock() mocked_api.post.return_value = { 'update': {'id': 1, 'text': 'hey!'} } update = Update(mocked_api, raw_response={'id':1, 'text': 'ola!'}) new_update = update.edit(text='hey!', media={'link':'w'}, utc="a", now=True) assert_update = Update(mocked_api, raw_response={'id':1, 'text': 'hey!'}) post_data = 'text=hey!&now=True&utc=a&media[link]=w&' mocked_api.post.assert_called_once_with(url='updates/1/update.json', data=post_data) eq_(new_update, assert_update)
def test_update_edit(): ''' Test basic update editing ''' mocked_api = MagicMock() mocked_api.post.return_value = { 'update': {'id': 1, 'text': 'hey!'} } update = Update(mocked_api, raw_response={'id':1, 'text': 'ola!'}) new_update = update.edit(text='hey!') assert_update = Update(mocked_api, raw_response={'id':1, 'text': 'hey!'}) post_data = 'text=hey!&' mocked_api.post.assert_called_once_with(url='updates/1/update.json', data=post_data) eq_(new_update, assert_update)
def edit(self, j, newTitle=''): logging.info("New title %s", newTitle) thePost = self.obtainPostData(j) oldTitle = thePost[0] if not newTitle: newTitle = self.reorderTitle(oldTitle) profile = self.getProfile() logging.info("servicename %s" %self.service) from buffpy.models.update import Update i=0 update = Update(api=self.client, id=profile.updates.pending[j].id) print(update) update = update.edit(text=newTitle) title = oldTitle update = "Changed "+title+" with "+newTitle logging.info("Res update %s" % update) return(update)
def editl(self, j, newLink=''): logging.info("New link %s", newLink) thePost = self.obtainPostData(j) oldLink = thePost[1] profile = self.getProfile() logging.info("servicename %s" %self.service) from buffpy.models.update import Update i=0 update = Update(api=self.client, id=profile.updates.pending[j].id) print(update) # media = {'original': newLink } return('Not implemented!') update = update.edit(text=newTitle) title = oldTitle update = "Changed "+title+" with "+newTitle logging.info("Res update %s" % update) return(update)
def test_update_edit(): """ Test basic update editing """ mocked_api = MagicMock() mocked_api.post.return_value = {"update": {"id": 1, "text": "hey!🏳️🌈"}} update = Update(mocked_api, raw_response={"id": 1, "text": "ola!"}) new_update = update.edit(text="hey!🏳️🌈") assert_update = Update(mocked_api, raw_response={ "id": 1, "text": "hey!🏳️🌈" }) post_data = "text=hey!🏳️🌈&" mocked_api.post.assert_called_once_with(url="updates/1/update.json", data=post_data) assert new_update == assert_update
def test_update_edit_params(): """ Test basic update editing with all the params """ mocked_api = MagicMock() mocked_api.post.return_value = {"update": {"id": 1, "text": "hey!🏳️🌈"}} update = Update(mocked_api, raw_response={"id": 1, "text": "ola!"}) new_update = update.edit(text="hey!🏳️🌈", media={"link": "w"}, utc="a", now=True) assert_update = Update(mocked_api, raw_response={ "id": 1, "text": "hey!🏳️🌈" }) post_data = "text=hey!🏳️🌈&now=True&utc=a&media[link]=w&" mocked_api.post.assert_called_once_with(url="updates/1/update.json", data=post_data) assert new_update == assert_update
from buffpy.managers.updates import Updates from buffpy.api import API # check http://bufferapp.com/developers/apps to retrieve a token # or generate one with the example token = 'awesome_token' # instantiate the api object api = API(client_id='client_id', client_secret='client_secret', access_token=token) # retrieve a single update based on an id update = Update(api=api, id='update_id') print(update) # get update's interactions print(update.interactions) # edit update = update.edit(text="Hey!") # publish now update.publish() # move to top update.move_to_top() # delete update.delete()
from buffpy.api import API # check http://bufferapp.com/developers/apps to retrieve a token # or generate one with the example token = "awesome_token" # instantiate the api object api = API(client_id="client_id", client_secret="client_secret", access_token=token) # retrieve a single update based on an id update = Update(api=api, id="update_id") print(update) # get update"s interactions print(update.interactions) # edit update = update.edit(text="Hey!") # publish now update.publish() # move to top update.move_to_top() # delete update.delete()