1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
7 class ArvadosApiClientTest < ActiveSupport::TestCase
8 # We use a mock instead of making real API calls, so there's no need to reset.
9 reset_api_fixtures :after_each_test, false
11 test 'successful stubbed api request' do
12 stub_api_calls_with_body '{"foo":"bar","baz":0}'
14 resp = ArvadosApiClient.new_or_current.api Link, ''
15 assert_equal Hash, resp.class
16 assert_equal 'bar', resp[:foo]
17 assert_equal 0, resp[:baz]
20 test 'exception if server returns non-JSON' do
21 stub_api_calls_with_invalid_json
22 assert_raises ArvadosApiClient::InvalidApiResponseException do
24 resp = ArvadosApiClient.new_or_current.api Link, ''