Пример #1
0
def test_links_get_shares():
    """ Should properly retrieve shares. """

    mocked_api = MagicMock()
    mocked_api.get.return_value = {"shares": 123}

    link = Link(api=mocked_api, url="www.google.com")

    assert link["shares"] == 123
    assert link["url"] == "www.google.com"
    assert link.get_shares() == 123

    mocked_api.get.assert_any_call(url="links/shares.json?url=www.google.com")
    assert mocked_api.get.call_count == 2
Пример #2
0
def test_links_get_shares():
  '''
    Test link's shares retrieving method
  '''

  mocked_api = MagicMock()
  mocked_api.get.return_value = {'shares': 123}

  link = Link(api=mocked_api, url='www.google.com')

  eq_(link, {'shares': 123, 'url': 'www.google.com', 'api': mocked_api})
  eq_(link.get_shares(), 123)
  mocked_api.get.assert_any_call(url='links/shares.json?url=www.google.com')
  eq_(mocked_api.get.call_count, 2)
Пример #3
0
def test_links_get_shares():
    '''
    Test link's shares retrieving method
  '''

    mocked_api = MagicMock()
    mocked_api.get.return_value = {'shares': 123}

    link = Link(api=mocked_api, url='www.google.com')

    eq_(link, {'shares': 123, 'url': 'www.google.com', 'api': mocked_api})
    eq_(link.get_shares(), 123)
    mocked_api.get.assert_any_call(url='links/shares.json?url=www.google.com')
    eq_(mocked_api.get.call_count, 2)
Пример #4
0
def test_links_shares():
    """ Should retrieve shares in contructor. """

    mocked_api = MagicMock()
    mocked_api.get.return_value = {"shares": 123}

    link = Link(api=mocked_api, url="www.google.com")

    assert link["shares"] == 123
    assert link["url"] == "www.google.com"
    mocked_api.get.assert_called_once_with(
        url="links/shares.json?url=www.google.com")
Пример #5
0
def test_links_shares():
    '''
    Test link's shares retrieving from constructor
  '''

    mocked_api = MagicMock()
    mocked_api.get.return_value = {'shares': 123}

    link = Link(api=mocked_api, url='www.google.com')

    eq_(link, {'shares': 123, 'url': 'www.google.com', 'api': mocked_api})
    mocked_api.get.assert_called_once_with(
        url='links/shares.json?url=www.google.com')
Пример #6
0
from buffpy.models.link import Link
from buffpy.api import API

# check http://bufferapp.com/developers/apps to retrieve a token
# or generate one with the example
token = 'awesome_tokne'

# instantiate the api object
api = API(client_id='client_id',
          client_secret='client_secret',
          access_token=token)

# get a link's shares
print(Link(api=api, url='http%3A%2F%2Fbufferapp.com').shares)