50 lines
1.7 KiB
Python
50 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from datetime import timedelta
|
|
|
|
from odoo import fields
|
|
from odoo.exceptions import UserError
|
|
from odoo.tests import TransactionCase
|
|
|
|
|
|
class TestPartnerSimple(TransactionCase):
|
|
"""Simple test for partner custom module"""
|
|
|
|
def test_01_saudi_id_valid(self):
|
|
partner = self.env['res.partner'].create({
|
|
'name': 'Test Saudi Citizen',
|
|
'company_type': 'person',
|
|
'identification_type': 'id',
|
|
'identification_number': '1234567890',
|
|
})
|
|
self.assertEqual(partner.identification_number, '1234567890')
|
|
|
|
def test_02_saudi_id_invalid_length(self):
|
|
with self.assertRaises(UserError):
|
|
self.env['res.partner'].create({
|
|
'name': 'Test Invalid ID',
|
|
'company_type': 'person',
|
|
'identification_type': 'id',
|
|
'identification_number': '123',
|
|
})
|
|
|
|
def test_03_iqama_valid(self):
|
|
partner = self.env['res.partner'].create({
|
|
'name': 'Test Resident',
|
|
'company_type': 'person',
|
|
'identification_type': 'iqama',
|
|
'identification_number': '2234567890',
|
|
})
|
|
self.assertEqual(partner.identification_number, '2234567890')
|
|
|
|
def test_04_expired_document(self):
|
|
"""Test expired document validation"""
|
|
yesterday = fields.Date.today() - timedelta(days=1)
|
|
with self.assertRaises(UserError):
|
|
self.env['res.partner'].create({
|
|
'name': 'Test Expired',
|
|
'company_type': 'person',
|
|
'identification_type': 'id',
|
|
'identification_number': '1234567890',
|
|
'identification_expiry_date': yesterday,
|
|
}) |