Mercurial > hg > configuration
diff tests/unit.py @ 116:9d19ed8fd883
https://bugzilla.mozilla.org/show_bug.cgi?id=796196
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 01 Oct 2012 17:08:45 -0700 |
parents | 56db0b2b90af |
children | dff886188b55 |
line wrap: on
line diff
--- a/tests/unit.py Wed Jul 04 09:54:37 2012 -0700 +++ b/tests/unit.py Mon Oct 01 17:08:45 2012 -0700 @@ -203,5 +203,29 @@ expected = datetime.datetime(2012, 7, 4, 0, 0) self.assertEqual(example.config['datestring'], expected) + + def test_added(self): + """test that we keep track of things added to the configuration""" + + # make an example class + class AddedExample(configuration.Configuration): + options = {'foo': {}, + 'bar': {}} + + # parse it; there should be nothing + instance = AddedExample() + instance() + self.assertEqual(instance.added, set()) + + # parse it; there should be one thing + instance = AddedExample() + instance({'foo': 'foo'}) + self.assertEqual(instance.added, set(['foo'])) + + # parse it; there should be two things + instance = AddedExample() + instance({'foo': 'foo'}, {'foo': 'FOO', 'bar': 'bar'}) + self.assertEqual(instance.added, set(['foo', 'bar'])) + if __name__ == '__main__': unittest.main()