Ejemplo n.º 1
0
def test_double_add_company(redis_client):
    ' Should only add a company once '
    company = MockCompany(account='foo', name='bar', profile_image_url='baz')
    db.write_company(redis_client, company)
    db.write_company(redis_client, company)
    companies = db.get_companies(redis_client)
    assert len(companies) == 1
Ejemplo n.º 2
0
def test_get_company(redis_client):
    ' Should fetch details for given company '
    company = MockCompany(account='foo', name='bar', profile_image_url='baz')
    db.write_company(redis_client, company)
    details = db.get_company_details(redis_client, 'foo')
    assert details['account'] == b'foo'
    assert details['name'] == b'bar'
    assert details['profile_image_url'] == b'baz'
Ejemplo n.º 3
0
def add_company(db_instance, company_name):
    ' will find company details by `company_name` and write to db '
    try:
        company = twitter.get_company_account(api, company_name)
        db.write_company(db_instance, company)
        print('{0} => {1}, @{2}'.format(company_name, company.name,
                                        company.screen_name))
    except Exception as e:
        print('exception', e)
def foo_company(redis_client):
    account = 'foo'
    company = MockCompany(account=account, name='bar', profile_image_url='baz')
    db.write_company(redis_client, company)
    return account
Ejemplo n.º 5
0
def test_add_company(redis_client, foo_company):
    ' Adding a company adds it a the list of companies '
    company = MockCompany(account='foo', name='bar', profile_image_url='baz')
    db.write_company(redis_client, company)
    companies = db.get_companies(redis_client)
    assert b'foo' in companies