#!/www/python/bin/python

"""$URL: svn+ssh://svn.mems-exchange.org/repos/trunk/dulcinea/lib/test/test_country.py $
$Id: test_country.py 20909 2003-03-04 14:35:33Z dbinger $

Test for dulcinea.country.
"""

from types import TupleType
from sancho.unittest import TestScenario, parse_args, run_scenarios
from dulcinea.country import get_country_name, get_country_list

tested_modules = [ "dulcinea.country" ]

class CountryTest (TestScenario):

    def check_country_lookup (self):
        self.test_val("get_country_name('CA')", "Canada")
        self.test_val("get_country_name('AU')", "Australia")
        self.test_val("get_country_name('TV')", "Tuvalu")
        self.test_val("get_country_name('XX')", None)
        self.test_val("get_country_name(None)", None)

    def check_country_list (self):
        list = get_country_list()
        self.test_true("len(list) > 200")
        self.test_true("('FI', 'Finland') in list")
        self.test_true("('BR', 'Brazil') in list")
        self.test_true("0 not in "
                       "[type(x) is TupleType and len(x) == 2 for x in list]")


if __name__ == "__main__":
    (scenarios, options) = parse_args()
    run_scenarios(scenarios, options)
