def test_0002_incorrect_email_addresses(self):
        address = Address()

        with self.assertRaises(ValueError) as e:
            address.emailAddress = 'test(at)invalid.email'

        with self.assertRaises(ValueError) as e:
            address.businessEmailAddress = 'test(at)invalid.email'

        with self.assertRaises(ValueError) as e:
            address.privateEmailAddress = 'test(at)invalid.email'
    def test_1001_add_order(self):
        # create a cart
        cart = CartCreate()
        cart.currency = 'EUR'
        cart.locale = 'fi_fi'
        cart.taxType = 'NET'

        products = self.get_products()

        # Add products to the cart
        item1 = ProductLineItemCreate()
        item1.productId = products[0]['productId']
        item1.quantity = 2
        cart.lineItems.add(item1)

        item2 = ProductLineItemCreate()
        item2.productId = products[1]['productId']
        item2.quantity = 4
        cart.lineItems.add(item2)

        time.sleep(1)

        # send to a shop
        self.params["object"] = cart
        response = self.client.add_cart(self.params)
        self.save_cart_credential(response)

        basic_params = self.add_cart_credential({})

        # Add required billing address
        buyer = Address()
        buyer.country = "FI"
        buyer.emailAddress = "*****@*****.**"

        # params for update billing address
        params = {'object': buyer}
        params.update(basic_params)

        time.sleep(1)

        response = self.client.update_billing_address(params)
        self.assertEqual(isinstance(response, dict), True)

        time.sleep(1)

        response = self.client.add_order(basic_params)
        self.assertEqual(isinstance(response, dict), True)

        self.save_resource(self.order_id_file, response['orderId'])
    def test_2005_add_order_twice(self):
        # try two times create order from a cart

        # Add correct billing address
        basic_params = self.add_cart_credential(self.params)
        billing_address = Address()
        billing_address.country = "FI"
        billing_address.emailAddress = "*****@*****.**"
        basic_params["object"] = billing_address

        response = self.client.update_billing_address(basic_params)

        response = self.client.add_order(basic_params)
        # Reason: Not Found
        with self.assertRaises(RuntimeError) as e:
            response = self.client.add_order(basic_params)
    def test_0008_add_billing_address(self):
        # Modifies the billing address for a cart.

        billing_address = Address()
        billing_address.firstName = "Äijö"
        billing_address.lastName = "Äälinen"
        billing_address.street = "Pellavatehtaankatu 19"
        billing_address.zipCode = "33210"
        billing_address.city = "Tampere"
        billing_address.country = "FI"
        billing_address.emailAddress = "*****@*****.**"

        # set credentials of the cart
        self.params = self.add_cart_credential(self.params)
        self.params["object"] = billing_address

        response = self.client.update_billing_address(self.params)
        self.assertEqual(isinstance(response, dict), True)
    def test_0010_add_shipping_address(self):
        # Modifies the shipping address for a cart.

        shipping_address = Address()
        shipping_address.firstName = "Лев"
        shipping_address.lastName = "Толстой"
        shipping_address.street = "Pellavatehtaankatu 19"
        shipping_address.zipCode = "33210"
        shipping_address.city = "Tampere"
        shipping_address.country = "FI"
        shipping_address.emailAddress = "*****@*****.**"
        shipping_address.gender = "MALE"
        shipping_address.jobTitle = "writer"

        # set credentials of the cart
        self.params = self.add_cart_credential(self.params)
        self.params["object"] = shipping_address

        response = self.client.update_shipping_address(self.params)
        self.assertEqual(isinstance(response, dict), True)
    def test_0001_simple_correct_inputs(self):
        address = Address()
        address.company = "Company"
        address.salutation = "Mr"
        address.title = "Agent"
        address.firstName = "James"
        address.lastName = "Körri"
        address.street = "Finlaysoninkuja 19"
        address.streetDetails = ""
        address.zipCode = "33210"
        address.city = "TAMPERE"
        address.state = "Pirkanmaa"
        address.country = "Finland"
        address.vatId = "vat_01"
        address.birthday = "04.04.2014"
        address.emailAddress = "*****@*****.**"
        address.addressExtension = "C 2"
        address.bankAccountHolder = "James Körri"
        address.bankAccountNumber = "123456-789"
        address.bankName = "Big Bank"
        address.bankSortCode = "BB"
        address.businessEmailAddress = "*****@*****.**"
        address.businessPhoneNumber = "+358441111111"
        address.department = "IT"
        address.displayName = "James Körri"
        address.doorCode = "0000"
        address.faxNumber = "+35845000000"
        address.fiscalCode = "000000-000"
        address.gender = "MALE"
        address.jobTitle = "Secret Agent"
        address.middleName = "Kalle"
        address.mobilePhoneNumber = "+35844000000000"
        address.phoneNumber = "+3584413579"
        address.privateEmailAddress = "*****@*****.**"
        address.privatePhoneNumber = "+358441234567"
        address.websiteUrl = "http://websites.invalid"

        right_answer = {
            'company': 'Company',
            'salutation': 'Mr',
            'title': 'Agent',
            'firstName': 'James',
            'lastName': 'Körri',
            'street': 'Finlaysoninkuja 19',
            'streetDetails': '',
            'zipCode': '33210',
            'city': 'TAMPERE',
            'state': 'Pirkanmaa',
            'country': 'Finland',
            'vatId': 'vat_01',
            'birthday': '04.04.2014',
            'emailAddress': '*****@*****.**',
            'addressExtension': 'C 2',
            'bankAccountHolder': 'James Körri',
            'bankAccountNumber': '123456-789',
            'bankName': 'Big Bank',
            'bankSortCode': 'BB',
            'businessEmailAddress': '*****@*****.**',
            'businessPhoneNumber': '+358441111111',
            'department': 'IT',
            'displayName': 'James Körri',
            'doorCode': '0000',
            'faxNumber': '+35845000000',
            'fiscalCode': '000000-000',
            'gender': 'MALE',
            'jobTitle': 'Secret Agent',
            'middleName': 'Kalle',
            'mobilePhoneNumber': '+35844000000000',
            'phoneNumber': '+3584413579',
            'privateEmailAddress': '*****@*****.**',
            'privatePhoneNumber': '+358441234567',
            'websiteUrl': 'http://websites.invalid'
        }

        self.assertEqual(address.get_dict(), right_answer)