#!/www/python/bin/python

"""$URL: svn+ssh://svn.mems-exchange.org/repos/trunk/dulcinea/lib/test/utest_country.py $
$Id: utest_country.py 25054 2004-09-09 18:04:30Z dbinger $

Test for dulcinea.country.
"""

from types import TupleType
from sancho.utest import UTest
from dulcinea.country import get_country_name, get_country_list


class CountryTest (UTest):

    def check_country_lookup (self):
        assert get_country_name('CA') == "Canada"
        assert get_country_name('AU') == "Australia"
        assert get_country_name('TV') == "Tuvalu"
        try:
            get_country_name('XX')
            assert 0
        except KeyError: pass
        try:
            get_country_name(None)
            assert 0
        except KeyError: pass

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


if __name__ == "__main__":
    CountryTest()
