示例#1
0
class SchemaorgObjectTest(Contract, unittest.TestCase):
    def setUp(self):
        fixture = os.path.join(os.path.dirname(__file__), "CITATION.cff")
        with open(fixture, "r") as f:
            cffstr = f.read()
            cff_object = yaml.safe_load(cffstr)
            self.so = SchemaorgObject(cff_object, initialize_empty=True)

    def test_author(self):
        pass

    def test_check_cff_object(self):
        with self.assertRaises(ValueError) as context:
            self.so.check_cff_object()
        self.assertTrue('Missing key "cff-version" in CITATION.cff file.' in
                        str(context.exception))

    def test_code_repository(self):
        pass

    def test_date_published(self):
        pass

    def test_description(self):
        pass

    def test_identifier(self):
        pass

    def test_keywords(self):
        pass

    def test_license(self):
        pass

    def test_name(self):
        pass

    def test_version(self):
        pass

    def test_print(self):
        pass
示例#2
0
 def setUp(self):
     fixture = os.path.join(os.path.dirname(__file__), "CITATION.cff")
     with open(fixture, "r") as f:
         cffstr = f.read()
         cff_object = yaml.safe_load(cffstr)
         self.so = SchemaorgObject(cff_object, initialize_empty=True)
示例#3
0
class SchemaorgObjectTest(Contract, unittest.TestCase):

    def setUp(self):
        fixture = os.path.join(os.path.dirname(__file__), "CITATION.cff")
        with open(fixture, "r") as f:
            cffstr = f.read()
            cff_object = yaml.safe_load(cffstr)
            self.so = SchemaorgObject(cff_object, initialize_empty=True)

    def test_check_cff_object(self):
        self.so.check_cff_object()
        # doesn't need an assert

    def test_author(self):
        self.so.add_author()
        expected_author = [{
            "@type": "Person",
            "affiliation": {
                "@type": "Organization",
                "legalName": "Netherlands eScience Center"
            },
            "familyName": "Spaaks",
            "givenName": "Jurriaan H."
        }, {
            "@type": "Person",
            "affiliation": {
                "@type": "Organization",
                "legalName": "Netherlands eScience Center"
            },
            "familyName": "Klaver",
            "givenName": "Tom"
        }, {
            "@type": "Person",
            "affiliation": {
                "@type": "Organization",
                "legalName": "Netherlands eScience Center"
            },
            "familyName": "Verhoeven",
            "givenName": "Stefan"
        }]
        self.assertListEqual(self.so.author, expected_author)

    def test_code_repository(self):
        self.so.add_code_repository()
        self.assertEqual(self.so.code_repository, 'https://github.com/citation-file-format/cff-converter-python')

    def test_date_published(self):
        self.so.add_date_published()
        self.assertEqual(self.so.date_published, '2018-05-09')

    def test_description(self):
        self.so.add_description()
        self.assertIsNone(self.so.description)

    def test_identifier(self):
        self.so.add_identifier()
        self.assertEqual(self.so.identifier, 'https://doi.org/10.5281/zenodo.1162057')

    def test_keywords(self):
        self.so.add_keywords()
        expected_keywords = ['citation', 'bibliography', 'cff', 'CITATION.cff']
        self.assertListEqual(self.so.keywords, expected_keywords)

    def test_license(self):
        self.so.add_license()
        self.assertEqual(self.so.license, 'https://spdx.org/licenses/Apache-2.0')

    def test_name(self):
        self.so.add_name()
        self.assertEqual(self.so.name, 'cffconvert')

    def test_version(self):
        self.so.add_version()
        self.assertEqual(self.so.version, '0.0.4')

    def test_print(self):
        actual_schemaorg = self.so.add_all().print()
        fixture = os.path.join(os.path.dirname(__file__), "schemaorg.json")
        with open(fixture, "r") as f:
            expected_schemaorg = f.read()
        self.assertEqual(actual_schemaorg, expected_schemaorg)
示例#4
0
class SchemaorgObjectTest(Contract, unittest.TestCase):
    def setUp(self):
        fixture = os.path.join(os.path.dirname(__file__), "CITATION.cff")
        with open(fixture, "r") as f:
            cffstr = f.read()
            cff_object = yaml.safe_load(cffstr)
            self.so = SchemaorgObject(cff_object, initialize_empty=True)

    def test_check_cff_object(self):
        self.so.check_cff_object()
        # doesn't need an assert

    def test_author(self):
        self.so.add_author()
        expected_author = [{
            "@type": "Person",
            "givenName": "Jisk",
            "familyName": "Attema",
            "affiliation": {
                "@type": "Organization",
                "legalName": "Netherlands eScience Center"
            }
        }, {
            "@id": "https://orcid.org/0000-0002-0989-929X",
            "@type": "Person",
            "givenName": "Faruk",
            "familyName": "Diblen",
            "affiliation": {
                "@type": "Organization",
                "legalName": "Netherlands eScience Center"
            }
        }]
        self.assertListEqual(self.so.author, expected_author)

    def test_code_repository(self):
        self.so.add_code_repository()
        self.assertEqual(self.so.code_repository,
                         'https://github.com/NLeSC/spot')

    def test_date_published(self):
        self.so.add_date_published()
        self.assertEqual(self.so.date_published, '2017-10-07')

    def test_description(self):
        self.so.add_description()
        self.assertIsNone(self.so.description)

    def test_identifier(self):
        self.so.add_identifier()
        self.assertEqual(self.so.identifier,
                         'https://doi.org/10.5281/zenodo.1003346')

    def test_keywords(self):
        self.so.add_keywords()
        expected_keywords = [
            'visualization', 'big data', 'visual data analytics',
            'multi-dimensional data'
        ]
        self.assertListEqual(self.so.keywords, expected_keywords)

    def test_license(self):
        self.so.add_license()
        self.assertEqual(self.so.license,
                         'https://spdx.org/licenses/Apache-2.0')

    def test_name(self):
        self.so.add_name()
        self.assertEqual(self.so.name, 'spot')

    def test_version(self):
        self.so.add_version()
        self.assertEqual(self.so.version, '0.1.0')

    def test_print(self):
        actual_schemaorg = self.so.add_all().print()
        fixture = os.path.join(os.path.dirname(__file__), "schemaorg.json")
        with open(fixture, "r") as f:
            expected_schemaorg = f.read()
        self.assertEqual(actual_schemaorg, expected_schemaorg)
class SchemaorgObjectTest(Contract, unittest.TestCase):
    def setUp(self):
        fixture = os.path.join(os.path.dirname(__file__), "CITATION.cff")
        with open(fixture, "r") as f:
            cffstr = f.read()
            cff_object = yaml.safe_load(cffstr)
            self.so = SchemaorgObject(cff_object, initialize_empty=True)

    def test_check_cff_object(self):
        self.so.check_cff_object()
        # doesn't need an assert

    def test_author(self):
        self.so.add_author()
        expected_author = [{
            "@type": "Person",
            "affiliation": {
                "@type": "Organization",
                "legalName": "Springsteen"
            },
            "familyName": "Van Zandt",
            "givenName": "Steven"
        }, {
            "@type": "Person",
            "affiliation": {
                "@type": "Organization",
                "legalName": "coverband"
            },
            "familyName": "van Zandt",
            "givenName": "Steven"
        }]
        self.assertListEqual(self.so.author, expected_author)

    def test_code_repository(self):
        self.so.add_code_repository()
        self.assertIsNone(self.so.code_repository)

    def test_date_published(self):
        self.so.add_date_published()
        self.assertEqual(self.so.date_published, '2018-01-16')

    def test_description(self):
        self.so.add_description()
        self.assertIsNone(self.so.description)

    def test_identifier(self):
        self.so.add_identifier()
        self.assertIsNone(self.so.identifier)

    def test_keywords(self):
        self.so.add_keywords()
        self.assertIsNone(self.so.keywords)

    def test_license(self):
        self.so.add_license()
        self.assertIsNone(self.so.license)

    def test_name(self):
        self.so.add_name()
        self.assertEqual(self.so.name, 'cff-converter-python')

    def test_version(self):
        self.so.add_version()
        self.assertEqual(self.so.version, '1.0.0')

    def test_print(self):
        actual_schemaorg = self.so.add_all().print()
        fixture = os.path.join(os.path.dirname(__file__), "schemaorg.json")
        with open(fixture, "r") as f:
            expected_schemaorg = f.read()
        self.assertEqual(actual_schemaorg, expected_schemaorg)
示例#6
0
class SchemaorgObjectTest(Contract, unittest.TestCase):
    def setUp(self):
        fixture = os.path.join(os.path.dirname(__file__), "CITATION.cff")
        with open(fixture, "r") as f:
            cffstr = f.read()
            cff_object = yaml.safe_load(cffstr)
            self.so = SchemaorgObject(cff_object, initialize_empty=True)

    def test_check_cff_object(self):
        self.so.check_cff_object()
        # doesn't need an assert

    def test_author(self):
        self.so.add_author()
        expected_author = [{
            "@type": "Person",
            "givenName": "Gonzalo",
            "familyName": "Fernández de Córdoba Jr.",
        }]
        self.assertListEqual(self.so.author, expected_author)

    def test_code_repository(self):
        self.so.add_code_repository()
        self.assertIsNone(self.so.code_repository)

    def test_date_published(self):
        self.so.add_date_published()
        self.assertEqual(self.so.date_published, "1999-12-31")

    def test_description(self):
        self.so.add_description()
        self.assertIsNone(self.so.description)

    def test_identifier(self):
        self.so.add_identifier()
        self.assertIsNone(self.so.identifier)

    def test_keywords(self):
        self.so.add_keywords()
        self.assertIsNone(self.so.keywords)

    def test_license(self):
        self.so.add_license()
        self.assertIsNone(self.so.license)

    def test_name(self):
        self.so.add_name()
        self.assertEqual(self.so.name, 'example title')

    def test_version(self):
        self.so.add_version()
        self.assertEqual(self.so.version, '1.0.0')

    def test_print(self):
        actual_schemaorg = self.so.add_all().print()
        fixture = os.path.join(os.path.dirname(__file__), "schemaorg.json")
        with open(fixture, "r") as f:
            expected_schemaorg = f.read()
        self.assertEqual(actual_schemaorg, expected_schemaorg)