-
Notifications
You must be signed in to change notification settings - Fork 18
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
feature(api-v2): Generate client test data for ontologies, resources, search, and lists #1549
Conversation
In v2 test data for resources, I cannot find JSON data for creation and metadata update ops. |
see https://github.com/dasch-swiss/knora-api-js-lib/blob/9e16288916c2e2a5a66b7d0d9f4448c7dd911438/src/api/v2/resource/resources-endpoint.spec.ts#L96-L648 for the tests I have written so far (test data hard coded) |
I think the the values themselves do not have to be tested thoroughly because this is already done in https://github.com/dasch-swiss/knora-api-js-lib/blob/wip/create-resource/src/api/v2/values/values-endpoint.spec.ts with test data generated by Knora. |
I just included the stuff you asked for 😜: |
Will add test data for the update operations, too. |
Thanks! |
In the meantime I am changing from static to generated v2 test data files. Works already for the ontologies! :-) My goal is to get rid of static test data at all. |
there is a failing test in ExceptionHandlerR2RSpec: https://github.com/dasch-swiss/knora-api/pull/1549/checks?check_run_id=341570711#step:6:1310 |
override val description: String = "An endpoint for working with Knora lists." | ||
override val functions: Seq[ClientFunction] = Seq.empty | ||
|
||
def knoraApiPath: Route = getList ~ getNode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment that this is actually the route definition?
private val ALL_LANGUAGES = "allLanguages" | ||
private val LAST_MODIFICATION_DATE = "lastModificationDate" | ||
|
||
def knoraApiPath: Route = { | ||
def knoraApiPath: Route = dereferenceOntologyIri ~ getOntologyMetadata ~ updateOntologyMetadata ~ getOntologyMetadataForProjects ~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment that this is actually the route definition?
@@ -127,138 +147,61 @@ class ResourcesRouteV2(routeData: KnoraRouteData) extends KnoraRoute(routeData) | |||
} | |||
} | |||
|
|||
def knoraApiPath: Route = createResource ~ updateResourceMetadata ~ getResourcesInProject ~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment that this is actually the route definition?
private val LIMIT_TO_PROJECT = "limitToProject" | ||
private val LIMIT_TO_RESOURCE_CLASS = "limitToResourceClass" | ||
private val OFFSET = "offset" | ||
private val LIMIT_TO_STANDOFF_CLASS = "limitToStandoffClass" | ||
|
||
def knoraApiPath: Route = fullTextSearchCount ~ fullTextSearch ~ gravsearchCountGet ~ gravsearchCountPost ~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a comment that this is actually the route definition?
That's not a failing test, the test is supposed to throw an exception. The GitHub CI build is actually failing here, but I don't know why: https://github.com/dasch-swiss/knora-api/pull/1549/checks?check_run_id=341570711#step:6:2012 |
I've added it to all routes. I added more test requests/responses for the resources route. Do you want update requests for the ontologies route too? |
Great, thanks.
Yes, we will need that too. Could you also create JSON test data for a resource preview (response to a creation request)? |
The preview JSON data has a higher priority to finish dasch-swiss/dsp-js-lib#115, so if you need more time for the ontologies and want to do this in a subsequent PR, that's also fine. |
Yes, because I'd like to finish #1509 first. |
When I access http://localhost:3333/clientapi/typescript I now get { |
I think this is too much precision, JS serializes this to "100000000000000". |
Maybe I could look at https://github.com/royNiladri/js-big-decimal or some similar lib. |
if possible, could you also generate data for
|
Sorry, stupid mistake. |
When I try to generate client api code I now get: {"error":"org.knora.webapi.ClientApiGenerationException: Failed to get test data: The requested resource could not be found."} However, I can get http://localhost:3333/v2/resourcespreview/http%3A%2F%2Frdfh.ch%2F0001%2Fa-thing |
@@ -376,7 +376,7 @@ class ResourcesRouteV2(routeData: KnoraRouteData) extends KnoraRoute(routeData) | |||
|
|||
private def getResourcesPreviewTestResponse: Future[SourceCodeFileContent] = { | |||
for { | |||
responseStr <- doTestDataRequest(Get(s"${baseApiUrl}resourcespreview/${SharedTestDataADM.AThing.iriEncoded}")) | |||
responseStr <- doTestDataRequest(Get(s"$baseApiUrl/resourcespreview/${SharedTestDataADM.AThing.iriEncoded}")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you are still missing v2: http://0.0.0.0:3333/resourcespreview/http%3A%2F%2Frdfh.ch%2F0001%2Fa-thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall I fix it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm doing it now along with the other stuff you asked for.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thank you.
Yet another stupid mistake. I think I need to hibernate for the winter. Can I change the file extensions to |
I experienced some problems earlier with that extension in the past when loading the files in a JS env. But we can give it a try in a separate PR. I am supposed to publish a new version of knora-api-js-lib today for @lrosenth, so I just want to finish resource creation. |
OK please try it now. |
Ok, that's all I need to finish dasch-swiss/dsp-js-lib#115, thanks! I spotted a potential issue for the automatic integration tests in Knora we want to set up (#1554): some of the data is dynamic (such as creation / modification dates) and the tests will fail because the assertions are hard-coded (but they won't fail because of an actual problem we would have to fix). |
I think I've fixed this now. Let me know if it's OK to merge. |
Works :-) |
Did you forget to press the "Approve" button, or is there something else I need to do? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I did a final check. Good to go!
Thanks for your patience! |
No worries! |
Once this is merged, could you update the branches for the modification date and the time value in Knora. I then have to regenerate the client data from these branches to integrate them in the PR is knora-api-js-lib. |
This PR incorporates more API v2 routes into the client code generation framework so they can return client test data.
Resolves #1548.