Exemple #1
0
    def test_as_dict3(self):

        LOG.info("Testing obj.as_dict() #3 - typecasting to str")

        from fb_tools.obj import FbBaseObject

        obj = FbBaseObject(appname='test_base_object', verbose=1)
        obj.obj2 = FbBaseObject(appname='test_base_object2', verbose=1)

        out = str(obj)
        self.assertIsInstance(out, str)
        LOG.debug("Got str(FbBaseObject): %s", out)
Exemple #2
0
    def test_as_dict_short(self):

        LOG.info("Testing obj.as_dict() #4 - stacked and short")

        from fb_tools.obj import FbBaseObject

        obj = FbBaseObject(appname='test_base_object', verbose=1)
        obj.obj2 = FbBaseObject(appname='test_base_object2', verbose=1)

        di = obj.as_dict(short=True)
        LOG.debug("Got FbBaseObject.as_dict(): %r", di)
        self.assertIsInstance(di, dict)
        self.assertIsInstance(obj.obj2.as_dict(), dict)
Exemple #3
0
    def test_basedir1(self):

        bd = '/blablub'
        LOG.info("Testing #1 wrong basedir: %r", bd)

        from fb_tools.obj import FbBaseObject

        obj = FbBaseObject(appname='test_base_object', base_dir=bd)     # noqa
Exemple #4
0
    def test_basedir2(self):

        bd = '/etc/passwd'
        LOG.info("Testing #2 wrong basedir: %r", bd)

        from fb_tools.obj import FbBaseObject

        obj = FbBaseObject(appname='test_base_object', base_dir=bd)     # noqa
Exemple #5
0
    def test_as_dict1(self):

        LOG.info("Testing obj.as_dict() #1 - simple")

        from fb_tools.obj import FbBaseObject

        obj = FbBaseObject(appname='test_base_object', verbose=1)

        di = obj.as_dict()
        LOG.debug("Got FbBaseObject.as_dict(): %r", di)
        self.assertIsInstance(di, dict)
Exemple #6
0
    def test_verbose2(self):

        LOG.info("Testing wrong verbose values #2.")

        from fb_tools.obj import FbBaseObject

        v = -2
        obj = None

        with self.assertRaises(ValueError) as cm:
            obj = FbBaseObject(appname='test_base_object', verbose=v)   # noqa
        e = cm.exception
        LOG.debug("ValueError raised on verbose = %r: %s", v, str(e))
Exemple #7
0
    def test_object(self):

        LOG.info("Testing init of a simple object.")

        from fb_tools.obj import FbGenericBaseObject, FbBaseObject

        with self.assertRaises(TypeError) as cm:
            gen_obj = FbGenericBaseObject()                         # noqa
        e = cm.exception
        LOG.debug("TypeError raised on instantiate a FbGenericBaseObject: %s", str(e))

        obj = FbBaseObject(
            appname='test_base_object',
            verbose=1,
        )
        LOG.debug("FbBaseObject %%r: %r", obj)
        LOG.debug("FbBaseObject %%s: %s", str(obj))