예제 #1
0
    def test_01_create_base_parser(self):
        """
        Run the test on the ObjMarkup class

        :param self: reference to the test framework object
        :return: Nothing
        """
        self.parser = objmarkup.ObjMarkup(self.obj)
        self.assertTrue(self.parser)
예제 #2
0
    def test_09_basic_get_schema(self):
        """
        Run the test on the ObjMarkup class

        :param self: reference to the test framework object
        :return: Nothing
        """
        self.parser = objmarkup.ObjMarkup(self.obj)
        self.assertTrue(self.parser)
        schema = self.parser.get_fields()
        self.assertIsNotNone(schema)
예제 #3
0
    def test_05_basic_parse_list_value(self):
        """
        Run the test on the ObjMarkup class

        :param self: reference to the test framework object
        :return: Nothing
        """
        markup = 'company[0]'
        self.parser = objmarkup.ObjMarkup(self.obj)
        self.assertTrue(self.parser)
        obj = self.parser(markup)
        self.assertIsNotNone(obj)
예제 #4
0
    def test_08_parse_mult_dict_list_value_2(self):
        """
        Run the test on the ObjMarkup class

        :param self: reference to the test framework object
        :return: Nothing
        """
        markup = 'company[0]employees[0]hobby[0]name'
        answer = 'Bowling'
        self.parser = objmarkup.ObjMarkup(self.obj)
        self.assertTrue(self.parser)
        value = self.parser(markup)
        self.assertEqual(value, answer)
예제 #5
0
    def test_06_parse_dict_list_value(self):
        """
        Run the test on the ObjMarkup class

        :param self: reference to the test framework object
        :return: Nothing
        """
        markup = 'company[0].name'
        answer = 'Slate Rock and Gravel Company'
        self.parser = objmarkup.ObjMarkup(self.obj)
        self.assertTrue(self.parser)
        value = self.parser(markup)
        self.assertEqual(value, answer)
예제 #6
0
    def test_10_schema_check(self):
        """
        Run the test on the ObjMarkup class

        :param self: reference to the test framework object
        :return: Nothing
        """
        self.parser = objmarkup.ObjMarkup(self.obj)
        self.assertTrue(self.parser)
        schema = self.parser.get_fields()
        self.assertEqual(len(schema), 4)
        self.assertEqual(schema[0], 'company[1]name')
        self.assertEqual(schema[1], 'company[1]employees[2]name')
        self.assertEqual(schema[2], 'company[1]employees[2]job title')
        self.assertEqual(schema[3], 'company[1]employees[2]hobby[2]name')
예제 #7
0
    def test_02_utility_methods(self):
        """
        Run the test on the ObjMarkup class

        :param self: reference to the test framework object
        :return: Nothing
        """
        # perform basic sanity checks on the class utility methods
        self.parser = objmarkup.ObjMarkup(self.obj)
        self.assertTrue(self.parser)
        self.assertTrue(self.parser.is_dict({}))
        self.assertFalse(self.parser.is_dict([]))
        self.assertTrue(self.parser.is_list([]))
        self.assertFalse(self.parser.is_list({}))
        self.assertTrue(self.parser.is_scalar('hello'))
        self.assertTrue(self.parser.is_scalar(1))
        self.assertTrue(self.parser.is_scalar(1.5))
        self.assertFalse(self.parser.is_scalar({}))
        self.assertFalse(self.parser.is_scalar([]))
        self.assertFalse(self.parser.is_scalar(()))