def test_good_references(self):
     test_refs_path = (Path(__file__).resolve().parent.joinpath(
         "../../optimade/server/data/test_references.json"))
     with open(test_refs_path, "r") as f:
         good_refs = json.load(f)
     for doc in good_refs:
         doc["last_modified"] = doc["last_modified"]["$date"]
         ReferenceResource(**ReferenceMapper.map_back(doc))
    def test_bad_references(self):
        bad_refs = [
            {"id": "AAAA", "type": "references", "doi": "10.1234/1234"},  # bad id
            {"id": "newton1687", "type": "references"},  # missing all fields
            {
                "id": "newton1687",
                "type": "reference",
                "doi": "10.1234/1234",
            },  # wrong type
        ]

        for ref in bad_refs:
            with self.assertRaises(ValidationError):
                ReferenceResource(**ReferenceMapper.map_back(ref))
Exemple #3
0
 def test_good_references(self):
     good_refs = optimade.server.data.references
     for doc in good_refs:
         ReferenceResource(**ReferenceMapper.map_back(doc))