~awn-core/awn/0.2.4

« back to all changes in this revision

Viewing changes to test/test-config-client.py

  • Committer: Neil J Patel
  • Date: 2008-02-14 17:14:00 UTC
  • mfrom: (155.1.34 awn-core-testing)
  • Revision ID: njp@neils-mbp-20080214171400-f2dikd9ivke2jhje
2008-02-14  Neil J. Patel  <njpatel@gmail.com>

        * .bzrignore:
        * CC.COPYING:
        * ChangeLog:
        * Makefile.am:
        * acinclude.m4:
        * applets/wscript_build:
        * autogen.sh:
        * awn-applet-activation/Makefile.am:
        * awn-applet-activation/main.c:
        * awn-applet-activation/wscript_build:
        * awn-manager/.directory:
        * awn-manager/Makefile.am:
        * awn-manager/awn-launcher-editor.in:
        * awn-manager/awnApplet.py:
        * awn-manager/awnDefs.py.in:
        * awn-manager/awnLauncher.py:
        * awn-manager/awnLauncherEditor.py:
        * awn-manager/awnManager.py.in:
        * awn-manager/awnPreferences.py:
        * awn-manager/awnTheme.py:
        * awn-manager/launcher-editor.glade:
        * awn-manager/window.glade:
        * awn-manager/wscript_build:
        * awn.pc.in:
        * bindings/Makefile.am:
        * bindings/python/Makefile.am:
        * bindings/python/__init__.py:
        * bindings/python/awn.defs:
        * bindings/python/awn.override:
        * bindings/python/awnmodule.c:
        * bindings/vala/Makefile.am:
        * bindings/vala/awn.deps:
        * bindings/vala/awn.files:
        * bindings/vala/awn.gi:
        * bindings/vala/awn.metadata:
        * bindings/vala/awn.namespace:
        * bindings/vala/awn.vapi:
        * config.h.in:
        * configure.in:
        * data/Makefile.am:
        * data/awn-schema-to-gconf:
        * data/awn.schema-ini:
        * data/wscript_build:
        * doc/Makefile.am:
        * doc/reference/Makefile.am:
        * doc/reference/libawn-docs.sgml:
        * doc/reference/libawn-sections.txt:
        * doc/reference/libawn.types:
        * docs/PPA_autoppa:
        * docs/waf:
        * libawn/Makefile.am:
        * libawn/awn-applet-dialog.c:
        * libawn/awn-applet-dialog.h:
        * libawn/awn-applet-gconf.c:
        * libawn/awn-applet-gconf.h:
        * libawn/awn-applet-simple.c:
        * libawn/awn-applet.c:
        * libawn/awn-applet.h:
        * libawn/awn-config-client-gconf.c:
        * libawn/awn-config-client-gkeyfile.c:
        * libawn/awn-config-client-shared.c:
        * libawn/awn-config-client.h:
        * libawn/awn-defines.h:
        * libawn/awn-desktop-item-egg.c:
        * libawn/awn-desktop-item-gnome.c:
        * libawn/awn-desktop-item.h:
        * libawn/awn-effects.c:
        * libawn/awn-effects.h:
        * libawn/awn-enum-types.c.in:
        * libawn/awn-settings.c:
        * libawn/awn-settings.h:
        * libawn/awn-title.c:
        * libawn/awn-vfs.c:
        * libawn/awn-vfs.h:
        * libawn/egg/Makefile.am:
        * libawn/egg/egg-enum-types.c.in:
        * libawn/egg/egg-enum-types.h.in:
        * libawn/egg/eggchecksum.c:
        * libawn/egg/eggchecksum.h:
        * libawn/egg/eggdesktopfile.c:
        * libawn/egg/eggdesktopfile.h:
        * libawn/egg/tests/checksum-test.c:
        * libawn/wscript_build:
        * po/wscript_build:
        * src/Makefile.am:
        * src/awn-applet-manager.c:
        * src/awn-applet-manager.h:
        * src/awn-bar.h:
        * src/awn-hotspot.h:
        * src/awn-task-manager.c:
        * src/awn-task-manager.h:
        * src/awn-task.c:
        * src/awn-task.h:
        * src/awn-utils.h:
        * src/awn-window.h:
        * src/awn-x.c:
        * src/awn-x.h:
        * src/main.c:
        * test/Makefile.am:
        * test/test-config-client.c:
        * test/test-config-client.py:
        * test/test.vala:
        * waf:
        * wscript:
        Merged awn-core-testing branch by malept, moonbeem & gilir.
        Abstracts configuration backends; Add support for GKeyfile backend.
        Abstracts Desktop File implementation; Adds support for libegg backend.
        Abstracts VFS backends; Adds support for Tunar & GVFS backend.
        Updated python bindings.
        Adds support for Vala bindings.
        Removes gnome-panel dependancy.
        Updated awn-manager interface.
        

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
#
 
3
#  Copyright (C) 2007 Mark Lee <avant-wn@lazymalevolence.com>
 
4
#
 
5
#  This program is free software; you can redistribute it and/or modify
 
6
#  it under the terms of the GNU General Public License as published by
 
7
#  the Free Software Foundation; either version 2 of the License, or
 
8
#  (at your option) any later version.
 
9
#
 
10
#  This program is distributed in the hope that it will be useful,
 
11
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
#  GNU General Public License for more details.
 
14
#
 
15
#  You should have received a copy of the GNU General Public License
 
16
#  along with this program; if not, write to the Free Software
 
17
#  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA.
 
18
#
 
19
#  Author : Mark Lee <avant-wn@lazymalevolence.com>
 
20
 
 
21
import sys
 
22
import awn
 
23
 
 
24
GROUP = 'test'
 
25
 
 
26
def print_err(err):
 
27
    sys.stderr.write(err + '\n')
 
28
 
 
29
def test_option_bool(client):
 
30
    print '* set bool...',
 
31
    val = True
 
32
    try:
 
33
        client.set_bool(GROUP, 'bool', val)
 
34
    except Exception, err:
 
35
        print_err(str(err))
 
36
        return 1
 
37
    print 'done.'
 
38
    print '* get bool...',
 
39
    val = False
 
40
    try:
 
41
        val = client.get_bool(GROUP, 'bool')
 
42
    except Exception, err:
 
43
        print_err(str(err))
 
44
        return 1
 
45
    print 'done.'
 
46
    if val == True:
 
47
        return 0
 
48
    else:
 
49
        return 1
 
50
 
 
51
def test_option_float(client):
 
52
    print '* set float...',
 
53
    val = 0.5
 
54
    try:
 
55
        client.set_float(GROUP, 'float', val)
 
56
    except Exception, err:
 
57
        print_err(str(err))
 
58
        return 1
 
59
    print 'done.'
 
60
    print '* get float...',
 
61
    val = 0
 
62
    try:
 
63
        val = client.get_float(GROUP, 'float')
 
64
    except Exception, err:
 
65
        print_err(str(err))
 
66
        return 1
 
67
    print 'done.'
 
68
    if val == 0.5:
 
69
        return 0
 
70
    else:
 
71
        return 1
 
72
 
 
73
def test_option_int(client):
 
74
    print '* set int...',
 
75
    val = 4
 
76
    try:
 
77
        client.set_int(GROUP, 'int', val)
 
78
    except Exception, err:
 
79
        print_err(str(err))
 
80
        return 1
 
81
    print 'done.'
 
82
    print '* get int...',
 
83
    val = 0
 
84
    try:
 
85
        val = client.get_int(GROUP, 'int')
 
86
    except Exception, err:
 
87
        print_err(str(err))
 
88
        return 1
 
89
    print 'done.'
 
90
    if val == 4:
 
91
        return 0
 
92
    else:
 
93
        return 1
 
94
 
 
95
def test_option_string(client):
 
96
    print '* set string...',
 
97
    val = 'test'
 
98
    try:
 
99
        client.set_string(GROUP, 'str', val)
 
100
    except Exception, err:
 
101
        print_err(str(err))
 
102
        return 1
 
103
    print 'done.'
 
104
    print '* get string...',
 
105
    val = ''
 
106
    try:
 
107
        val = client.get_string(GROUP, 'str')
 
108
    except Exception, err:
 
109
        print_err(str(err))
 
110
        return 1
 
111
    print 'done.'
 
112
    if val == 'test':
 
113
        return 0
 
114
    else:
 
115
        return 1
 
116
 
 
117
def check_lists(list_get, list_set):
 
118
    retval = 0
 
119
    if len(list_get) != len(list_set):
 
120
        retval = 1
 
121
    else:
 
122
        list_len = len(list_set)
 
123
        for i in range(list_len):
 
124
            if list_get[i] != list_set[i]:
 
125
                print_err('The lists differ at list index %s: get="%s", set="%s"' % (i, list_get[i], list_set[i]))
 
126
                retval = 1
 
127
    return retval
 
128
 
 
129
def test_option_list_bool(client):
 
130
    print '* set list (bool)...',
 
131
    list_set = [True, False, True]
 
132
    try:
 
133
        client.set_list(GROUP, 'list_bool', awn.CONFIG_LIST_BOOL, list_set)
 
134
    except Exception, err:
 
135
        print_err(str(err))
 
136
        return 1
 
137
    print 'done.'
 
138
    print '* get list (bool)...',
 
139
    try:
 
140
        list_get = client.get_list(GROUP, 'list_bool', awn.CONFIG_LIST_BOOL)
 
141
    except Exception, err:
 
142
        print_err(str(err))
 
143
        return 1
 
144
    print 'done.'
 
145
    return check_lists(list_get, list_set)
 
146
 
 
147
def test_option_list_float(client):
 
148
    print '* set list (float)...',
 
149
    list_set = [0.2, 0.4, 0.6]
 
150
    try:
 
151
        client.set_list(GROUP, 'list_float', awn.CONFIG_LIST_FLOAT, list_set)
 
152
    except Exception, err:
 
153
        print_err(str(err))
 
154
        return 1
 
155
    print 'done.'
 
156
    print '* get list (float)...',
 
157
    try:
 
158
        list_get = client.get_list(GROUP, 'list_float', awn.CONFIG_LIST_FLOAT)
 
159
    except Exception, err:
 
160
        print_err(str(err))
 
161
        return 1
 
162
    print 'done.'
 
163
    return check_lists(list_get, list_set)
 
164
 
 
165
def test_option_list_int(client):
 
166
    print '* set list (int)...',
 
167
    list_set = [1, 3, 5]
 
168
    try:
 
169
        client.set_list(GROUP, 'list_int', awn.CONFIG_LIST_INT, list_set)
 
170
    except Exception, err:
 
171
        print_err(str(err))
 
172
        return 1
 
173
    print 'done.'
 
174
    print '* get list (int)...',
 
175
    try:
 
176
        list_get = client.get_list(GROUP, 'list_int', awn.CONFIG_LIST_INT)
 
177
    except Exception, err:
 
178
        print_err(str(err))
 
179
        return 1
 
180
    print 'done.'
 
181
    return check_lists(list_get, list_set)
 
182
 
 
183
def test_option_list_string(client):
 
184
    print '* set list (string)...',
 
185
    list_set = ['One', 'Two', 'Three']
 
186
    try:
 
187
        client.set_list(GROUP, 'list_str', awn.CONFIG_LIST_STRING, list_set)
 
188
    except Exception, err:
 
189
        print_err(str(err))
 
190
        return 1
 
191
    print 'done.'
 
192
    print '* get list (string)...',
 
193
    try:
 
194
        list_get = client.get_list(GROUP, 'list_str', awn.CONFIG_LIST_STRING)
 
195
    except Exception, err:
 
196
        print_err(str(err))
 
197
        return 1
 
198
    print 'done.'
 
199
    return check_lists(list_get, list_set)
 
200
 
 
201
def test_option_types(client):
 
202
    retval = 0
 
203
    retval |= test_option_bool(client)
 
204
    retval |= test_option_float(client)
 
205
    retval |= test_option_int(client)
 
206
    retval |= test_option_string(client)
 
207
    retval |= test_option_list_bool(client)
 
208
    retval |= test_option_list_float(client)
 
209
    retval |= test_option_list_int(client)
 
210
    retval |= test_option_list_string(client)
 
211
    return retval
 
212
 
 
213
def test_awn_config():
 
214
    retval = 0
 
215
    print 'Main config client'
 
216
    client = awn.Config()
 
217
    if client is None:
 
218
        return 1
 
219
    retval |= test_option_types(client)
 
220
    return retval
 
221
 
 
222
def test_applet_config():
 
223
    retval = 0
 
224
    print 'Applet config client'
 
225
    client = awn.Config('test')
 
226
    if client is None:
 
227
        return 1
 
228
    retval |= test_option_types(client)
 
229
    return retval
 
230
 
 
231
def main():
 
232
    retval = 0
 
233
    retval |= test_awn_config()
 
234
    retval |= test_applet_config()
 
235
    return retval
 
236
 
 
237
if __name__ == '__main__':
 
238
    sys.exit(main())