Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

String-literal conneg tests #10

Open
michielbdejong opened this issue Feb 10, 2021 · 7 comments
Open

String-literal conneg tests #10

michielbdejong opened this issue Feb 10, 2021 · 7 comments

Comments

@michielbdejong
Copy link
Member

When I originally started exploring the test for conneg, it was easy to check strings against strings. Once that worked, I added the tests for asTriples. I think we will never have good maintainable string-based conneg tests, so maybe we should just use the as triples tests only? So:

  • take a string in content type 1
  • upload it
  • retrieve it, accepting content type 2
  • rather than looking at the response body string, just parse it into rdflib
  • compare the resulting set of triples to the set triples in the document that was uploaded.
@edwardsph
Copy link
Collaborator

I agree but I would still do a simple first test to establish you got back something in the correct format then the second test only compares the graph. Note that this is where you need the set based comparison I used elsewhere not equality since you may also get server generated triples.

@bourgeoa
Copy link
Collaborator

Don't you think parsing is enough. If parsing fail then the document is wrong.

@ylebre
Copy link
Member

ylebre commented Feb 10, 2021

I agree that the best way is to parse the result into RDFlib. Depending on the situation we could opt to just validate that the expected triples are in the result, ignoring any other triples that might be in there?

@edwardsph
Copy link
Collaborator

edwardsph commented Feb 10, 2021 via email

@bourgeoa
Copy link
Collaborator

bourgeoa commented Feb 10, 2021

If you convert to an array of triples

The array of triples will still need to be normalised for blank-nodes.

@michielbdejong
Copy link
Member Author

I commented out the tests so they don't show up as skipped. We could remove them altogether when we're certain we don't want them back.

@bourgeoa
Copy link
Collaborator

@michielbdejong

compare the resulting set of triples to the set triples in the document that was uploaded.

To make the comparison easier to understand and follow, I propose to make :

  • the triples comparison on sorted array of N-triples : store.toNT(),split('\n').sort()
  • to normalize blank nodes with the following RegExp :
    ArrayOfNTriples.map(item => item.replace(RegExp((<\_:[\w-]*>)|(\b\_:[\w-]*), gm), '<_:b0>')
    replace with <_:b0> all words (containing letters, digits, _ and -), that begin with <_: or _:

I made the test on NSS and CSS. Or do you prefer to keep the tests as they are ?

@bourgeoa bourgeoa reopened this Feb 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants