Files
suite/delivery_partner_ups/tests/test_ups_account.py
Leighton Pennicott b9f0d75a99 [MIG] delivery_partner_ups: migrate module from 12.0 to 13.0
Migrate this module from 12.0 to 13.0 and write tests for validation

H4409
2020-11-05 16:38:20 -05:00

52 lines
2.1 KiB
Python

from odoo.tests.common import TransactionCase
from odoo.exceptions import ValidationError
class TestAccount(TransactionCase):
def setUp(self):
super(TestAccount, self).setUp()
self.PartnerShippingAccount = self.env['partner.shipping.account']
def test_ups_account_information(self):
# Create object and confirm that validation error raises if ups account number is blank or not 8 digits
with self.assertRaises(ValidationError):
wrong_account_number = self.PartnerShippingAccount.create({
'name': '1234567',
'description': 'Error Account',
'partner_id': 5,
'delivery_type': 'ups',
'note': 'This is a note',
'ups_zip': '12345'
})
with self.assertRaises(ValidationError):
no_account_number = self.PartnerShippingAccount.create({
'name': '',
'description': 'Error Account',
'partner_id': 5,
'delivery_type': 'ups',
'note': 'This is a note',
'ups_zip': '12345'
})
# Create object and confirm that validation error raises if zipcode is blank or not 5 digits
with self.assertRaises(ValidationError):
wrong_zip_code = self.PartnerShippingAccount.create({
'name': '123456',
'description': 'Error Account',
'partner_id': 5,
'delivery_type': 'ups',
'note': 'This is a note',
'ups_zip': '1234'
})
with self.assertRaises(ValidationError):
no_zip_code = self.PartnerShippingAccount.create({
'name': '123456',
'description': 'Error Account',
'partner_id': 5,
'delivery_type': 'ups',
'note': 'This is a note',
'ups_zip': ''
})