Esempio n. 1
0
def send_tweet(text,link,img_url):
    '''
    rdict={}
    rdict['client_id']=cid
    rdict['client_secret']=cid
    rdict['code']=access_token
    rdict['redirect_uri']='http://www.kwantm.com'
    rdict['grant_type']='authorization_code'
    resp=requests.post('https://api.bufferapp.com/1/oauth2/token.json',data=rdict)
    print resp
    
    rdict={'access_token':access_token}
    resp=requests.get('https://api.bufferapp.com/1/user.json',data=rdict)
    print resp.text
    print resp
    '''
    api = API(client_id=cid,
          client_secret=csec,
          access_token=access_token)
    #print api
    profiles = Profiles(api=api).all()
    profile_id=profiles[1].id
    #print profile_id
    media={}
    media['link']=link
    media['picture']=img_url

    updates=Updates(api,profile_id)
    updates.new(text=text,shorten=True,now=True,media=media)
    profile_id=profiles[1].id
    updates=Updates(api,profile_id)
    updates.new(text=text,shorten=True,now=True,media=media)
Esempio n. 2
0
def test_updates_manager_new_update():
  '''
    Test update creation
  '''

  mocked_api = MagicMock()
  mocked_api.post.return_value = {'updates': [{'text': 'hey'}]}

  updates = Updates(api=mocked_api, profile_id=1)
  update = updates.new("hey")

  data = "text=hey&profile_ids[]=1&"
  mocked_api.post.assert_called_once_with(url='updates/create.json', data=data)

  assert_update = Update(api=mocked_api, raw_response={'text': 'hey'})
  eq_(update, assert_update)
  assert assert_update in updates
def test_updates_manager_new_update():
    """
        Test update creation
    """

    mocked_api = MagicMock()
    mocked_api.post.return_value = {"updates": [{"text": "hey"}]}

    updates = Updates(api=mocked_api, profile_id=1)
    update = updates.new("hey")

    data = "text=hey&profile_ids[]=1&"
    mocked_api.post.assert_called_once_with(url="updates/create.json",
                                            data=data)

    assert_update = Update(api=mocked_api, raw_response={"text": "hey"})
    assert update == assert_update
    assert assert_update in updates
Esempio n. 4
0
def test_updates_manager_new_update():
    '''
    Test update creation
  '''

    mocked_api = MagicMock()
    mocked_api.post.return_value = {'updates': [{'text': 'hey'}]}

    updates = Updates(api=mocked_api, profile_id=1)
    update = updates.new("hey")

    data = "text=hey&profile_ids[]=1&"
    mocked_api.post.assert_called_once_with(url='updates/create.json',
                                            data=data)

    assert_update = Update(api=mocked_api, raw_response={'text': 'hey'})
    eq_(update, assert_update)
    assert assert_update in updates