Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DSP-442 Add Convenience Methods to Ontology Information #265

Merged
merged 9 commits into from
Dec 7, 2020

Conversation

tobiasschweizer
Copy link
Contributor

resolves DSP-442

@tobiasschweizer tobiasschweizer self-assigned this Dec 3, 2020
@tobiasschweizer tobiasschweizer added the enhancement Improve existing code or new feature label Dec 3, 2020
@tobiasschweizer
Copy link
Contributor Author

@flavens I am already preparing a PR for the advanced search: dasch-swiss/dsp-ui-lib#239

@tobiasschweizer
Copy link
Contributor Author

I will add some more tests on Monday.

@tobiasschweizer
Copy link
Contributor Author

Ok, I added the tests. The PR is now ready for review.

@@ -143,6 +144,28 @@ describe("OntologiesEndpoint", () => {
expect((response.properties["http://0.0.0.0:3333/ontology/0001/anything/v2#hasListItem"] as ResourcePropertyDefinition).isLinkValueProperty).toBeFalsy();
expect((response.properties["http://0.0.0.0:3333/ontology/0001/anything/v2#hasListItem"] as ResourcePropertyDefinition).guiAttributes).toEqual(["hlist=<http://rdfh.ch/lists/0001/treeList>"]);

const classDefs = response.getAllClassDefinitions();
expect(classDefs.length).toEqual(9);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think there is a way to avoid a hardcoded number for all of the length assertions? If the test data changes, this could break so I'm thinking we could maybe make this more flexible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. However, I think unit tests should have static expectations. The more flexible assertions get, the more complexity grows. I once have written some testing helper method that was quite flexible and I only found out later that it never worked correctly. So the test would not have caught errors correctly.

Nevertheless, I think your point is valid. There is an ongoing discussion about how not to generate (static) test data from Knora anymore, but to manage it inside this lib. This would be possible once there is a formal spec that test data can be validated against. So then we would only care about the formal correctness of the test data, and this wouldn't change unless there is a change in the format spec.

Now, the ontology JSON-LD is actually generated from a test ontology in Knora. If this ontology changes, then the assertions would be wrong and would have to be updated.

@mdelez mdelez self-requested a review December 7, 2020 14:03
@tobiasschweizer tobiasschweizer merged commit 31a3044 into main Dec 7, 2020
@tobiasschweizer tobiasschweizer deleted the wip/dsp-442-ontology-info branch December 7, 2020 17:01
@kilchenmann kilchenmann changed the title Add Convenience Methods to Ontology Information DSP-442 Add Convenience Methods to Ontology Information Dec 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve existing code or new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants