~alecu/ubuntuone-client/config-notifications-2

« back to all changes in this revision

Viewing changes to tests/syncdaemon/test_config.py

  • Committer: Tarmac
  • Author(s): Alejandro J. Cura
  • Date: 2011-02-15 15:25:19 UTC
  • mfrom: (858.1.2 aggregator-fixes)
  • Revision ID: tarmac-20110215152519-rs8ksuxv5w3oe8ji
Add a config/dbus option to disable notification bubbles (part I)

Show diffs side-by-side

added added

removed removed

Lines of Context:
372
372
        conf_1 = config._Config(conf_file)
373
373
        self.assertEquals(True, conf_1.get_autoconnect())
374
374
 
 
375
    def test_load_show_all_notifications(self):
 
376
        """Test load/set/override of show_all_notifications config value."""
 
377
        conf_file = os.path.join(self.test_root,
 
378
                                 'test_show_all_notifications_config.conf')
 
379
        # ensure that show_all_notifications is True
 
380
        with open(conf_file, 'w') as fp:
 
381
            fp.write('[notifications]\n')
 
382
            fp.write('show_all_notifications = True\n')
 
383
 
 
384
        # keep a original around
 
385
        conf_orig = config._Config(conf_file)
 
386
 
 
387
        # assert default is correct
 
388
        self.assertTrue(conf_orig.get_show_all_notifications(),
 
389
                        'show_all_notifications is True by default.')
 
390
 
 
391
        # load the config
 
392
        conf = config._Config(conf_file)
 
393
        self.assertTrue(conf.get_show_all_notifications())
 
394
 
 
395
        # change it to False
 
396
        conf.set_show_all_notifications(False)
 
397
        self.assertFalse(conf.get_show_all_notifications())
 
398
 
 
399
        # save, load and check
 
400
        conf.save()
 
401
        conf_1 = config._Config(conf_file)
 
402
        self.assertFalse(conf_1.get_show_all_notifications())
 
403
        # change it to True
 
404
        conf.set_show_all_notifications(True)
 
405
        self.assertTrue(conf.get_show_all_notifications())
 
406
        # save, load and check
 
407
        conf.save()
 
408
        conf_1 = config._Config(conf_file)
 
409
        self.assertTrue(conf_1.get_show_all_notifications())
 
410
 
 
411
        # load the config, check the override of the value
 
412
        conf = config._Config(conf_file)
 
413
        self.assertTrue(conf.get_show_all_notifications())
 
414
        overridden_opts = [('notifications', 'show_all_notifications', False)]
 
415
        conf.override_options(overridden_opts)
 
416
        self.assertFalse(conf.get_show_all_notifications())
 
417
        self.assertNotEqual(conf.get_show_all_notifications(),
 
418
                            conf_orig.get_show_all_notifications())
 
419
        conf.save()
 
420
        conf_1 = config._Config(conf_file)
 
421
        self.assertEquals(True, conf_1.get_show_all_notifications())
 
422
 
375
423
 
376
424
class ConfigglueParsersTests(BaseTwistedTestCase):
377
425
    """Tests for our custom configglue parsers"""