class CodemetaObjectTest(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.co = CodemetaObject(cff_object, initialize_empty=True) def test_author(self): pass def test_check_cff_object(self): with self.assertRaises(ValueError) as context: self.co.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
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.co = CodemetaObject(cff_object, initialize_empty=True)
class CodemetaObjectTest(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.co = CodemetaObject(cff_object, initialize_empty=True) def test_check_cff_object(self): self.co.check_cff_object() # doesn't need an assert def test_author(self): self.co.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.co.author, expected_author) def test_code_repository(self): self.co.add_code_repository() self.assertIsNone(self.co.code_repository) def test_date_published(self): self.co.add_date_published() self.assertEqual(self.co.date_published, '2018-01-16') def test_description(self): self.co.add_description() self.assertIsNone(self.co.description) def test_identifier(self): self.co.add_identifier() self.assertIsNone(self.co.identifier) def test_keywords(self): self.co.add_keywords() self.assertIsNone(self.co.keywords) def test_license(self): self.co.add_license() self.assertIsNone(self.co.license) def test_name(self): self.co.add_name() self.assertEqual(self.co.name, 'cff-converter-python') def test_version(self): self.co.add_version() self.assertEqual(self.co.version, '1.0.0') def test_print(self): actual_codemeta = self.co.add_all().print() fixture = os.path.join(os.path.dirname(__file__), "codemeta.json") with open(fixture, "r") as f: expected_codemeta = f.read() self.assertEqual(actual_codemeta, expected_codemeta)
class CodemetaObjectTest(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.co = CodemetaObject(cff_object, initialize_empty=True) def test_check_cff_object(self): self.co.check_cff_object() # doesn't need an assert def test_author(self): self.co.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.co.author, expected_author) def test_code_repository(self): self.co.add_code_repository() self.assertEqual(self.co.code_repository, 'https://github.com/NLeSC/spot') def test_date_published(self): self.co.add_date_published() self.assertEqual(self.co.date_published, '2017-10-07') def test_description(self): self.co.add_description() self.assertIsNone(self.co.description) def test_identifier(self): self.co.add_identifier() self.assertEqual(self.co.identifier, 'https://doi.org/10.5281/zenodo.1003346') def test_keywords(self): self.co.add_keywords() expected_keywords = [ 'visualization', 'big data', 'visual data analytics', 'multi-dimensional data' ] self.assertListEqual(self.co.keywords, expected_keywords) def test_license(self): self.co.add_license() self.assertEqual(self.co.license, 'https://spdx.org/licenses/Apache-2.0') def test_name(self): self.co.add_name() self.assertEqual(self.co.name, 'spot') def test_version(self): self.co.add_version() self.assertEqual(self.co.version, '0.1.0') def test_print(self): actual_codemeta = self.co.add_all().print() fixture = os.path.join(os.path.dirname(__file__), "codemeta.json") with open(fixture, "r") as f: expected_codemeta = f.read() self.assertEqual(actual_codemeta, expected_codemeta)
class CodemetaObjectTest(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.co = CodemetaObject(cff_object, initialize_empty=True) def test_check_cff_object(self): self.co.check_cff_object() # doesn't need an assert def test_author(self): self.co.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": "MyAffiliation" }, "name": "mysteryauthor" }] self.assertListEqual(self.co.author, expected_author) def test_code_repository(self): self.co.add_code_repository() self.assertEqual( self.co.code_repository, 'https://github.com/citation-file-format/cff-converter-python') def test_date_published(self): self.co.add_date_published() self.assertEqual(self.co.date_published, '2018-01-16') def test_description(self): self.co.add_description() self.assertIsNone(self.co.description) def test_identifier(self): self.co.add_identifier() self.assertEqual(self.co.identifier, 'https://doi.org/10.5281/zenodo.1162057') def test_keywords(self): self.co.add_keywords() expected_keywords = ['citation', 'bibliography', 'cff', 'CITATION.cff'] self.assertListEqual(self.co.keywords, expected_keywords) def test_license(self): self.co.add_license() self.assertEqual(self.co.license, 'https://spdx.org/licenses/Apache-2.0') def test_name(self): self.co.add_name() self.assertEqual(self.co.name, 'cff-converter-python') def test_version(self): self.co.add_version() self.assertEqual(self.co.version, '1.0.0') def test_print(self): actual_codemeta = self.co.add_all().print() fixture = os.path.join(os.path.dirname(__file__), "codemeta.json") with open(fixture, "r") as f: expected_codemeta = f.read() self.assertEqual(actual_codemeta, expected_codemeta)
class CodemetaObjectTest(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.co = CodemetaObject(cff_object, initialize_empty=True) def test_check_cff_object(self): self.co.check_cff_object() # doesn't need an assert def test_author(self): self.co.add_author() expected_author = [{ "@type": "Person", "givenName": "Gonzalo", "familyName": "Fernández de Córdoba Jr.", }] self.assertListEqual(self.co.author, expected_author) def test_code_repository(self): self.co.add_code_repository() self.assertIsNone(self.co.code_repository) def test_date_published(self): self.co.add_date_published() self.assertEqual(self.co.date_published, "1999-12-31") def test_description(self): self.co.add_description() self.assertIsNone(self.co.description) def test_identifier(self): self.co.add_identifier() self.assertIsNone(self.co.identifier) def test_keywords(self): self.co.add_keywords() self.assertIsNone(self.co.keywords) def test_license(self): self.co.add_license() self.assertIsNone(self.co.license) def test_name(self): self.co.add_name() self.assertEqual(self.co.name, 'example title') def test_version(self): self.co.add_version() self.assertEqual(self.co.version, '1.0.0') def test_print(self): actual_codemeta = self.co.add_all().print() fixture = os.path.join(os.path.dirname(__file__), "codemeta.json") with open(fixture, "r") as f: expected_codemeta = f.read() self.assertEqual(actual_codemeta, expected_codemeta)