def testDump(self):
        catalogue = MessageCatalogue('en')
        catalogue.add({"foo": "bar"})

        tmp_dir = tempfile.gettempdir()
        dumper = PoFileDumper()
        dumper.dump(catalogue, {"path": tmp_dir})

        with open(__DIR__ + '/../fixtures/resources.po') as f1:
            with open(tmp_dir + '/messages.en.po') as f2:
                self.assertEqual(f1.read(), f2.read())

        os.unlink(tmp_dir + '/messages.en.po')
Beispiel #2
0
    def testAdd(self):
        catalogue = MessageCatalogue(
            'en', dict(domain1=dict(foo='foo'), domain2=dict(bar='bar')))
        catalogue.add(dict(foo1='foo1'), 'domain1')

        self.assertEquals('foo', catalogue.get('foo', 'domain1'))
        self.assertEquals('foo1', catalogue.get('foo1', 'domain1'))

        catalogue.add(dict(foo='bar'), 'domain1')
        self.assertEquals('bar', catalogue.get('foo', 'domain1'))
        self.assertEquals('foo1', catalogue.get('foo1', 'domain1'))

        catalogue.add(dict(foo='bar'), 'domain88')
        self.assertEquals('bar', catalogue.get('foo', 'domain88'))
    def testAdd(self):
        catalogue = MessageCatalogue(
            'en', dict(
                domain1=dict(
                    foo='foo'), domain2=dict(
                    bar='bar')))
        catalogue.add(dict(foo1='foo1'), 'domain1')

        self.assertEquals('foo', catalogue.get('foo', 'domain1'))
        self.assertEquals('foo1', catalogue.get('foo1', 'domain1'))

        catalogue.add(dict(foo='bar'), 'domain1')
        self.assertEquals('bar', catalogue.get('foo', 'domain1'))
        self.assertEquals('foo1', catalogue.get('foo1', 'domain1'))

        catalogue.add(dict(foo='bar'), 'domain88')
        self.assertEquals('bar', catalogue.get('foo', 'domain88'))