Initial import from Docker volume
This commit is contained in:
2
modules/country/tests/__init__.py
Executable file
2
modules/country/tests/__init__.py
Executable file
@@ -0,0 +1,2 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
BIN
modules/country/tests/__pycache__/__init__.cpython-311.opt-1.pyc
Executable file
BIN
modules/country/tests/__pycache__/__init__.cpython-311.opt-1.pyc
Executable file
Binary file not shown.
BIN
modules/country/tests/__pycache__/__init__.cpython-311.pyc
Executable file
BIN
modules/country/tests/__pycache__/__init__.cpython-311.pyc
Executable file
Binary file not shown.
BIN
modules/country/tests/__pycache__/test_module.cpython-311.opt-1.pyc
Executable file
BIN
modules/country/tests/__pycache__/test_module.cpython-311.opt-1.pyc
Executable file
Binary file not shown.
BIN
modules/country/tests/__pycache__/test_module.cpython-311.pyc
Executable file
BIN
modules/country/tests/__pycache__/test_module.cpython-311.pyc
Executable file
Binary file not shown.
BIN
modules/country/tests/__pycache__/test_scenario.cpython-311.opt-1.pyc
Executable file
BIN
modules/country/tests/__pycache__/test_scenario.cpython-311.opt-1.pyc
Executable file
Binary file not shown.
BIN
modules/country/tests/__pycache__/test_scenario.cpython-311.pyc
Executable file
BIN
modules/country/tests/__pycache__/test_scenario.cpython-311.pyc
Executable file
Binary file not shown.
26
modules/country/tests/scenario_country_import.rst
Executable file
26
modules/country/tests/scenario_country_import.rst
Executable file
@@ -0,0 +1,26 @@
|
||||
==============
|
||||
Country Import
|
||||
==============
|
||||
|
||||
Imports::
|
||||
|
||||
>>> from proteus import Model
|
||||
>>> from trytond.modules.country.scripts import (
|
||||
... import_countries, import_postal_codes)
|
||||
>>> from trytond.tests.tools import activate_modules
|
||||
|
||||
Activate modules::
|
||||
|
||||
>>> config = activate_modules('country')
|
||||
|
||||
Import countries::
|
||||
|
||||
>>> Country = Model.get('country.country')
|
||||
>>> belgium = Country(name="Belgium", code='BE')
|
||||
>>> belgium.save()
|
||||
|
||||
>>> import_countries.do_import()
|
||||
|
||||
Import postal codes::
|
||||
|
||||
>>> import_postal_codes.do_import(['us'])
|
||||
82
modules/country/tests/test_module.py
Executable file
82
modules/country/tests/test_module.py
Executable file
@@ -0,0 +1,82 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
import datetime as dt
|
||||
|
||||
from trytond.pool import Pool
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
|
||||
|
||||
class CountryTestCase(ModuleTestCase):
|
||||
'Test Country module'
|
||||
module = 'country'
|
||||
|
||||
def create_membership(self, from_date=None, to_date=None):
|
||||
pool = Pool()
|
||||
Country = pool.get('country.country')
|
||||
Organization = pool.get('country.organization')
|
||||
OrganizationMember = pool.get('country.organization.member')
|
||||
|
||||
organization = Organization(name="Organization")
|
||||
organization.save()
|
||||
country = Country(name="Country")
|
||||
country.save()
|
||||
member = OrganizationMember(
|
||||
organization=organization, country=country,
|
||||
from_date=from_date, to_date=to_date)
|
||||
member.save()
|
||||
return organization, country
|
||||
|
||||
@with_transaction()
|
||||
def test_is_member_no_date(self):
|
||||
"Test is member without date"
|
||||
organization, country = self.create_membership()
|
||||
|
||||
self.assertTrue(country.is_member(organization))
|
||||
self.assertTrue(country.is_member(organization, dt.date.min))
|
||||
self.assertTrue(country.is_member(organization, dt.date.max))
|
||||
|
||||
@with_transaction()
|
||||
def test_is_member_with_from_date(self):
|
||||
"Test is member with from date"
|
||||
today = dt.date.today()
|
||||
yesterday = today - dt.timedelta(days=1)
|
||||
tomorrow = today + dt.timedelta(days=1)
|
||||
organization, country = self.create_membership(from_date=today)
|
||||
|
||||
self.assertTrue(country.is_member(organization, today))
|
||||
self.assertFalse(country.is_member(organization, yesterday))
|
||||
self.assertTrue(country.is_member(organization, tomorrow))
|
||||
self.assertFalse(country.is_member(organization, dt.date.min))
|
||||
self.assertTrue(country.is_member(organization, dt.date.max))
|
||||
|
||||
@with_transaction()
|
||||
def test_is_member_with_to_date(self):
|
||||
"Test is member with to date"
|
||||
today = dt.date.today()
|
||||
yesterday = today - dt.timedelta(days=1)
|
||||
tomorrow = today + dt.timedelta(days=1)
|
||||
organization, country = self.create_membership(to_date=today)
|
||||
|
||||
self.assertTrue(country.is_member(organization, today))
|
||||
self.assertTrue(country.is_member(organization, yesterday))
|
||||
self.assertFalse(country.is_member(organization, tomorrow))
|
||||
self.assertTrue(country.is_member(organization, dt.date.min))
|
||||
self.assertFalse(country.is_member(organization, dt.date.max))
|
||||
|
||||
@with_transaction()
|
||||
def test_is_member_with_dates(self):
|
||||
"Test is member with dates"
|
||||
today = dt.date.today()
|
||||
yesterday = today - dt.timedelta(days=1)
|
||||
tomorrow = today + dt.timedelta(days=1)
|
||||
organization, country = self.create_membership(
|
||||
from_date=yesterday, to_date=tomorrow)
|
||||
|
||||
self.assertTrue(country.is_member(organization, today))
|
||||
self.assertTrue(country.is_member(organization, yesterday))
|
||||
self.assertFalse(country.is_member(organization, dt.date.min))
|
||||
self.assertFalse(country.is_member(organization, dt.date.max))
|
||||
|
||||
|
||||
del ModuleTestCase
|
||||
8
modules/country/tests/test_scenario.py
Executable file
8
modules/country/tests/test_scenario.py
Executable file
@@ -0,0 +1,8 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
|
||||
from trytond.tests.test_tryton import load_doc_tests
|
||||
|
||||
|
||||
def load_tests(*args, **kwargs):
|
||||
return load_doc_tests(__name__, __file__, *args, **kwargs)
|
||||
Reference in New Issue
Block a user