示例#1
0
def client_configuration_no_token_test():
    try:
        client = Smallinvoice(None)
        client.get_api_endpoint()
        assert False
    except SmallInvoiceConfigurationException:
        assert True
示例#2
0
def test_authentication_error():
    client = Smallinvoice("playgroundclienttests")
    try:
        client.invoices.all()
        assert False
    except SmallInvoiceConnectionException:
        assert True
示例#3
0
# coding=utf-8
import os
from smallinvoice import Smallinvoice

TEST_API_TOKEN = os.environ['TEST_API_TOKEN']
smallinvoice = Smallinvoice(TEST_API_TOKEN)


def get_smallinvoice():
    # type: () -> Smallinvoice
    return smallinvoice


def generate_address():
    from smallinvoice.clients import Address

    return Address(primary=1,
                   street="Kernstrasse",
                   streetno="60",
                   city="Zurich",
                   code="8004",
                   country="CH")


def generate_customer(name="Hanspeter Muster"):
    from smallinvoice.clients import Customer, CUSTOMER_TYPE, CUSTOMER_GENDER

    return Customer(address_type=CUSTOMER_TYPE.PRIVATE,
                    gender=CUSTOMER_GENDER.MALE,
                    name=name,
                    language="de")
示例#4
0
def test_append_token_to_endpoint():
    client = Smallinvoice("test-token")
    result = client.append_token_to_method("test_method")
    assert result == "https://api.smallinvoice.com/test_method/token/test-token"
示例#5
0
def get_api_endpoint_test():
    client = Smallinvoice("test")
    assert client.get_api_endpoint() == "https://api.smallinvoice.com/"