Ejemplo n.º 1
0
    def test_read_mcf(self):
        """Test reading MCF files"""

        with self.assertRaises(IOError):
            mcf = read_mcf(get_abspath('../404.mcf'))

        mcf = read_mcf(get_abspath('../sample.mcf'))
        self.assertIsInstance(mcf, dict, 'Expected dict')

        self.assertTrue('metadata' in mcf, 'Expected metadata section')
Ejemplo n.º 2
0
    def test_read_mcf(self):
        """Test reading MCF files"""

        with self.assertRaises(IOError):
            mcf = read_mcf(get_abspath('../404.mcf'))

        mcf = read_mcf(get_abspath('../sample.mcf'))
        self.assertIsInstance(mcf, dict, 'Expected dict')

        self.assertTrue('metadata' in mcf, 'Expected metadata section')
Ejemplo n.º 3
0
    def test_nested_mcf(self):
        """test nested mcf support"""

        mcf = read_mcf(get_abspath('child.mcf'))

        self.assertEqual(mcf['metadata']['identifier'], '1234',
                         'Expected specific identifier')

        self.assertEqual(mcf['identification']['title_en'], 'title in English',
                         'Expected specific title')

        self.assertIsInstance(mcf, dict, 'Expected dict')
Ejemplo n.º 4
0
    def test_nested_mcf(self):
        """test nested mcf support"""

        mcf = read_mcf(get_abspath('child.mcf'))

        self.assertEqual(mcf['metadata']['identifier'], '1234',
                         'Expected specific identifier')

        self.assertEqual(mcf['identification']['title_en'],
                         'title in English',
                         'Expected specific title')

        self.assertIsInstance(mcf, dict, 'Expected dict')
Ejemplo n.º 5
0
    def test_read_mcf(self):
        """Test reading MCF files, strings or ConfigParser objects"""

        # test as file
        with self.assertRaises(IOError):
            mcf = read_mcf(get_abspath('../404.mcf'))

        mcf = read_mcf(get_abspath('../sample.mcf'))
        self.assertIsInstance(mcf, dict, 'Expected dict')

        self.assertTrue('metadata' in mcf, 'Expected metadata section')

        # test as string
        with open(get_abspath('../sample.mcf')) as fh:
            mcf_string = fh.read()

        mcf = read_mcf(mcf_string)
        self.assertTrue('metadata' in mcf, 'Expected metadata section')

        # test as ConfigParser object
        mcf_cp = ConfigParser()
        mcf_cp.readfp(StringIO(mcf_string))
        mcf = read_mcf(mcf_cp)
        self.assertTrue('metadata' in mcf, 'Expected metadata section')
Ejemplo n.º 6
0
    def test_read_mcf(self):
        """Test reading MCF files, strings or ConfigParser objects"""

        # test as file
        with self.assertRaises(IOError):
            mcf = read_mcf(get_abspath('../404.mcf'))

        mcf = read_mcf(get_abspath('../sample.mcf'))
        self.assertIsInstance(mcf, dict, 'Expected dict')

        self.assertTrue('metadata' in mcf, 'Expected metadata section')

        # test as string
        with open(get_abspath('../sample.mcf')) as fh:
            mcf_string = fh.read()

        mcf = read_mcf(mcf_string)
        self.assertTrue('metadata' in mcf, 'Expected metadata section')

        # test as ConfigParser object
        mcf_cp = ConfigParser()
        mcf_cp.readfp(StringIO(mcf_string))
        mcf = read_mcf(mcf_cp)
        self.assertTrue('metadata' in mcf, 'Expected metadata section')