Example #1
0
        # test...
        old_environ = os.environ
        try:
            os.environ = {}
            c = TestConfig([])
            self.assertEqual(c.dumb_dict, TestConfig.DEFAULT_DUMB_DICT)

            os.environ = {'REZ_DUMB_DICT': 'foo:bar,more:stuff'}
            c = TestConfig([])
            self.assertEqual(c.dumb_dict, {'foo': 'bar', 'more': 'stuff'})
        finally:
            os.environ = old_environ


if __name__ == '__main__':
    unittest.main()


# Copyright 2013-2016 Allan Johns.
#
# This library is free software: you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation, either
# version 3 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
Example #2
0
                 colors=set(["black", "white"]),
                 male=True,
                 age=1.0,
                 owner=None))

        # load a bad resource, won't fail til bad attribute is accessed
        mordor = store.get_kitten("mordor")
        self.assertEqual(mordor.male, True)

        with self.assertRaises(PetResourceError):
            getattr(mordor, "age")

        # load a puppy why not?
        taco = store.get_puppy("taco")
        self.assertTrue(isinstance(taco, Puppy))
        self.assertTrue(isinstance(taco.resource, PuppyResource))
        self.assertEqual(taco.male, True)
        self.assertEqual(taco.colors, set(["brown"]))

        _validate(
            taco.resource,
            dict(name="taco",
                 colors=set(["brown"]),
                 male=True,
                 age=0.6,
                 owner="joe.bloggs"))


if __name__ == '__main__':
    unittest.main()