Merge lp://staging/~awn-core/libdesktop-agnostic/various-fixes into lp://staging/libdesktop-agnostic
- various-fixes
- Merge into trunk
Status: | Superseded | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Proposed branch: | lp://staging/~awn-core/libdesktop-agnostic/various-fixes | ||||||||||||||||||||||||||||||||
Merge into: | lp://staging/libdesktop-agnostic | ||||||||||||||||||||||||||||||||
Diff against target: | None lines | ||||||||||||||||||||||||||||||||
To merge this branch: | bzr merge lp://staging/~awn-core/libdesktop-agnostic/various-fixes | ||||||||||||||||||||||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mark Lee | Needs Resubmitting | ||
Review via email: mp+10124@code.staging.launchpad.net |
This proposal supersedes a proposal from 2009-08-13.
This proposal has been superseded by a proposal from 2009-08-19.
Commit message
Description of the change
Michal Hruby (mhr3) wrote : Posted in a previous version of this proposal | # |
Mark Lee (malept) wrote : Posted in a previous version of this proposal | # |
> This branch contains currently fixes to the test-config.vala program and the
> new python test-config script (see bug 411879).
Please resubmit when you have updated your branch against latest trunk (r248), as I have committed a better version of your test-config.vala fix.
Mark Lee (malept) wrote : Posted in a previous version of this proposal | # |
I don't agree with the changes made to test-config.vala. If anything, there should be a --verbose flag that allows messages to be optionally printed. I would prefer if test programs emitted as little non-error text as possible by default, so that they can be integrated into a `./waf test` or whatever it will be called.
Michal Hruby (mhr3) wrote : Posted in a previous version of this proposal | # |
Messages were removed.
Mark Lee wrote:
> Review: Needs Fixing
> I don't agree with the changes made to test-config.vala. If anything, there should be a --verbose flag that allows messages to be optionally printed. I would prefer if test programs emitted as little non-error text as possible by default, so that they can be integrated into a `./waf test` or whatever it will be called.
>
Mark Lee (malept) wrote : Posted in a previous version of this proposal | # |
> Messages were removed.
>
> Mark Lee wrote:
> > Review: Needs Fixing
> > I don't agree with the changes made to test-config.vala. If anything, there
> should be a --verbose flag that allows messages to be optionally printed. I
> would prefer if test programs emitted as little non-error text as possible by
> default, so that they can be integrated into a `./waf test` or whatever it
> will be called.
> >
I think, to keep things relatively sane, all copyright should be assigned to me, with you listed as the author.
Mark Lee (malept) wrote : Posted in a previous version of this proposal | # |
I would just get rid of any changes you made to tests/test-
> === added file 'tests/
It should be in tests/python (there will be a separate directory for tests/gi).
> +import glib
> +import time
> +import desktopagnostic
> +
> +class TestCase:
You should run the PEP8 checker on this file.
> + def __init__(self):
> + self.ml = glib.MainLoop()
> + self.notify_counter = 0
> + self.client = desktopagnostic
Use single quotes instead of double quotes.
> + self.client.
> +
> + def test_defaults(
> + expected = True
> + actual = self.client.
> + v = self.client.
> + assert expected == actual, "Fail! Expected value: %s,
> actual: %s" % (str(expected), str(actual))
> + assert actual == v
I think this code can be generalized into its own method.
[...]
> +
> + #expected = [10.5, 20.6, 30.7]
> + #expected = map (lambda x: round (x, 3), expected)
Use list comprehensions instead of map.
[...]
> + def string_
> + self.notify_counter = self.notify_counter + 1
I prefer using += here.
> +
> + def string_
> + if (value.find ("quux") != -1):
Don't use parentheses in if statements unless you're grouping for || or &&.
you probably want `"quux" in value` instead (much more readable).
> + self.notify_counter = self.notify_counter + 3
> +
> + def test_notify(self):
The repeated statements in this method should also be generalized into a function (similar to how I did it in tests/test-
Mark Lee (malept) wrote : Posted in a previous version of this proposal | # |
> > === added file 'tests/
>
> It should be in tests/python (there will be a separate directory for
> tests/gi).
I forgot to mention, it should also be renamed to test-config-
Michal Hruby (mhr3) wrote : | # |
The issues mentioned in the review were fixed, except:
> I would just get rid of any changes you made to tests/test-
I believe the version in my branch is more readable and moreover simplified, why do you use Idle callback? It's not needed, in fact calling run() method of the MainLoop is not necessary. Plus main's return codes are defined directly in that function and one doesn't need a private prop for it.
Michal Hruby (mhr3) wrote : | # |
Sorry about the missing "this.test_
Michal Hruby (mhr3) wrote : | # |
Patch for bug 411156 was added to the branch in R255.
- 252. By Mark Lee
-
Config (memory): Fix compile error introduced in Vala 0.7.5 (requires a fix in Vala 0.7.6).
- 253. By Mark Lee
-
Desktop Entry: the string list getter/setter now deals with GStrv values only.
- 254. By Mark Lee
-
Python: add minimal bindings for VFS.
- 255. By Mark Lee
-
lda-schema-
to-gconf: emit a better error message when the gconf module could not be loaded. - 256. By Mark Lee
-
Build system: add configure flag with enables extra C compiler warnings.
- 257. By Mark Lee
-
Config: ensure empty arrays are handled correctly in both the schemas and when setting them via the API.
- 258. By Mark Lee
-
Tests (Config): add tests for empty strings/arrays.
- 259. By Mark Lee
-
Build system (Debian): revert part of revision 234, as it doesn't appear to work on Ubuntu for some bizarre reason.
- 260. By Mark Lee
-
Merge from <lp:~gilir/libdesktop-agnostic/debian-packaging>, revision 265 (with one change - add SONAME to the desktop-specific modules as well).
- 261. By Mark Lee
-
Desktop Entry: the return values for string (array) getters are nullable.
- 262. By Mark Lee
-
Desktop Entry (GLib): Emit a proper warning when an error occurs trying to retrieve the value of a desktop entry key.
- 263. By Mark Lee
-
VFS (Thunar VFS): fix compiler warnings.
- 264. By Mark Lee
-
Docs: update the known issues.
- 265. By Mark Lee
-
Desktop Entry: the icon property now returns NULL if it doesn't exist in the desktop entry.
- 266. By Mark Lee
-
Desktop Entry: add API which checks to see if a key exists in a desktop entry.
- 267. By Mark Lee
-
Desktop Entry (GLib): emit a warning and default to FALSE when a boolean key is not found, instead of hitting an assert.
- 268. By Mark Lee
-
Tests (Desktop Entry): link to and initialize GDK, which is needed for the GNOME module.
- 269. By Mark Lee
-
Tests (Config): refactor to not use Idle.add, as it's not strictly necessary.
- 270. By Mark Lee
-
Build system: don't add SONAMEs to the modules.
- 271. By Mark Lee
-
Config (GConf): refactor reset() and remove().
- 272. By Mark Lee
-
Config Bridge: ensure that objects are properly unbound and that the bridge does not hold any references to the object; add a test for this behavior; replace the messages in the test program with asserts.
Mark Lee (malept) wrote : | # |
Please resubmit so that I can see a diff against the latest changes to both branches.
- 273. By Mark Lee
-
Ignore generated GConf schemas.
- 274. By Mark Lee
-
Module: only emit debug messages when the proper environment variable is set.
- 275. By Mark Lee
-
Build system: update basedir-header support (now called includedir), which will be in Vala 0.7.6.
- 276. By Mark Lee
-
Tests (Config): Catch the exception thrown from creating the schema object.
- 277. By Mark Lee
-
Config Bridge: Make error more verbose.
- 278. By Mark Lee
-
Config: convert Values which are not floats or ints but can be transformed into those types, to get around limitations in certain bindings.
- 279. By Mark Lee
-
Tests (Config Bridge): consolidate code, add tests for floats/bools (and a disabled list test).
- 280. By Mark Lee
-
Config (KeyFile): remove extra call to save_config().
- 281. By Mark Lee
-
Config (KeyFile): don't autosave when updating the config from a keyfile change.
- 282. By Mark Lee
-
Config (KeyFile): when setting a value, ensure that it has changed before writing to disk.
- 283. By Mark Lee
-
Merge from <lp:~mhr3/libdesktop-agnostic/various-fixes>, revision 259.
- 284. By Mark Lee
-
Python (Config): Fix FTBFS.
- 285. By Mark Lee
-
Config: same as revision 278, but also for lists.
- 286. By Mark Lee
-
Python (Config): make sure that byte/unicode strings passed to set_value() are not marked as arrays.
- 287. By Mark Lee
-
Tests (Python Config Client): refactor to remove redundant code; add set_value() tests.
- 288. By Mark Lee
-
Tests (Python Config Client): refactor into a unittest TestCase.
- 289. By Mark Lee
-
Config Bridge: optimize string building.
- 290. By Mark Lee
-
Tests (Config Bridge): fix accidental commit of commented out throws clause.
- 291. By Mark Lee
-
Config Bridge: minor code cleanup.
- 292. By Mark Lee
-
Config Bridge: refactor to avoid segfaults caused by revision 272.
* Move binding destruction code to its proper place in the Binding destructor method.
* Properly remove Bindings from the bindings list.
* Add comments regarding code that should not be written.
* Add a cleaner method of dealing with the config notify callbacks. - 293. By Mark Lee
-
Tests (Config Bridge): add regression tests which test the various states that the internal binding lists could be in.
- 294. By Mark Lee
-
Config Bridge: Use prepend to populate the bindings to remove list, in case a key is bound to more than one property of an object. Add a test for this in the test program.
- 295. By Mark Lee
-
Config Bridge: only deal with config notify functions when a binding list is being created or destroyed.
- 296. By Mark Lee
-
Config: fix throws clauses.
- 297. By Mark Lee
-
Config Bridge: consolidate the config notify callback code.
- 298. By Mark Lee
-
Tests (VFS File): link with GDK so that the Thunar VFS module can be tested properly.
- 299. By Mark Lee
-
Build system: fix installing defs files.
- 300. By Mark Lee
-
Desktop Entry: annotate the file, keyfile, and data properties as also being construct properties.
- 301. By Mark Lee
-
Build system (Python): fix handling of local load types and register flags.
- 302. By Mark Lee
-
Python: add bindings/tests for VFS.File, VFS.FileMonitor, and FDO.DesktopEntry.
- 303. By Mark Lee
-
Python (FDO): add compatibility code for PyGObject installations without PyGLib.
- 304. By Mark Lee
-
Build system (Debian): add a rule to 'fix' VAPIs generated with Vala < 0.7.6.
- 305. By Mark Lee
-
Python: fix typo.
- 306. By Mark Lee
-
Config Client: add a constructor that takes a config schema and an optional instance ID.
- 307. By Mark Lee
-
Python (Desktop Entry): bind the key_exists() method.
- 308. By Mark Lee
-
Config Bridge: add support for binding enumerations.
- 309. By Mark Lee
-
Color: fix the default alpha value when parsing a color string without an alpha value.
- 310. By Mark Lee
-
Color: fix the channel property types.
- 311. By Mark Lee
-
Remove trailing whitespace.
- 312. By Mark Lee
-
Revert accidentally committed code.
- 313. By Mark Lee
-
Config Schema: make the invalid schema section error easier to understand.
- 314. By Mark Lee
-
Config Client: properly implement BindMethod.BOTH.
- 315. By Mark Lee
-
Tests (Config Client): fix license.
- 316. By Mark Lee
-
Desktop Entry (GLib): fix the case where the file doesn't exist.
- 317. By Mark Lee
-
Tests (Config Bridge): add test for adding property notify callbacks pre- and post-bind.
- 318. By Mark Lee
-
Config Bridge: make sure that a config key is not bound to the same property more than once.
- 319. By Mark Lee
-
Python (VFS): fix error enum.
- 320. By Mark Lee
-
VFS.File: add the copy() method (copies the file, not the object).
- 321. By Mark Lee
-
Tests (VFS.File): test launch() or remove(), but not both at once.
- 322. By Mark Lee
-
Python (VFS): add trash bindings.
- 323. By Mark Lee
-
VFS Volume (GIO): remove warning message.
- 324. By Mark Lee
-
Config Bridge (bind): use the canonical property name when possible, not the user-supplied one.
- 325. By Mark Lee
-
Config Bridge: allow two different object instances with the same property name to bind to the same config key.
- 326. By Mark Lee
-
Config Client: Add a short description of the class.
- 327. By Mark Lee
-
Config (KeyFile): use unowned variables for schema-related stuff when possible.
- 328. By Mark Lee
-
Config (KeyFile): fix a bunch of segfaults.
- 329. By Mark Lee
-
VFS File: add support for querying the access rights of the current user, for a given file.
- 330. By Mark Lee
-
Add a wrapper for Gtk.ColorButton that can use DesktopAgnostic
.Color objects. - 331. By Mark Lee
-
Build system: add libdesktop-
agnostic- gtk to the pkgconfig file. - 332. By Mark Lee
-
GTK: install a glade3 catalog when configured to do so.
- 333. By Mark Lee
-
Color: attempt to fix FTBFS, given Vala < 0.7.6.
- 334. By Mark Lee
-
GTK (ColorButton): provide a default value for the da_color property.
- 335. By Mark Lee
-
VAPI: Update the thunar-vfs bindings.
- 336. By Mark Lee
-
VFS Volume (Thunar VFS): add a constructor, due to changes to Object.new in Vala 0.7.6.
- 337. By Mark Lee
-
Config (GConf): throw a key not found error in gconfvalue_
to_gvalue if the config key doesn't exist in the schema. - 338. By Mark Lee
-
Tools (lda-schema-
to-gconf) : ensure that the schema-ini file exists. - 339. By Mark Lee
-
VFS Trash (GNOME VFS): fix summary.
- 340. By Mark Lee
-
VFS Trash (GNOME VFS): close directory handle when finished.
- 341. By Mark Lee
-
VFS File: add enumerate_
children( ) method. - 342. By Mark Lee
-
VFS Volume (GIO): handle the case where the volume mount is NULL.
- 343. By Mark Lee
-
Add an icon chooser dialog, an associated button, a launcher editor dialog, and an associated binary.
- 344. By Mark Lee
-
Build system (Debian): add manpage for lda-desktop-
entry-editor. - 345. By Mark Lee
-
VFS: fixes for Vala 0.7.6.
- 346. By Mark Lee
-
Tests (GTK): add tests for using GTK.ColorButton with GtkBuilder.
- 347. By Mark Lee
-
Tests (Python): update Color test so that it asserts that the color property is a gdk.Color.
- 348. By Mark Lee
-
GTK Color Button (glade3): use @get-type-function instead of parent.
- 349. By Mark Lee
-
GTK (ColorButton): ensure that the DesktopAgnostic
.Color object and color/alpha properties are synced, even if the custom constructor isn't used or the da-color property is NULL. - 350. By Mark Lee
-
Python (Config): update call due to changes in Vala 0.7.6.
- 351. By Mark Lee
-
Build system (tests): forgot to add test-gtk-
colorbutton- gtkbuilder to the build system. - 352. By Mark Lee
-
VFS (Volume): fix methods using VolumeCallback, due to changes in Vala 0.7.6.
- 353. By Mark Lee
-
Build system: requires Vala 0.7.7 or later now, as Vala 0.7.6 is rather broken (in terms of this library).
- 354. By Mark Lee
-
Config Schema: fix Vala compiler warnings.
- 355. By Mark Lee
-
Config Schema Option: default_value, upper_boundary, and lower_boundary are now automatic properties.
- 356. By Mark Lee
-
Config Schema Option: fix the declaration of the whitelist and blacklist properties.
- 357. By Mark Lee
-
Config Schema Option: retrieve the localized version of the summary and description, and use the non-translated version as fallback.
- 358. By Mark Lee
-
Documentation: update dependency information; add specific instructions for Debian/Ubuntu.
- 359. By Mark Lee
-
Config Schema Option: fix typo.
- 360. By Mark Lee
-
Module: update delegates due to changes in Vala >= 0.7.6.
- 361. By Mark Lee
-
Module (load_from_path): restructure to emit more errors.
- 362. By Mark Lee
-
Glade3: apparently get-type-function is not needed, as glade3 generates the correct function name.
- 363. By Mark Lee
-
Glade3: annotate which library needs to be loaded (thanks to mhr3).
- 364. By Mark Lee
-
GTK (ColorButton): fix notify property name (thanks to mhr3).
- 365. By Mark Lee
-
GTK (ColorButton): only disconnect the signal if it's still connected.
- 366. By Mark Lee
-
GTK (ColorButton): the destructor is not needed (according to mhr3).
- 367. By Mark Lee
-
Python (FDO): fix human-readable method names.
- 368. By Mark Lee
-
Config Notify Delegate: fix compile warning.
- 369. By Mark Lee
-
Config (KeyFile): don't set global-only options in an instance config object.
- 370. By Mark Lee
-
Module: allow the module directory environment variable to take precedence over the 'hardcoded' paths.
- 371. By Mark Lee
-
Config: when dealing with ValueArrays, use foreach instead of for.
- 372. By Mark Lee
-
Debian: remove obsolete sed commands.
- 373. By Mark Lee
-
GTK/UI: rename the gtk library/namespace to UI, so that using the widgets via GtkBuilder doesn't fail.
- 374. By Mark Lee
-
UI (Icon Button): Port the clicked signal handler of GtkColorButton, to fix modal/focus issues. (reported by mhr3).
- 375. By Mark Lee
-
Merge from <lp:~mhr3/libdesktop-agnostic/various-fixes>, revision 369.
- 376. By Mark Lee
-
UI (LauncherEditor
Dialog) : remove a block out of a try-catch statement that does not need to be there. - 377. By Mark Lee
-
VAPI (ThunarVfs): update.
- 378. By Mark Lee
-
VAPI (ThunarVfs): fix Path parent handling attributes.
- 379. By Mark Lee
-
VFS: add support for retrieving the parent file of a given file (or NULL if the file is the root directory).
- 380. By Mark Lee
-
UI (LauncherEditor
Dialog) : refactor the code that determines whether the output file can be written to so that it is more robust. - 381. By Mark Lee
-
UI (Icon Chooser Dialog): only use the case folded path to check the path's suffix.
- 382. By Mark Lee
-
UI (Color Button): make sure all of the color buttons don't reference one object.
- 383. By Mark Lee
-
VFS Trash (GIO): fix recursion bug.
- 384. By Michal Hruby
-
Fix memleaks in Config.Bridge.
Fix binding when using multiple instances. - 385. By Michal Hruby
-
Fix FTBFS
- 386. By Michal Hruby
-
Workaround the leaky gconf bindings
- 387. By Michal Hruby
-
Minor cleanup.
- 388. By Michal Hruby
-
Adapt to GConf bindings changes in Vala 0.7.10
- 389. By Michal Hruby
-
A couple of fixes for Vala 0.7.10
- 390. By Michal Hruby
-
Require vala 0.7.10
- 391. By Michal Hruby
-
Fix keyfile config backend monitoring
- 392. By Michal Hruby
-
Bump version to 0.3.9
- 393. By Michal Hruby
-
Merge from <lp:~gilir/libdesktop-agnostic/debian-fixes>
- 394. By Michal Hruby
-
Bump Vala requirement to 0.7.10
- 395. By Michal Hruby
-
Support current locale in DesktopEntry.
get_localestrin g - 396. By Michal Hruby
-
Use size of string on relevant places to fix problems with utf8 encoded data
- 397. By Michal Hruby
-
Use gnu_dirs tool to simplify packagers' lives
- 398. By Michal Hruby
-
Remove empty constructor
- 399. By Michal Hruby
-
Valadoc fixes
- 400. By Michal Hruby
-
Make sure dist includes Vala-generated sources
- 401. By Michal Hruby
-
Fix crasher in gnome-vfs trash implementation
- 402. By Michal Hruby
-
Merge trunk
- 403. By Michal Hruby
-
Fix unwanted exception during keyfile creation
- 404. By Michal Hruby
-
Fix compability with Vala 0.8.1
- 405. By Michal Hruby
-
Merge trunk
- 406. By Michal Hruby
-
Fix leaks in python bindings
- 407. By onox
-
Fix compability with Vala 0.9.1
- 408. By Michal Hruby
-
Make this actually work... Though it's nasty
- 409. By Michal Hruby
-
Fix for recent Vala version
- 410. By Michal Hruby
-
Add --disable-gi option to allow building with older GI
- 411. By Michal Hruby
-
Fix compability with Vala 0.9.7
- 412. By Michal Hruby
-
Add FDO gio backend
- 413. By Michal Hruby
-
Recognize Terminal key in FDO glib backend
- 414. By Michal Hruby
-
Support launching also Link-type desktop entries in FDO gio backend
- 415. By Michal Hruby
-
Fix focus chain in launcher editor
- 416. By Michal Hruby
-
Make theme selection active by default in IconChooserDialog, support resize, implement lazy pixbuf loading
- 417. By Michal Hruby
-
Update known issues
- 418. By Michal Hruby
-
Try to fix thunar-vfs compile errors
- 419. By Michal Hruby
-
Change LauncherEditorD
ialog to support both Applications and Links - 420. By Michal Hruby
-
Add a couple of methods to VFS.File and bump version number
- 421. By Michal Hruby
-
Add python bindings for the new methods
- 422. By Michal Hruby
-
Add also get_thumbnail_path
- 423. By Julien Lavergne
-
debian: Build-depends on gir-repository-dev (>= 0.6.3)
- 424. By Michal Hruby
-
Whoops, did I remove gilir's commit?
- 425. By Michal Hruby
-
PEP8 changes to wscript
Unmerged revisions
Preview Diff
1 | === added file 'tests/python/test-config-client.py' |
2 | --- tests/python/test-config-client.py 1970-01-01 00:00:00 +0000 |
3 | +++ tests/python/test-config-client.py 2009-08-13 23:04:26 +0000 |
4 | @@ -0,0 +1,156 @@ |
5 | +#!/usr/bin/env python |
6 | +# Copyright(c) 2009 Mark Lee <libdesktop-agnostic@lazymalevolence.com> |
7 | +# |
8 | +# This program is free software; you can redistribute it and/or modify |
9 | +# it under the terms of the GNU General Public License as published by |
10 | +# the Free Software Foundation; either version 2 of the License, or |
11 | +#(at your option) any later version. |
12 | +# |
13 | +# This program is distributed in the hope that it will be useful, |
14 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | +# GNU General Public License for more details. |
17 | +# |
18 | +# You should have received a copy of the GNU General Public License |
19 | +# along with this program; if not, write to the Free Software |
20 | + |
21 | +import glib |
22 | +import time |
23 | +import desktopagnostic.config |
24 | + |
25 | + |
26 | +class TestCase: |
27 | + |
28 | + def __init__(self): |
29 | + SCHEMA_FILE = '../test-config.schema-ini' |
30 | + self.ml = glib.MainLoop() |
31 | + self.notify_counter = 0 |
32 | + self.client = desktopagnostic.config.Client(SCHEMA_FILE) |
33 | + self.client.reset(False) |
34 | + |
35 | + def check_values(self, expected, actual, value): |
36 | + ERROR_MSG = 'Fail! Expected value: %s, actual: %s' |
37 | + assert expected == actual, ERROR_MSG % (str(expected), str(actual)) |
38 | + assert actual == value |
39 | + |
40 | + def test_defaults(self): |
41 | + group, key = ('numeric', 'boolean') |
42 | + self.check_values(True, |
43 | + self.client.get_bool(group, key), |
44 | + self.client.get_value(group, key)) |
45 | + |
46 | + group, key = ('numeric', 'integer') |
47 | + self.check_values(3, |
48 | + self.client.get_int(group, key), |
49 | + self.client.get_value(group, key)) |
50 | + |
51 | + group, key = ('numeric', 'float') |
52 | + self.check_values(round(3.14, 3), |
53 | + round(self.client.get_float(group, key), 3), |
54 | + round(self.client.get_value(group, key), 3)) |
55 | + |
56 | + group, key = ('misc', 'string') |
57 | + self.check_values('Foo bar', |
58 | + self.client.get_string(group, key), |
59 | + self.client.get_value(group, key)) |
60 | + |
61 | + group, key = ('list', 'boolean') |
62 | + self.check_values([True, False], |
63 | + self.client.get_list(group, key), |
64 | + self.client.get_value(group, key)) |
65 | + |
66 | + group, key = ('list', 'integer') |
67 | + self.check_values([1, 2, 3], |
68 | + self.client.get_list(group, key), |
69 | + self.client.get_value(group, key)) |
70 | + |
71 | + group, key = ('list', 'float') |
72 | + actual = [round(x, 3) for x in self.client.get_list(group, key)] |
73 | + values = [round(x, 3) for x in self.client.get_value(group, key)] |
74 | + self.check_values([round(x, 3) for x in [1.618, 2.718, 3.141]], |
75 | + actual, values) |
76 | + |
77 | + group, key = ('list', 'string') |
78 | + self.check_values(['foo', 'bar'], |
79 | + self.client.get_list(group, key), |
80 | + self.client.get_value(group, key)) |
81 | + |
82 | + def test_set(self): |
83 | + expected = False |
84 | + self.client.set_bool('numeric', 'boolean', expected) |
85 | + assert expected == self.client.get_value('numeric', 'boolean') |
86 | + assert expected == self.client.get_bool('numeric', 'boolean') |
87 | + |
88 | + expected = 10 |
89 | + self.client.set_int('numeric', 'integer', expected) |
90 | + assert expected == self.client.get_value('numeric', 'integer') |
91 | + assert expected == self.client.get_int('numeric', 'integer') |
92 | + |
93 | + expected = round(2.718, 3) |
94 | + self.client.set_float('numeric', 'float', expected) |
95 | + assert expected == round(self.client.get_value('numeric', 'float'), 3) |
96 | + assert expected == round(self.client.get_float('numeric', 'float'), 3) |
97 | + |
98 | + expected = 'Quux baz' |
99 | + self.client.set_string('misc', 'string', expected) |
100 | + assert expected == self.client.get_value('misc', 'string') |
101 | + assert expected == self.client.get_string('misc', 'string') |
102 | + |
103 | + expected = [False, True, False] |
104 | + self.client.set_list('list', 'boolean', expected) |
105 | + assert expected == self.client.get_value('list', 'boolean') |
106 | + assert expected == self.client.get_list('list', 'boolean') |
107 | + |
108 | + expected = [10, 20, 30] |
109 | + self.client.set_list('list', 'integer', expected) |
110 | + assert expected == self.client.get_value('list', 'integer') |
111 | + assert expected == self.client.get_list('list', 'integer') |
112 | + |
113 | + expected = [round(x, 3) for x in [10.5, 20.6, 30.7]] |
114 | + self.client.set_list('list', 'float', expected) |
115 | + list1 = [round(x, 3) for x in self.client.get_value('list', 'float')] |
116 | + list2 = [round(x, 3) for x in self.client.get_list('list', 'float')] |
117 | + assert expected == list1 |
118 | + assert expected == list2 |
119 | + |
120 | + expected = ['Quux', 'Baz', 'Foo'] |
121 | + self.client.set_list('list', 'string', expected) |
122 | + assert expected == self.client.get_value('list', 'string') |
123 | + assert expected == self.client.get_list('list', 'string') |
124 | + |
125 | + def string_changed(self, group, key, value): |
126 | + self.notify_counter += 1 |
127 | + |
128 | + def string_changed2(self, group, key, value): |
129 | + if 'quux' in value: |
130 | + self.notify_counter += 3 |
131 | + |
132 | + def check_notify(self, ctx, string, expected_counter): |
133 | + self.client.set_string('misc', 'string', string) |
134 | + # wait for the notification |
135 | + time.sleep(0.25) |
136 | + while ctx.pending(): |
137 | + ctx.iteration() |
138 | + assert self.notify_counter == expected_counter |
139 | + |
140 | + def test_notify(self): |
141 | + ctx = self.ml.get_context() |
142 | + |
143 | + self.client.notify_add('misc', 'string', self.string_changed) |
144 | + self.client.notify_add('misc', 'string', self.string_changed2) |
145 | + |
146 | + self.check_notify(ctx, 'Bar foo', 1) |
147 | + |
148 | + self.check_notify(ctx, 'Foo quux', 5) |
149 | + |
150 | + self.client.notify_remove('misc', 'string', self.string_changed) |
151 | + self.check_notify(ctx, 'Bar quux', 8) |
152 | + |
153 | + self.client.notify_remove('misc', 'string', self.string_changed2) |
154 | + self.check_notify(ctx, 'Baz foo', 8) |
155 | + |
156 | +if __name__ == '__main__': |
157 | + t = TestCase() |
158 | + t.test_defaults() |
159 | + t.test_set() |
160 | + t.test_notify() |
161 | |
162 | === modified file 'tests/test-config.vala' |
163 | --- tests/test-config.vala 2009-08-12 05:43:40 +0000 |
164 | +++ tests/test-config.vala 2009-08-13 08:45:37 +0000 |
165 | @@ -34,7 +34,6 @@ |
166 | Config.Backend cfg; |
167 | uint notify_counter; |
168 | MainLoop ml; |
169 | - int retval; |
170 | |
171 | public TestCase () |
172 | { |
173 | @@ -42,7 +41,6 @@ |
174 | this.cfg = Config.new ((owned)schema); |
175 | this.notify_counter = 0; |
176 | this.ml = new MainLoop (null, false); |
177 | - this.retval = 0; |
178 | } |
179 | |
180 | void |
181 | @@ -285,10 +283,14 @@ |
182 | |
183 | cfg.notify_add ("misc", "string", this.on_string_changed); |
184 | cfg.notify_add ("misc", "string", this.on_string_changed2); |
185 | + |
186 | this.update_notify_value (ctx, "Bar foo", 1); |
187 | + |
188 | this.update_notify_value (ctx, "Foo quux", 5); |
189 | + |
190 | cfg.notify_remove ("misc", "string", this.on_string_changed); |
191 | this.update_notify_value (ctx, "Bar quux", 8); |
192 | + |
193 | cfg.notify_remove ("misc", "string", this.on_string_changed2); |
194 | this.update_notify_value (ctx, "Baz foo", 8); |
195 | } |
196 | @@ -316,46 +318,36 @@ |
197 | test_invalid () throws AssertionError, Error |
198 | { |
199 | this.test_invalid_func ((GetCfgFunc)cfg.get_bool); |
200 | + |
201 | this.test_invalid_func ((GetCfgFunc)cfg.get_float); |
202 | - this.test_invalid_func ((GetCfgFunc)cfg.get_int); |
203 | + |
204 | this.test_invalid_func ((GetCfgFunc)cfg.get_string); |
205 | + |
206 | this.test_invalid_func ((GetCfgFunc)cfg.get_list); |
207 | } |
208 | |
209 | - bool |
210 | - run () |
211 | + public static int |
212 | + main (string[] args) |
213 | { |
214 | + TestCase test = new TestCase (); |
215 | try |
216 | { |
217 | - this.test_defaults (); |
218 | - this.test_set (); |
219 | - this.test_invalid (); |
220 | - this.test_notify (); |
221 | + test.test_defaults (); |
222 | + test.test_set (); |
223 | + test.test_invalid (); |
224 | + test.test_notify (); |
225 | } |
226 | catch (AssertionError assertion) |
227 | { |
228 | critical ("Assertion Error: %s", assertion.message); |
229 | - this.retval = 1; |
230 | + return 1; |
231 | } |
232 | catch (Error err) |
233 | { |
234 | critical ("Error: %s", err.message); |
235 | - this.retval = 2; |
236 | - } |
237 | - finally |
238 | - { |
239 | - this.ml.quit (); |
240 | - } |
241 | - return false; |
242 | - } |
243 | - |
244 | - public static int |
245 | - main (string[] args) |
246 | - { |
247 | - TestCase test = new TestCase (); |
248 | - Idle.add (test.run); |
249 | - test.ml.run (); |
250 | - return test.retval; |
251 | + return 2; |
252 | + } |
253 | + return 0; |
254 | } |
255 | } |
256 |
This branch contains currently fixes to the test-config.vala program and the new python test-config script (see bug 411879).