You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.5 KiB

# -*- coding: utf-8 -*-
import unittest
import yaml
import testenv
from papers import endecoder
from str_fixtures import bibyaml_raw0, bibtexml_raw0, bibtex_raw0, metadata_raw0
def compare_yaml_str(s1, s2):
if s1 == s2:
return True
else:
y1 = yaml.safe_load(s1)
y2 = yaml.safe_load(s2)
return y1 == y2
class TestEnDecode(unittest.TestCase):
def test_endecode_bibyaml(self):
decoder = endecoder.EnDecoder()
entry = decoder.decode_bibdata(bibyaml_raw0)
bibyaml_output0 = decoder.encode_bibdata(entry)
self.assertEqual(bibyaml_raw0, bibyaml_output0)
self.assertTrue(compare_yaml_str(bibyaml_raw0, bibyaml_output0))
def test_endecode_bibtexml(self):
decoder = endecoder.EnDecoder()
entry = decoder.decode_bibdata(bibtexml_raw0)
bibyaml_output0 = decoder.encode_bibdata(entry)
self.assertTrue(compare_yaml_str(bibyaml_raw0, bibyaml_output0))
def test_endecode_bibtex(self):
decoder = endecoder.EnDecoder()
entry = decoder.decode_bibdata(bibtex_raw0)
bibyaml_output0 = decoder.encode_bibdata(entry)
self.assertTrue(compare_yaml_str(bibyaml_raw0, bibyaml_output0))
def test_endecode_metadata(self):
decoder = endecoder.EnDecoder()
entry = decoder.decode_metadata(metadata_raw0)
metadata_output0 = decoder.encode_metadata(entry)
self.assertEqual(metadata_raw0, metadata_output0)