Beispiel #1
0
    def run(self, arg):
        self.name = 'BundleTest'
        print 'Bundle testcase:'

        # Test main bundle.
        b = Bundle.mainbundle()
        print 'Main bundle path:{}'.format(b.path)
        print 'Main bundle name:{}'.format(b.name)

        # Create new bundle.
        my_bundle_name = 'my_bundle'
        try:
            _ = Bundle(my_bundle_name)
        except llbc.error, e:
            print 'Try create my bundle, failed, reason:{}'.format(e)
            print 'We create the bundle dir...'
            os.makedirs(op.join(b.path, my_bundle_name))
Beispiel #2
0
    def run(self, *args, **kwargs):
        print 'Property test:'

        # Construct content.
        print 'Construct property content ...'
        content = 'llbc.test.intVal=       30 # The integer value\n'
        content += 'llbc.test.floatVal    =3.543    # The float value\n'
        content += r'llbc.test.strVal=\#\#\#\.\.\=\=Hello World\=\=\.\.\#\## The string value####'
        print 'Done!, content value: '
        print content

        # Create property and init from above constructed content.
        print 'Load property from above content...'
        prop = Property()
        prop.from_content(content)
        print 'Done!\n'

        # Read from property
        print 'Read from property'
        intProp = prop.llbc.test.intVal
        print 'llbc.test.intVal value:{}, comments:{}'.format(
            intProp.getvalue(as_type=int), intProp.get_comments())
        floatProp = prop.llbc.test.floatVal
        print 'llbc.test.floatVal:{}, comments:{}'.format(
            floatProp.getvalue(as_type=float), floatProp.get_comments())
        print 'llbc.test.strVal:{}, comments:{}'.format(
            prop.getvalue('llbc.test.strVal'),
            prop.get_comments('llbc.test.strVal'))

        # To content.
        print 'convert to content...'
        content = prop.to_content()
        print 'Done!, content:'
        print content

        # To file.
        # We use main bundle to file path.
        bundle = Bundle.mainbundle()
        prop_file_path = op.join(bundle.path, 'test_cfg.cfg')

        print 'to file test, to file: {}'.format(prop_file_path)
        prop.to_file(prop_file_path)
        print 'Done!'

        # From file
        print 'Reinit property from file: {}'.format(prop_file_path)
        prop.from_file(prop_file_path)
        print 'Done! llbc.test.intVal: {}'.format(
            prop.llbc.test.intVal.getvalue(as_type=int))

        print 'All test done!'
        print 'Press any key to continue ...'
        raw_input()

        del prop
        os.remove(prop_file_path)

        return 0
Beispiel #3
0
    def run(self, *args, **kwargs):
        print 'Property test:'

        # Construct content.
        print 'Construct property content ...'
        content = 'llbc.test.intVal=       30 # The integer value\n'
        content += 'llbc.test.floatVal    =3.543    # The float value\n'
        content += r'llbc.test.strVal=\#\#\#\.\.\=\=Hello World\=\=\.\.\#\## The string value####'
        print 'Done!, content value: '
        print content

        # Create property and init from above constructed content.
        print 'Load property from above content...'
        prop = Property()
        prop.from_content(content)
        print 'Done!\n'

        # Read from property
        print 'Read from property'
        intProp = prop.llbc.test.intVal
        print 'llbc.test.intVal value:{}, comments:{}'.format(
            intProp.getvalue(as_type=int), intProp.get_comments())
        floatProp = prop.llbc.test.floatVal
        print 'llbc.test.floatVal:{}, comments:{}'.format(
            floatProp.getvalue(as_type=float), floatProp.get_comments())
        print 'llbc.test.strVal:{}, comments:{}'.format(
            prop.getvalue('llbc.test.strVal'), prop.get_comments('llbc.test.strVal'))

        # To content.
        print 'convert to content...'
        content = prop.to_content()
        print 'Done!, content:'
        print content

        # To file.
        # We use main bundle to file path.
        bundle = Bundle.mainbundle()
        prop_file_path = op.join(bundle.path, 'test_cfg.cfg')

        print 'to file test, to file: {}'.format(prop_file_path)
        prop.to_file(prop_file_path)
        print 'Done!'

        # From file
        print 'Reinit property from file: {}'.format(prop_file_path)
        prop.from_file(prop_file_path)
        print 'Done! llbc.test.intVal: {}'.format(prop.llbc.test.intVal.getvalue(as_type=int))

        print 'All test done!'
        print 'Press any key to continue ...'
        raw_input()

        del prop
        os.remove(prop_file_path)

        return 0
Beispiel #4
0
    def run(self, arg):
        self.name = 'BundleTest'
        print 'Bundle testcase:'

        # Test main bundle.
        b = Bundle.mainbundle()
        print 'Main bundle path:{}'.format(b.path)
        print 'Main bundle name:{}'.format(b.name)

        # Create new bundle.
        my_bundle_name = 'my_bundle'
        try:
            _ = Bundle(my_bundle_name)
        except llbc.error, e:
            print 'Try create my bundle, failed, reason:{}'.format(e)
            print 'We create the bundle dir...'
            os.makedirs(op.join(b.path, my_bundle_name))
Beispiel #5
0
class BundleTest(TestCase):
    def run(self, arg):
        self.name = 'BundleTest'
        print 'Bundle testcase:'

        # Test main bundle.
        b = Bundle.mainbundle()
        print 'Main bundle path:{}'.format(b.path)
        print 'Main bundle name:{}'.format(b.name)

        # Create new bundle.
        my_bundle_name = 'my_bundle'
        try:
            _ = Bundle(my_bundle_name)
        except llbc.error, e:
            print 'Try create my bundle, failed, reason:{}'.format(e)
            print 'We create the bundle dir...'
            os.makedirs(op.join(b.path, my_bundle_name))

        my_bundle = Bundle(my_bundle_name)
        print 'Bundle [{}] created:'.format(my_bundle.name)
        print '{} path: {}'.format(my_bundle.name, my_bundle.path)

        # We try in the my_bundle create a txt file.
        test_file_name = 'test.txt'
        test_file_path = op.join(my_bundle.path, test_file_name)
        with open(test_file_path, 'w+') as f:
            f.write('Hello llbc!\n')

        # Now, get the test file path.
        rtn_path = my_bundle.getrespath(test_file_name)
        print 'The test file[{}] in bundle path: {}'.format(
            test_file_name, rtn_path)

        # Cleanup test resources.
        os.remove(test_file_path)
        os.removedirs(my_bundle.path)

        print 'Press any key to continue ... '
        _ = raw_input()

        return 0