def testAddCatalogue(self): catalogue = MessageCatalogue( 'en', dict(domain1=dict(foo='foo'), domain2=dict(bar='bar'))) catalogue.add_resource('r') catalogue1 = MessageCatalogue('en', dict(domain1=dict(foo1='foo1'))) catalogue1.add_resource('r1') catalogue.add_catalogue(catalogue1) self.assertEquals('foo', catalogue.get('foo', 'domain1')) self.assertEquals('foo1', catalogue.get('foo1', 'domain1')) resources = catalogue.get_resources() resources.sort(key=len) self.assertEquals(['r', 'r1'], resources)
def testAddCatalogueWhenLocaleIsNotTheSameAsTheCurrentOne(self): catalogue = MessageCatalogue('en') self.assertRaises( ValueError, lambda: catalogue.add_catalogue( MessageCatalogue( 'fr', dict())))
def testAddCatalogue(self): catalogue = MessageCatalogue( 'en', dict( domain1=dict( foo='foo'), domain2=dict( bar='bar'))) catalogue.add_resource('r') catalogue1 = MessageCatalogue('en', dict(domain1=dict(foo1='foo1'))) catalogue1.add_resource('r1') catalogue.add_catalogue(catalogue1) self.assertEquals('foo', catalogue.get('foo', 'domain1')) self.assertEquals('foo1', catalogue.get('foo1', 'domain1')) resources = catalogue.get_resources() resources.sort(key=len) self.assertEquals(['r', 'r1'], resources)
def testAddCatalogueWhenLocaleIsNotTheSameAsTheCurrentOne(self): catalogue = MessageCatalogue('en') self.assertRaises( ValueError, lambda: catalogue.add_catalogue(MessageCatalogue('fr', dict())))