def test_other_names(models): org = Organisation.select().first() raw_data0 = open(os.path.join(os.path.dirname(__file__), "data", "othernames.json"), "r").read() data0 = load_yaml_json("othernames000.json", raw_data0) assert isinstance(data0, list) and isinstance(data0[0], NestedDict) data0 = load_yaml_json(None, source=raw_data0, content_type="json") assert isinstance(data0, list) and isinstance(data0[0], NestedDict) data0 = load_yaml_json(None, source=raw_data0) assert isinstance(data0, list) and isinstance(data0[0], NestedDict) task0 = OtherNameRecord.load_from_json(filename="othernames000.json", source=raw_data0, org=org) data = task0.to_dict() raw_data = json.dumps(data, cls=JSONEncoder) task = OtherNameRecord.load_from_json(filename="othernames001.json", source=raw_data, org=org) assert len(data0) == len(task.to_dict()["records"])
def test_work_task(models): org = Organisation.select().first() raw_data0 = open(os.path.join(os.path.dirname(__file__), "data", "example_works.json"), "r").read() data0 = load_yaml_json("test0001.json", raw_data0) assert isinstance(data0, list) and isinstance(data0[0], NestedDict) data0 = load_yaml_json(None, source=raw_data0, content_type="json") assert isinstance(data0, list) and isinstance(data0[0], NestedDict) data0 = load_yaml_json(None, source=raw_data0) assert isinstance(data0, list) and isinstance(data0[0], NestedDict) task0 = WorkRecord.load_from_json(filename="work0042.json", source=raw_data0, org=org) data = task0.to_export_dict() raw_data = json.dumps(data, cls=JSONEncoder) task = WorkRecord.load_from_json(filename="work0001.json", source=raw_data, org=org) export = task.to_export_dict() for a in ["id", "filename", "created-at", "updated-at"]: del(export[a]) del(data[a]) assert data == export
def test_researcher_urls(models): org = Organisation.select().first() raw_data0 = open(os.path.join(os.path.dirname(__file__), "data", "researchurls.json"), "r").read() data0 = load_yaml_json("researchurls.json", raw_data0) assert isinstance(data0, list) and isinstance(data0[0], NestedDict) task0 = ResearcherUrlRecord.load_from_json(filename="researchurls000.json", source=raw_data0, org=org) data = task0.to_dict() raw_data = json.dumps(data, cls=JSONEncoder) task = ResearcherUrlRecord.load_from_json(filename="researchurls001.json", source=raw_data, org=org) assert len(data0) == len(task.to_dict()["records"])
def test_other_names(models): org = Organisation.get() raw_data0 = readup_test_data("othernames.json", "r") data0 = load_yaml_json("othernames000.json", raw_data0) assert isinstance(data0, list) and isinstance(data0[0], NestedDict) data0 = load_yaml_json(None, source=raw_data0, content_type="json") assert isinstance(data0, list) and isinstance(data0[0], NestedDict) data0 = load_yaml_json(None, source=raw_data0) assert isinstance(data0, list) and isinstance(data0[0], NestedDict) task0 = PropertyRecord.load_from_json(filename="othernames000.json", source=raw_data0, org=org, file_property_type="NAME") data = task0.to_dict(recurse=True) raw_data = json.dumps(data, cls=JSONEncoder) task = PropertyRecord.load_from_json(filename="othernames001.json", source=raw_data, org=org, file_property_type="NAME") assert len(data0) == len(task.to_dict(recurse=True)["records"])