~bjornt/grammatista/basic-ui

« back to all changes in this revision

Viewing changes to gtest.py

  • Committer: Bjorn Tillenius
  • Date: 2008-11-02 21:57:57 UTC
  • Revision ID: bjorn@tillenius.me-20081102215757-9hal1f3ldbqu9g9j
Remove a bunch of old cruft.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- coding: utf-8 -*-
2
 
##############################################################################
3
 
#
4
 
# Copyright (c) 2004 Bjorn Tillenius
5
 
# All Rights Reserved.
6
 
#
7
 
# This file is part of Grammatista.
8
 
#
9
 
# Grammatista is free software; you can redistribute it and/or modify
10
 
# it under the terms of the GNU General Public License as published by
11
 
# the Free Software Foundation; either version 2 of the License, or
12
 
# (at your option) any later version.
13
 
#
14
 
# Grammatista is distributed in the hope that it will be useful,
15
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 
# GNU General Public License for more details.
18
 
#
19
 
# You should have received a copy of the GNU General Public License
20
 
# along with Grammatista; if not, write to the Free Software
21
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22
 
#
23
 
##############################################################################
24
 
"""Functional test for grammatista
25
 
 
26
 
It creates a new database, and inserts the definition for
27
 
German. Then it test some things.
28
 
 
29
 
Usage: gtest.py
30
 
"""
31
 
 
32
 
import os
33
 
import sys
34
 
 
35
 
import grammatista
36
 
 
37
 
 
38
 
def setUp():
39
 
    """Sets up everything before the tests are run."""
40
 
    # First add 'utilities' and 'lang' to sys path
41
 
    cwd = os.getcwd()
42
 
    for libdir in ('utilities', 'lang'):
43
 
        path = os.path.join(cwd, libdir)
44
 
        sys.path.insert(0, path)
45
 
 
46
 
    import german
47
 
    import createdb
48
 
                    
49
 
    # Then create the database    
50
 
    createdb.main()
51
 
 
52
 
    # And finally define Lithuanian
53
 
    german.main(args=('-t',))
54
 
 
55
 
def main(args=sys.argv[1:], stdout=sys.stdout, stderr=sys.stderr):
56
 
    setUp()
57
 
    print "Running tests...",
58
 
    gram = grammatista.Grammatista()
59
 
    german = gram.getLanguage(u'Deutsch')
60
 
    assert german.label == u'Deutsch'
61
 
 
62
 
    noun = german.getWordCategory(u'Substantiv')
63
 
    assert noun.label == 'Substantiv'
64
 
 
65
 
    nom_sing_bes = noun.getInflectionForm(u'Nominativ', u'Singular', 'Bestimmt')
66
 
    gen_sing_bes = noun.getInflectionForm(u'Genitiv', u'Singular', 'Bestimmt')
67
 
    dat_sing_bes = noun.getInflectionForm(u'Dativ', u'Singular', 'Bestimmt')
68
 
    acc_sing_bes = noun.getInflectionForm(u'Akkusativ', u'Singular', 'Bestimmt')
69
 
    nom_sing_unbes = noun.getInflectionForm(
70
 
                         u'Nominativ', u'Singular', 'Unbestimmt')
71
 
    gen_sing_unbes = noun.getInflectionForm(
72
 
                         u'Genitiv', u'Singular', 'Unbestimmt')
73
 
    dat_sing_unbes = noun.getInflectionForm(
74
 
                         u'Dativ', u'Singular', 'Unbestimmt')
75
 
    acc_sing_unbes = noun.getInflectionForm(
76
 
                         u'Akkusativ', u'Singular', 'Unbestimmt')
77
 
    
78
 
    nom_plur_bes = noun.getInflectionForm(u'Nominativ', u'Plural', 'Bestimmt')
79
 
    gen_plur_bes = noun.getInflectionForm(u'Genitiv', u'Plural', 'Bestimmt')
80
 
    dat_plur_bes = noun.getInflectionForm(u'Dativ', u'Plural', 'Bestimmt')
81
 
    acc_plur_bes = noun.getInflectionForm(u'Akkusativ', u'Plural', 'Bestimmt')
82
 
    nom_plur_unbes = noun.getInflectionForm(
83
 
                         u'Nominativ', u'Plural', 'Unbestimmt')
84
 
    gen_plur_unbes = noun.getInflectionForm(
85
 
                         u'Genitiv', u'Plural', 'Unbestimmt')
86
 
    dat_plur_unbes = noun.getInflectionForm(
87
 
                         u'Dativ', u'Plural', 'Unbestimmt')
88
 
    acc_plur_unbes = noun.getInflectionForm(
89
 
                         u'Akkusativ', u'Plural', 'Unbestimmt')
90
 
 
91
 
    haus = noun.getWord(u'Haus')
92
 
    #import pdb; pdb.set_trace()
93
 
    assert haus[nom_sing_bes] == u'das Haus'
94
 
    assert haus[acc_sing_bes] == u'das Haus'
95
 
    assert haus[dat_sing_bes] == u'dem Haus'
96
 
    assert haus[gen_sing_bes] == u'des Hauses'
97
 
    assert haus[nom_plur_bes] == u'die Häuser'
98
 
    assert haus[acc_plur_bes] == u'die Häuser'
99
 
    assert haus[dat_plur_bes] == u'den Häusern'
100
 
    assert haus[gen_plur_bes] == u'der Häuser'
101
 
    
102
 
    apfel = noun.getWord(u'Apfel')
103
 
    assert apfel[nom_sing_bes] == u'der Apfel'
104
 
    assert apfel[acc_sing_bes] == u'den Apfel'
105
 
    assert apfel[dat_sing_bes] == u'dem Apfel'
106
 
    assert apfel[gen_sing_bes] == u'des Apfeles'
107
 
    assert apfel[nom_plur_bes] == u'die Äpfel'
108
 
    assert apfel[acc_plur_bes] == u'die Äpfel'
109
 
    assert apfel[dat_plur_bes] == u'den Äpfeln'
110
 
    assert apfel[gen_plur_bes] == u'der Äpfel'
111
 
    
112
 
    meinung = noun.getWord(u'Meinung')
113
 
    assert meinung[nom_sing_bes] == u'die Meinung'
114
 
    assert meinung[acc_sing_bes] == u'die Meinung'
115
 
    assert meinung[dat_sing_bes] == u'der Meinung'
116
 
    assert meinung[gen_sing_bes] == u'der Meinung'
117
 
    assert meinung[nom_plur_bes] == u'die Meinungen'
118
 
    assert meinung[acc_plur_bes] == u'die Meinungen'
119
 
    assert meinung[dat_plur_bes] == u'den Meinungenn'
120
 
    assert meinung[gen_plur_bes] == u'der Meinungen'
121
 
 
122
 
    print "done."
123
 
    
124
 
    
125
 
    
126
 
if __name__ == "__main__":
127
 
    sys.exit(main())