944e70221e
* feat(metrics): wip * refactor(auth): use accts instead of tokens * fix(wrapper): delayed auth bug * refactor(memory): quick fix * fix(creds): change incompatible py 3.8+ syntax * feat(anatylics): updates tracking * fix(credentials): catch when no accts * fix(metrics): remove unused field * feat(wrapper): raise exception for old import * feat(analytics): consolidate names
48 lines
1.3 KiB
Python
48 lines
1.3 KiB
Python
import pytest
|
|
from specklepy.api import operations
|
|
from specklepy.api.client import SpeckleClient
|
|
from specklepy.objects.base import Base
|
|
from specklepy.transports.server import ServerTransport
|
|
from specklepy.api.credentials import Account, get_account_from_token
|
|
from specklepy.logging.exceptions import SpeckleException, SpeckleWarning
|
|
|
|
|
|
def test_invalid_authentication():
|
|
client = SpeckleClient()
|
|
|
|
with pytest.warns(SpeckleWarning):
|
|
client.authenticate_with_token("fake token")
|
|
|
|
|
|
def test_invalid_send():
|
|
client = SpeckleClient()
|
|
client.account = Account(token="fake_token")
|
|
transport = ServerTransport("3073b96e86", client)
|
|
|
|
with pytest.raises(SpeckleException):
|
|
operations.send(Base(), [transport])
|
|
|
|
|
|
def test_invalid_receive():
|
|
client = SpeckleClient()
|
|
client.account = Account(token="fake_token")
|
|
transport = ServerTransport("fake stream", client)
|
|
|
|
with pytest.raises(SpeckleException):
|
|
operations.receive("fake object", transport)
|
|
|
|
|
|
def test_account_from_token():
|
|
token = "fake token"
|
|
acct = get_account_from_token(token)
|
|
|
|
assert acct.token == token
|
|
|
|
|
|
def test_account_from_token_and_url():
|
|
token = "fake token"
|
|
url = "fake.server"
|
|
acct = get_account_from_token(token, url)
|
|
|
|
assert acct.token == token
|
|
assert acct.serverInfo.url == url |