Merge branch '21639-keep-cache-dict' refs #21639
[arvados.git] / services / api / test / integration / discovery_document_test.rb
index 672f52f7d49fa1b6c0119eb2fb558d7eb42e5241..37e775029733be80bcf101f8f544da626c985372 100644 (file)
@@ -31,20 +31,25 @@ class DiscoveryDocumentTest < ActionDispatch::IntegrationTest
     canonical = Hash[CANONICAL_FIELDS.map { |key| [key, json_response[key]] }]
     missing = canonical.select { |key| canonical[key].nil? }
     assert(missing.empty?, "discovery document missing required fields")
+    actual_json = JSON.pretty_generate(canonical)
 
-    expected = JSON.pretty_generate(canonical)
-    src_path = Rails.root.join("../../doc/arvados-v1-discovery.json")
+    # Currently the Python SDK is the only component using this copy of the
+    # discovery document, and storing it with the source simplifies the build
+    # process, so it lives there. If another component wants to use it later,
+    # we might consider moving it to a more general subdirectory, but then the
+    # Python build process will need to be extended to accommodate that.
+    src_path = Rails.root.join("../../sdk/python/arvados-v1-discovery.json")
     begin
-      actual = File.open(src_path) { |f| f.read }
+      expected_json = File.open(src_path) { |f| f.read }
     rescue Errno::ENOENT
-      actual = "(#{src_path} not found)"
+      expected_json = "(#{src_path} not found)"
     end
 
     out_path = Rails.root.join("tmp", "test-arvados-v1-discovery.json")
-    if expected != actual
-      File.open(out_path, "w") { |f| f.write(expected) }
+    if expected_json != actual_json
+      File.open(out_path, "w") { |f| f.write(actual_json) }
     end
-    assert_equal(expected, actual, [
+    assert_equal(expected_json, actual_json, [
                    "#{src_path} did not match the live discovery document",
                    "Current live version saved to #{out_path}",
                    "Commit that to #{src_path} to regenerate documentation",