public
Description: Web-based translation and translation management tool
Homepage: http://translate.sf.net/
Clone URL: git://github.com/julen/pootle.git
pootle / test_statistics.py
100644 36 lines (29 sloc) 1.086 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
"""tests for stats classes"""
 
from py import test
from Pootle import statistics
from translate.storage import po
import os
 
class TestStatsFile:
    """Tests StatsFile"""
 
    def test_creation(self):
        """we create the object and storage file correctly"""
        pofile = po.pofile()
        pofile.filename = os.path.join("file", "test.po")
        sfile = statistics.StatsFile(pofile)
        assert sfile.filename == pofile.filename + ".stats"
 
    def test_hasparent(self):
        """check that we manage the associated stats file for a translatable file"""
        posource = '''msgid "Simple String"\nmsgstr "Dimpled ring"\n'''
        pofile = open("test.po", "w")
        pofile.write(posource)
        pofile.close()
        pofile = open("test.po", "r")
        poobj = po.pofile(pofile)
        print poobj
        sfile = statistics.StatsFile(poobj)
        assert sfile.hasparent() == True
        os.remove("test.po")
        assert not sfile.hasparent()
        assert not os.path.exists("test.po.stats")