def test_delete(host, use_ssl, account):
    client = SpeckleApiClient(host=host, use_ssl=use_ssl)
    client.login(email=account['email'], password=account['password'])
    try:
        client.accounts.delete(id='some-made-up-id')
    except AttributeError as e:
        assert str(e) == "'Resource' object has no attribute 'delete'"
def test_create(host, use_ssl, account):
    client = SpeckleApiClient(host=host, use_ssl=use_ssl)
    client.login(email=account['email'], password=account['password'])
    try:
        client.accounts.create(data=account)
    except AttributeError as e:
        assert str(e) == "'Resource' object has no attribute 'create'"
def test_login(host, use_ssl, account):
    client = SpeckleApiClient(host=host, use_ssl=use_ssl)
    assert client.me == None
    client.login(email=account['email'], password=account['password'])
    assert client.me['email'] == account['email']
    assert client.me['apitoken'] is not None
    assert client.me['token'] is not None
Exemple #4
0
def client(host, use_ssl, admin_account):
    client = SpeckleApiClient(host=host, use_ssl=use_ssl)
    try:
        client.register(**admin_account)
    except AssertionError as e:
        if str(e) == 'Email taken. Please login. Thanks!':
            client.login(email=admin_account['email'],
                         password=admin_account['password'])
        else:
            raise e

    return client
def test_get_profile(host, use_ssl, account):
    client = SpeckleApiClient(host=host, use_ssl=use_ssl)
    assert client.me == None
    client.login(email=account['email'], password=account['password'])
    profile = client.accounts.get_profile()

    assert profile['email'] == account['email']
    assert profile['name'] == account['name']
    assert profile['surname'] == account['surname']
    assert profile['company'] == account['company']
    assert profile['private'] == True
    assert profile['role'] == 'admin'
    assert profile['_id'] is not None
def test_update_profile(host, use_ssl, account, new_profile_payload):
    client = SpeckleApiClient(host=host, use_ssl=use_ssl)
    assert client.me == None
    client.login(email=account['email'], password=account['password'])

    client.accounts.update_profile(new_profile_payload)
    profile = client.accounts.get_profile()

    assert profile['name'] != account['name']
    assert profile['surname'] != account['surname']
    assert profile['company'] != account['company']

    assert profile['name'] == new_profile_payload['name']
    assert profile['surname'] == new_profile_payload['surname']
    assert profile['company'] == new_profile_payload['company']

    assert profile['role'] == 'admin'
    assert profile['role'] != new_profile_payload['role']
 def get_me():
     client = SpeckleApiClient(host=host, use_ssl=use_ssl)
     client.login(email=created_item['email'],
                  password='******')
     return client.me