예제 #1
0
def test_create_invoice_from_xml(
    sample_invoice_xml,
    sample_address_data,
    sample_invoice_customer_data,
    sample_invoice_item_service1_data,
    sample_invoice_item_service2_data,
    sample_invoice_line1_data,
    sample_invoice_line2_data,
    sample_invoice_data,
):
    root_lxml = etree.fromstring(sample_invoice_xml)
    invoice = Invoice.from_lxml(root_lxml)

    assert invoice.TxnID == sample_invoice_data['TxnID']
    assert invoice.TimeCreated == sample_invoice_data['TimeCreated']
    assert invoice.TimeModified == sample_invoice_data['TimeModified']
    assert invoice.EditSequence == sample_invoice_data['EditSequence']
    assert invoice.IsPending == sample_invoice_data['IsPending']
    assert invoice.DueDate == sample_invoice_data['DueDate']
    assert invoice.Memo == sample_invoice_data['Memo']

    assert invoice.BillAddress == BillAddress(**sample_address_data)
    assert invoice.ShipAddress == ShipAddress(**sample_address_data)
    assert invoice.Customer == Customer(**sample_invoice_customer_data)

    assert isinstance(invoice.InvoiceLine, list)
    assert invoice.InvoiceLine[0] == InvoiceLine(
        **sample_invoice_line1_data,
        Item=ItemService(**sample_invoice_item_service1_data))
    assert invoice.InvoiceLine[1] == InvoiceLine(
        **sample_invoice_line2_data,
        Item=ItemService(**sample_invoice_item_service2_data))
예제 #2
0
def sample_invoice_add(sample_invoice_data, sample_address_data,
                       sample_customer_data, sample_invoice_item_service1_data,
                       sample_invoice_item_service2_data,
                       sample_invoice_line1_data, sample_invoice_line2_data):
    invoice_data = deepcopy(sample_invoice_data)
    invoice_data.pop('TxnID')
    invoice_data.pop('EditSequence')
    invoice_data.pop('TimeCreated')
    invoice_data.pop('TimeModified')
    invoice_line1_data = deepcopy(sample_invoice_line1_data)
    invoice_line2_data = deepcopy(sample_invoice_line2_data)
    invoice_line1_data.pop('TxnLineID')
    invoice_line2_data.pop('TxnLineID')
    sample_invoice_item_service1_data.pop('FullName')
    sample_invoice_item_service2_data.pop('FullName')
    customer_data = dict(ListID=sample_customer_data['ListID'],
                         FullName=sample_customer_data['FullName'])

    return Invoice(**invoice_data,
                   BillAddress=BillAddress(**sample_address_data),
                   ShipAddress=ShipAddress(**sample_address_data),
                   Customer=Customer(**customer_data),
                   InvoiceLine=[
                       InvoiceLine(**invoice_line1_data,
                                   Item=ItemService(
                                       **sample_invoice_item_service1_data)),
                       InvoiceLine(**invoice_line2_data,
                                   Item=ItemService(
                                       **sample_invoice_item_service2_data))
                   ])
예제 #3
0
def test_create_bill_address_with_validation_error():
    with pytest.raises(ValidationError):
        BillAddress(
            Addr1=12312,
            City=1234,
            State=1234,
            PostalCode=1234,
            Country=1234,
        )
예제 #4
0
def test_create_bill_address_from_xml(sample_address_xml, sample_address_data):
    root_lxml = etree.fromstring(sample_address_xml)
    bill_address = BillAddress.from_lxml(root_lxml)
    assert bill_address.Addr1 == sample_address_data['Addr1']
    assert bill_address.City == sample_address_data['City']
    assert bill_address.State == sample_address_data['State']
    assert bill_address.PostalCode == sample_address_data['PostalCode']
    assert bill_address.Country == sample_address_data['Country']
    assert bill_address.Note == sample_address_data['Note']
예제 #5
0
def test_create_bill_address(sample_address_data):
    address = BillAddress(**sample_address_data)

    assert address.Addr1 == sample_address_data['Addr1']
    assert address.City == sample_address_data['City']
    assert address.State == sample_address_data['State']
    assert address.PostalCode == sample_address_data['PostalCode']
    assert address.Country == sample_address_data['Country']
    assert address.Note == sample_address_data['Note']
def sample_customer_add(
    sample_customer_data,
    sample_address_data,
):
    customer_data = deepcopy(sample_customer_data)
    customer_data.pop('ListID')
    customer_data.pop('TimeCreated')
    customer_data.pop('TimeModified')
    customer_data.pop('EditSequence')

    return Customer(
        **customer_data,
        BillAddress=BillAddress(**sample_address_data),
        ShipAddress=ShipAddress(**sample_address_data),
    )
def test_create_customer_from_xml(sample_customer_xml, sample_customer_data, sample_address_data):
    root_lxml = etree.fromstring(sample_customer_xml)
    customer = Customer.from_lxml(root_lxml)
    assert customer.ListID == sample_customer_data['ListID']
    assert customer.TimeCreated == sample_customer_data['TimeCreated']
    assert customer.TimeModified == sample_customer_data['TimeModified']
    assert customer.EditSequence == sample_customer_data['EditSequence']
    assert customer.Name == sample_customer_data['Name']
    assert customer.FullName == sample_customer_data['FullName']
    assert customer.IsActive == sample_customer_data['IsActive']
    assert customer.CompanyName == sample_customer_data['CompanyName']
    assert customer.Phone == sample_customer_data['Phone']
    assert customer.AltPhone == sample_customer_data['AltPhone']
    assert customer.Fax == sample_customer_data['Fax']
    assert customer.Email == sample_customer_data['Email']
    assert customer.Contact == sample_customer_data['Contact']
    assert customer.AltContact == sample_customer_data['AltContact']

    assert customer.BillAddress == BillAddress(**sample_address_data)
    assert customer.ShipAddress == ShipAddress(**sample_address_data)
def test_create_customer(sample_customer_data, sample_address_data):
    customer = Customer(
        **sample_customer_data,
        BillAddress=BillAddress(**sample_address_data),
        ShipAddress=ShipAddress(**sample_address_data),
    )

    assert customer.Name == sample_customer_data['Name']
    assert customer.IsActive == sample_customer_data['IsActive']
    assert customer.ListID == sample_customer_data['ListID']
    assert customer.EditSequence == sample_customer_data['EditSequence']
    assert customer.FullName == sample_customer_data['FullName']
    assert customer.CompanyName == sample_customer_data['CompanyName']
    assert customer.Phone == sample_customer_data['Phone']
    assert customer.AltPhone == sample_customer_data['AltPhone']
    assert customer.Fax == sample_customer_data['Fax']
    assert customer.Email == sample_customer_data['Email']
    assert customer.Contact == sample_customer_data['Contact']
    assert customer.AltContact == sample_customer_data['AltContact']

    assert isinstance(customer.BillAddress, BillAddress)
    assert isinstance(customer.ShipAddress, ShipAddress)
예제 #9
0
def test_create_invoice(
    sample_address_data,
    sample_customer_data,
    sample_invoice_item_service1_data,
    sample_invoice_item_service2_data,
    sample_invoice_line1_data,
    sample_invoice_line2_data,
    sample_invoice_data,
):
    invoice = Invoice(
        **sample_invoice_data,
        BillAddress=BillAddress(**sample_address_data),
        ShipAddress=ShipAddress(**sample_address_data),
        Customer=Customer(**sample_customer_data),
        InvoiceLine=[
            InvoiceLine(**sample_invoice_line1_data,
                        Item=ItemService(**sample_invoice_item_service1_data)),
            InvoiceLine(**sample_invoice_item_service2_data,
                        Item=ItemService(**sample_invoice_item_service2_data))
        ])

    assert invoice.TxnID == sample_invoice_data['TxnID']
    assert invoice.TimeCreated == sample_invoice_data['TimeCreated']
    assert invoice.TimeModified == sample_invoice_data['TimeModified']
    assert invoice.EditSequence == sample_invoice_data['EditSequence']
    assert invoice.TxnDate == sample_invoice_data['TxnDate']
    assert invoice.IsPending == sample_invoice_data['IsPending']
    assert invoice.DueDate == sample_invoice_data['DueDate']
    assert invoice.Memo == sample_invoice_data['Memo']

    assert isinstance(invoice.BillAddress, BillAddress)
    assert isinstance(invoice.ShipAddress, ShipAddress)
    assert isinstance(invoice.Customer, Customer)
    assert isinstance(invoice.InvoiceLine, list)
    assert isinstance(invoice.InvoiceLine[0], InvoiceLine)
    assert isinstance(invoice.InvoiceLine[0].Item, ItemService)
    assert isinstance(invoice.InvoiceLine[1], InvoiceLine)