Example #1
0
    def test_init(self):

        d = Dogma('CF', {}, None)
        assert_equal(d._religion, 'CF')
        assert_equal(d._beliefs, {})
        assert_is(d._dataObject, None)
        assert_equal(d.__class__.__name__, 'CFDogma')

        d = Dogma('CF', {}, 'foo')
        assert_is(d._dataObject, 'foo')

        beliefs = {'foo': 'bar', 'bat': 'baz'}
        d = Dogma('CF', beliefs, None)
        assert_is(d._beliefs, beliefs)
        assert_is(d.__class__._beliefs, beliefs)
        assert_is(d.__class__._religion, 'CF')
        assert_is_instance(d.__class__.__dict__.get('foo'), Tenets)
        assert_is_instance(d.__class__.__dict__.get('bat'), Tenets)

        bat_tenet = d.__class__.__dict__.get('bat')
        assert_equal(bat_tenet.belief, 'bat')
        assert_equal(bat_tenet.teaching, 'baz')

        with assert_raises_regexp(
                DogmaMetaClassException,
                "Blasphemy! The name of your metadata religion"):
            d = Dogma('', {}, None)
Example #2
0
    def test_dogma_validate_teaching(self):

        beliefs = {"foo": "bar", "bat": "baz"}
        d = Dogma("CF", beliefs, None)

        ret = d._validate_teaching("foo", "bar")
        self.assertIs(ret, "bar")

        Dogma._validate_teaching("foo", "bar")
        self.assertIs(ret, "bar")
Example #3
0
    def test_dogma_validate_teaching(self):

        beliefs = {'foo': 'bar', 'bat': 'baz'}
        d = Dogma('CF', beliefs, None)

        ret = d._validate_teaching('foo', 'bar')
        assert_is(ret, 'bar')

        Dogma._validate_teaching('foo', 'bar')
        assert_is(ret, 'bar')
Example #4
0
    def test_dogma_delete(self):

        beliefs = {"foo": "bar", "bat": "baz"}
        d = Dogma("CF", beliefs, None)
        with self.assertRaisesRegexp(NotImplementedError, "_del Method is not implemented in the Dogma Base Class!"):
            d._del("foo")

        with self.assertRaisesRegexp(
            DogmaDeleteException, """Error deleting the 'foo' property of the class 'CFDogma'"""
        ):
            del d.foo

        with self.assertRaises(AttributeError):
            del d.not_an_att
Example #5
0
    def test_dogma_set(self):

        beliefs = {"foo": "bar", "bat": "baz"}
        d = Dogma("CF", beliefs, None)
        with self.assertRaisesRegexp(NotImplementedError, "_set Method is not implemented in the Dogma Base Class!"):
            d._set("foo", "bar")

        with self.assertRaisesRegexp(
            DogmaGetterSetterException, """Error setting the 'foo' property of the class 'CFDogma'"""
        ):
            d.foo = 5

        with self.assertRaises(AttributeError):
            d.not_an_att = 5
Example #6
0
    def test_dogma_get(self):

        beliefs = {'foo': 'bar', 'bat': 'baz'}
        d = Dogma('CF', beliefs, None)
        with assert_raises_regexp(
                NotImplementedError,
                '_get Method is not implemented in the Dogma Base Class!'):
            d._get('foo')

        with assert_raises_regexp(
                DogmaGetterSetterException,
                """Error getting the 'foo' property of the class 'CFDogma'"""):
            d.foo

        with assert_raises(AttributeError):
            d.not_an_att
Example #7
0
    def test_dogma_delete(self):

        beliefs = {'foo': 'bar', 'bat': 'baz'}
        d = Dogma('CF', beliefs, None)
        with self.assertRaisesRegexp(
                NotImplementedError,
                '_del Method is not implemented in the Dogma Base Class!'):
            d._del('foo')

        with self.assertRaisesRegexp(
                DogmaDeleteException,
                """Error deleting the 'foo' property of the class 'CFDogma'"""
        ):
            del d.foo

        with self.assertRaises(AttributeError):
            del d.not_an_att