def test_retrieving_namespace_with_partially_untrastlated_contents(self): """ When a namespace is requested in a locale in which not all items are available, the namespace with global names should be returned instead. """ bool_var = BoolVar() traffic = TrafficLightVar() st = SymbolTable("global", ( Bind("bool", BoolVar(), es="booleano", fr=u"booléen"), Bind("traffic", TrafficLightVar(), es=u"tráfico") ), SymbolTable("foo", ( Bind("bar", bool_var, es="fulano"), Bind("baz", traffic, es="mengano", fr="bonjour"), ), ), ) # Checking the namespace: namespace = st.get_namespace("fr") eq_(len(namespace.subnamespaces), 1) subnamespace = namespace.subnamespaces["foo"] subnamespace_objects = { 'bar': bool_var, 'bonjour': traffic, } eq_(subnamespace.objects, subnamespace_objects) expected_unbound_objects_global = { u'booléen': BoolVar(), 'traffic': TrafficLightVar(), } eq_(namespace.objects, expected_unbound_objects_global)
def test_retrieving_namespace_with_partially_untrastlated_contents(self): """ When a namespace is requested in a locale in which not all items are available, the namespace with global names should be returned instead. """ bool_var = BoolVar() traffic = TrafficLightVar() st = SymbolTable( "global", (Bind("bool", BoolVar(), es="booleano", fr=u"booléen"), Bind("traffic", TrafficLightVar(), es=u"tráfico")), SymbolTable( "foo", ( Bind("bar", bool_var, es="fulano"), Bind("baz", traffic, es="mengano", fr="bonjour"), ), ), ) # Checking the namespace: namespace = st.get_namespace("fr") eq_(len(namespace.subnamespaces), 1) subnamespace = namespace.subnamespaces["foo"] subnamespace_objects = { 'bar': bool_var, 'bonjour': traffic, } eq_(subnamespace.objects, subnamespace_objects) expected_unbound_objects_global = { u'booléen': BoolVar(), 'traffic': TrafficLightVar(), } eq_(namespace.objects, expected_unbound_objects_global)
def test_retrieving_namespace_without_children(self): """ A namespace shouldn't have sub-namespaces if the original symbol table doesn't have sub-tables. """ bool_var = BoolVar() traffic = TrafficLightVar() st = SymbolTable( "global", (Bind("bool", bool_var, es="booleano"), Bind("traffic", traffic, es=u"tráfico")), ) # Checking the namespace: global_namespace = st.get_namespace() eq_(len(global_namespace.subnamespaces), 0) # Checking the namespace in Castilian: castilian_namespace = st.get_namespace("es") eq_(len(castilian_namespace.subnamespaces), 0)
def test_retrieving_namespace_with_children(self): """ A namespace should have sub-namespaces for the sub-tables of the original symbol table. """ bool_var = BoolVar() traffic = TrafficLightVar() st = SymbolTable("global", ( Bind("bool", bool_var, es="booleano"), Bind("traffic", traffic, es=u"tráfico") ), SymbolTable("foo", ( Bind("bar", bool_var, es="fulano"), Bind("baz", traffic, es="mengano"), ), ), ) # Checking the namespace: global_namespace = st.get_namespace() eq_(len(global_namespace.subnamespaces), 1) global_subnamespace = global_namespace.subnamespaces["foo"] global_subnamespace_objects = { 'bar': bool_var, 'baz': traffic, } eq_(global_subnamespace.objects, global_subnamespace_objects) # Checking the namespace in Castilian: castilian_namespace = st.get_namespace("es") eq_(len(castilian_namespace.subnamespaces), 1) castilian_subnamespace = castilian_namespace.subnamespaces["foo"] castilian_subnamespace_objects = { 'fulano': bool_var, 'mengano': traffic, } eq_(castilian_subnamespace.objects, castilian_subnamespace_objects)
def test_retrieving_namespace_with_children(self): """ A namespace should have sub-namespaces for the sub-tables of the original symbol table. """ bool_var = BoolVar() traffic = TrafficLightVar() st = SymbolTable( "global", (Bind("bool", bool_var, es="booleano"), Bind("traffic", traffic, es=u"tráfico")), SymbolTable( "foo", ( Bind("bar", bool_var, es="fulano"), Bind("baz", traffic, es="mengano"), ), ), ) # Checking the namespace: global_namespace = st.get_namespace() eq_(len(global_namespace.subnamespaces), 1) global_subnamespace = global_namespace.subnamespaces["foo"] global_subnamespace_objects = { 'bar': bool_var, 'baz': traffic, } eq_(global_subnamespace.objects, global_subnamespace_objects) # Checking the namespace in Castilian: castilian_namespace = st.get_namespace("es") eq_(len(castilian_namespace.subnamespaces), 1) castilian_subnamespace = castilian_namespace.subnamespaces["foo"] castilian_subnamespace_objects = { 'fulano': bool_var, 'mengano': traffic, } eq_(castilian_subnamespace.objects, castilian_subnamespace_objects)
def test_retrieving_namespace_without_children(self): """ A namespace shouldn't have sub-namespaces if the original symbol table doesn't have sub-tables. """ bool_var = BoolVar() traffic = TrafficLightVar() st = SymbolTable("global", ( Bind("bool", bool_var, es="booleano"), Bind("traffic", traffic, es=u"tráfico") ), ) # Checking the namespace: global_namespace = st.get_namespace() eq_(len(global_namespace.subnamespaces), 0) # Checking the namespace in Castilian: castilian_namespace = st.get_namespace("es") eq_(len(castilian_namespace.subnamespaces), 0)