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

JSON-LD resources endpoint should return consistent ordering of data in arrays #11820

Open
jacobtylerwalls opened this issue Feb 26, 2025 · 0 comments
Labels

Comments

@jacobtylerwalls
Copy link
Member

@aarongundel and I noticed that the the JSON-LD endpoint returns arrays of data that aren't deterministically ordered.

Adjusting this test to repeat the GET and assert equal results gives occasional failures (to be clear, not suggesting we add this as a potentially flaky test, just demoing the issue):

diff --git a/tests/exporter/jsonld_export_tests.py b/tests/exporter/jsonld_export_tests.py
index 457dd0a910..f1e618877a 100644
--- a/tests/exporter/jsonld_export_tests.py
+++ b/tests/exporter/jsonld_export_tests.py
@@ -694,6 +694,12 @@ class JsonLDExportTests(ArchesTestCase):
         response = self.client.get(url, secure=False)
         self.assertTrue(response.status_code == 200)
         js = response.json()
+
+        self.maxDiff = None
+        response_again = self.client.get(url, secure=False)
+        js_again = response_again.json()
+        self.assertEqual(js, js_again)
+
         self.assertTrue("@id" in js)
         self.assertTrue(
             js["@id"]
======================================================================
FAIL: test_5299_complex (tests.exporter.jsonld_export_tests.JsonLDExportTests.test_5299_complex)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/jwalls/prj/arches/tests/exporter/jsonld_export_tests.py", line 701, in test_5299_complex
    self.assertEqual(js, js_again)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
AssertionError: {'@id[507 chars]node/080d16b0-0722-11ea-b628-acde48001122', '@[692 chars]}}]}} != {'@id[507 chars]node/222d5c4e-0722-11ea-b628-acde48001122', '@[692 chars]}}]}}
  {'@id': 'http://localhost:8000/resources/7f90ff58-0722-11ea-b628-acde48001122',
   '@type': 'http://www.cidoc-crm.org/cidoc-crm/E22_Man-Made_Object',
   'http://www.cidoc-crm.org/cidoc-crm/P108i_was_produced_by': {'@id': 'http://localhost:8000/tile/caced9b0-f717-4557-9c64-ef87f646c9c1/node/fdbc4f50-0721-11ea-b628-acde48001122',
                                                                '@type': 'http://www.cidoc-crm.org/cidoc-crm/E12_Production',
-                                                               'http://www.cidoc-crm.org/cidoc-crm/P10i_contains': [{'@id': 'http://localhost:8000/tile/caced9b0-f717-4557-9c64-ef87f646c9c1/node/080d16b0-0722-11ea-b628-acde48001122',
?                                                                                                                                                                                                  ^^^^^^ -------------

+                                                               'http://www.cidoc-crm.org/cidoc-crm/P10i_contains': [{'@id': 'http://localhost:8000/tile/caced9b0-f717-4557-9c64-ef87f646c9c1/node/222d5c4e-0722-11ea-b628-acde48001122',
?                                                                                                                                                                                                  ^^^^^^^^^^^^^^^^^^^

+                                                                                                                     '@type': 'http://www.cidoc-crm.org/cidoc-crm/E4_Period',
+                                                                                                                     'http://www.cidoc-crm.org/cidoc-crm/P3_has_note': {'@language': 'en',
+                                                                                                                                                                        '@value': 'Note'}},
+                                                                                                                    {'@id': 'http://localhost:8000/tile/caced9b0-f717-4557-9c64-ef87f646c9c1/node/080d16b0-0722-11ea-b628-acde48001122',
                                                                                                                      '@type': 'http://www.cidoc-crm.org/cidoc-crm/E4_Period',
                                                                                                                      'http://www.cidoc-crm.org/cidoc-crm/P4_has_time-span': {'@id': 'http://localhost:8000/tile/caced9b0-f717-4557-9c64-ef87f646c9c1/node/3d38c276-0722-11ea-b628-acde48001122',
                                                                                                                                                                              '@type': 'http://www.cidoc-crm.org/cidoc-crm/E52_Time-Span',
                                                                                                                                                                              'http://www.cidoc-crm.org/cidoc-crm/P82a_begin_of_the_begin': {'@type': 'http://www.w3.org/2001/XMLSchema#dateTime',
-                                                                                                                                                                                                                                            '@value': '2019-11-01'}}},
?                                                                                                                                                                                                                                                                     ^

+                                                                                                                                                                                                                                            '@value': '2019-11-01'}}}]}}
?                                                                                                                                                                                                                                                                     ^^^

-                                                                                                                    {'@id': 'http://localhost:8000/tile/caced9b0-f717-4557-9c64-ef87f646c9c1/node/222d5c4e-0722-11ea-b628-acde48001122',
-                                                                                                                     '@type': 'http://www.cidoc-crm.org/cidoc-crm/E4_Period',
-                                                                                                                     'http://www.cidoc-crm.org/cidoc-crm/P3_has_note': {'@language': 'en',
-                                                                                                                                                                        '@value': 'Note'}}]}}

----------------------------------------------------------------------
Ran 1 test in 9.091s

FAILED (failures=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

1 participant