From b5436d9277da44c5cd6bffe54196c9807581abd6 Mon Sep 17 00:00:00 2001 From: Devin Gaffney Date: Thu, 5 Sep 2024 05:27:14 -0700 Subject: [PATCH] review and resolve broken tests --- test/models/bot/alegre_2_test.rb | 2 +- test/models/bot/alegre_3_test.rb | 2 +- test/models/bot/alegre_test.rb | 2 +- test/models/bot/smooch_6_test.rb | 2 ++ test/models/explainer_test.rb | 1 + 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/test/models/bot/alegre_2_test.rb b/test/models/bot/alegre_2_test.rb index 29e1056640..efe63f0d47 100644 --- a/test/models/bot/alegre_2_test.rb +++ b/test/models/bot/alegre_2_test.rb @@ -315,7 +315,7 @@ def teardown WebMock.stub_request(:post, 'http://alegre.test/text/similarity/').to_return(body: 'success') WebMock.stub_request(:delete, 'http://alegre.test/text/similarity/').to_return(body: { success: true }.to_json) WebMock.stub_request(:delete, 'http://alegre.test/image/similarity/').to_return(body: { success: true }.to_json) - WebMock.stub_request(:post, 'http://alegre.test/text/similarity/search/').to_return(body: { success: true }.to_json) + WebMock.stub_request(:post, 'http://alegre.test/similarity/sync/text').to_return(body: { success: true }.to_json) WebMock.stub_request(:post, 'http://alegre.test/image/ocr/').to_return(body: { text: 'Foo bar' }.to_json) WebMock.stub_request(:post, 'http://alegre.test/similarity/sync/image').to_return(body: { result: [ diff --git a/test/models/bot/alegre_3_test.rb b/test/models/bot/alegre_3_test.rb index 5a7a90cfe5..1d9b74cec2 100644 --- a/test/models/bot/alegre_3_test.rb +++ b/test/models/bot/alegre_3_test.rb @@ -149,7 +149,7 @@ def teardown WebMock.disable_net_connect! allow: /#{CheckConfig.get('elasticsearch_host')}|#{CheckConfig.get('storage_endpoint')}/ WebMock.stub_request(:post, 'http://alegre/text/similarity/').to_return(body: 'success') WebMock.stub_request(:delete, 'http://alegre/text/similarity/').to_return(body: {success: true}.to_json) - WebMock.stub_request(:post, 'http://alegre/text/similarity/search/').to_return(body: {success: true}.to_json) + WebMock.stub_request(:post, 'http://alegre/similarity/sync/text').to_return(body: {success: true}.to_json) WebMock.stub_request(:post, 'http://alegre/audio/similarity/').to_return(body: { "success": true }.to_json) diff --git a/test/models/bot/alegre_test.rb b/test/models/bot/alegre_test.rb index bea721a37e..af6b0445d3 100644 --- a/test/models/bot/alegre_test.rb +++ b/test/models/bot/alegre_test.rb @@ -44,7 +44,7 @@ def teardown WebMock.stub_request(:post, 'http://alegre/text/langid/').to_return(body: 'bad JSON response') WebMock.stub_request(:post, 'http://alegre/text/langid/').to_return(body: 'bad JSON response') WebMock.stub_request(:post, 'http://alegre/text/similarity/').to_return(body: 'success') - WebMock.stub_request(:post, 'http://alegre/text/similarity/search/').to_return(body: 'success') + WebMock.stub_request(:post, 'http://alegre/similarity/sync/text').to_return(body: 'success') WebMock.disable_net_connect! allow: /#{CheckConfig.get('elasticsearch_host')}|#{CheckConfig.get('storage_endpoint')}/ Bot::Alegre.any_instance.stubs(:get_language).raises(RuntimeError) assert_nothing_raised do diff --git a/test/models/bot/smooch_6_test.rb b/test/models/bot/smooch_6_test.rb index 3586980cac..9afaa3d1d5 100644 --- a/test/models/bot/smooch_6_test.rb +++ b/test/models/bot/smooch_6_test.rb @@ -140,6 +140,7 @@ def send_message_outside_24_hours_window(template, pm = nil) test "should submit query without details on tipline bot v2" do WebMock.stub_request(:post, /\/text\/similarity\/search\//).to_return(body: {}.to_json) # For explainers WebMock.stub_request(:post, /\/similarity\/async\/text/).to_return(body: {}.to_json) # For explainers + WebMock.stub_request(:post, /\/similarity\/sync\/text/).to_return(body: {}.to_json) # For explainers claim = 'This is a test claim' send_message 'hello', '1', '1', random_string, random_string, claim, random_string, random_string, '1' assert_saved_query_type 'default_requests' @@ -209,6 +210,7 @@ def send_message_outside_24_hours_window(template, pm = nil) end test "should submit query with details on tipline bot v2" do + WebMock.stub_request(:post, /\/similarity\/sync\/text/).to_return(body: {}.to_json) # For explainers WebMock.stub_request(:post, /\/similarity\/async\/text/).to_return(body: {}.to_json) # For explainers WebMock.stub_request(:post, /\/text\/similarity\/search\//).to_return(body: {}.to_json) # For explainers claim = 'This is a test claim' diff --git a/test/models/explainer_test.rb b/test/models/explainer_test.rb index a87665421e..81b3c170f0 100644 --- a/test/models/explainer_test.rb +++ b/test/models/explainer_test.rb @@ -83,6 +83,7 @@ def setup end test "should create tag texts when setting tags" do + WebMock.stub_request(:post, /\/similarity\/async\/text/).to_return(body: {}.to_json) # For explainers Sidekiq::Testing.inline! do assert_difference 'TagText.count' do create_explainer tags: ['foo']