def test_cla01_journal(self):
        """Prueba de revista para test_cla01_journal"""
        self.maxDiff = None
        config.DB_FILES = ['test_cla01.txt.gz']
        marc2dict = Marc2Dict()
        revistas = []

        registro_expected = [
            {
                'base_datos': 'CLA01',
                'titulo_revista': 'Revista geográfica',
                'issn': '0031-0581',
                'pais': None,
                'idioma': ['spa']
            }
        ]

        for dict in marc2dict.get_dict():
            revista_dict = RevistaDict(dict)
            revista_dict = revista_dict.to_dict()
            revistas.append(revista_dict)
            print(revista_dict)

        self.assertEqual(len(revistas), 1)
        self.assertEqual(revistas[0]['titulo_revista'], registro_expected[0]['titulo_revista'])
        self.assertEqual(revistas[0]['issn'], registro_expected[0]['issn'])
        self.assertEqual(revistas[0]['pais'], registro_expected[0]['pais'])
        self.assertEqual(revistas[0]['idioma'], registro_expected[0]['idioma'])
        self.assertEqual(revistas[0]['base_datos'], registro_expected[0]['base_datos'])
    def test_per01_journal(self):
        """Prueba de revista para test_per01_journal"""
        self.maxDiff = None
        config.DB_FILES = ['test_per01.txt.gz']
        marc2dict = Marc2Dict()
        revistas = []

        registro_expected = [
            {
                'base_datos': 'PER01',
                'titulo_revista': 'Papeis avulsos de zoologia',
                'issn': '0031-1049',
                'pais': 'BR',
                'idioma': ['eng']
            }
        ]

        for dict in marc2dict.get_dict():
            revista_dict = RevistaDict(dict)
            revista_dict = revista_dict.to_dict()
            revistas.append(revista_dict)
            print(revista_dict)

        self.assertEqual(len(revistas), 1)
        self.assertEqual(revistas[0]['titulo_revista'], registro_expected[0]['titulo_revista'])
        self.assertEqual(revistas[0]['issn'], registro_expected[0]['issn'])
        self.assertEqual(revistas[0]['pais'], registro_expected[0]['pais'])
        self.assertEqual(revistas[0]['idioma'], registro_expected[0]['idioma'])
        self.assertEqual(revistas[0]['base_datos'], registro_expected[0]['base_datos'])
    def test_disciplina_per_journal(self):
        """Prueba del campo disciplina de revista en PERIODICA."""
        disciplina = self._make_disciplina_PER01()
        self.maxDiff = None
        config.DB_FILES = ['test_per01.txt.gz']
        marc2dict = Marc2Dict()
        revistas = []

        for dict in marc2dict.get_dict():
            revista_dict = RevistaDict(dict)
            revistas.append(revista_dict)

        self.assertIsNotNone(revistas[0].disciplina, disciplina)
Ejemplo n.º 4
0
    def test_per01_basic(self):
        self.maxDiff = None
        config.DB_FILES = ['test_per01.txt.gz']
        marc2dict = Marc2Dict()
        marc_dicts = []

        for marc_dict in marc2dict.get_dict():
            marc_dicts.append(marc_dict)
        with open(os.path.join(self.test_files_path, 'test_per01.json'),
                  encoding='utf-8') as per01_json:
            marc_dict_expected = json.load(per01_json)

        self.assertDictEqual(marc_dict_expected, marc_dicts[0])
        self.assertEqual(1, len(marc_dicts))
Ejemplo n.º 5
0
    def test_cla01_basic(self):
        self.maxDiff = None
        self.config['db_files'] = 'test_cla01.txt.gz'
        marc2dict = Marc2Dict(self.config)
        marc_dicts = []

        for marc_dict in marc2dict.get_dict():
            marc_dicts.append(marc_dict)

        with open(os.path.join(self.test_files_path, 'test_cla01.json'),
                  encoding='utf-8') as cla01_json:
            marc_dict_expected = json.load(cla01_json)

        self.assertDictEqual(marc_dict_expected, marc_dicts[0])
        self.assertEqual(1, len(marc_dicts))
Ejemplo n.º 6
0
    def test_120_as_100(self):
        """Prueba para verificar etiqueta 120 como 100"""
        self.maxDiff = None
        config.DB_FILES = ['test_120_as_100.txt.gz']
        marc2dict = Marc2Dict()
        marc_dicts = []

        for marc_dict in marc2dict.get_dict():
            marc_dicts.append(marc_dict)

        with open(os.path.join(self.test_files_path, 'test_120_as_100.json'),
                  encoding='utf-8') as json_120_as_100:
            marc_dict_expected = json.load(json_120_as_100)

        self.assertDictEqual(marc_dict_expected, marc_dicts[0])
        self.assertEqual(1, len(marc_dicts))
Ejemplo n.º 7
0
    def test_cla01_length(self):
        self.maxDiff = None
        config.DB_FILES = ['test_cla01_length.txt.gz']
        marc2dict = Marc2Dict()
        marc_dicts = []

        for marc_dict in marc2dict.get_dict():
            marc_dicts.append(marc_dict)

        with open(os.path.join(self.test_files_path, 'test_cla01_length.json'),
                  encoding='utf-8') as cla01_length_json:
            marc_dicts_expected = json.load(cla01_length_json)

            self.assertEqual(2, len(marc_dicts))
            self.assertDictEqual(marc_dicts_expected[0], marc_dicts[0])
            self.assertDictEqual(marc_dicts_expected[1], marc_dicts[1])
Ejemplo n.º 8
0
    def test_subfield_dup(self):
        """Prueba para verificar cuando un sub-campo esta duplicado"""
        self.maxDiff = None
        config.DB_FILES = ['test_subfield_dup.txt.gz']
        marc2dict = Marc2Dict()
        marc_dicts = []

        for marc_dict in marc2dict.get_dict():
            marc_dicts.append(marc_dict)

        with open(os.path.join(self.test_files_path, 'test_subfield_dup.json'),
                  encoding='utf-8') as subfield_dup_json:
            marc_dict_expected = json.load(subfield_dup_json)

        self.assertDictEqual(marc_dict_expected, marc_dicts[0])
        self.assertEqual(1, len(marc_dicts))
Ejemplo n.º 9
0
    def test_fix_100z(self):
        """"Prueba para verificar la corrección del sub-campo 100z encontrado
        como otro sub-campo"""
        self.maxDiff = None
        config.DB_FILES = ['test_fix_100z.txt.gz']
        marc2dict = Marc2Dict()
        marc_dicts = []

        for marc_dict in marc2dict.get_dict():
            marc_dicts.append(marc_dict)

        with open(os.path.join(self.test_files_path, 'test_fix_100z.json'),
                  encoding='utf-8') as fix_100z_json:
            marc_dict_expected = json.load(fix_100z_json)

        self.assertDictEqual(marc_dict_expected, marc_dicts[0])
        self.assertEqual(1, len(marc_dicts))
Ejemplo n.º 10
0
    def test_claper_length(self):
        self.maxDiff = None
        self.config['db_files'] = 'test_cla01.txt.gz,test_per01.txt.gz'
        marc2dict = Marc2Dict(self.config)
        marc_dicts = []

        for marc_dict in marc2dict.get_dict():
            marc_dicts.append(marc_dict)

        with open(os.path.join(self.test_files_path, 'test_per01.json'),
                  encoding='utf-8') as per01_json, \
                open(os.path.join(self.test_files_path, 'test_cla01.json'),
                     encoding='utf-8') as cla01_json:
            cla01_dict = json.load(cla01_json)
            per01_dict = json.load(per01_json)

            self.assertEqual(2, len(marc_dicts))
            self.assertDictEqual(cla01_dict, marc_dicts[0])
            self.assertDictEqual(per01_dict, marc_dicts[1])