Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
DGaffney committed Aug 28, 2024
1 parent c4aeee5 commit a1ad41e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/models/bot/smooch_6_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -877,9 +877,9 @@ def send_message_outside_24_hours_window(template, pm = nil)
Sidekiq::Testing.fake! do
WebMock.disable_net_connect! allow: /#{CheckConfig.get('elasticsearch_host')}|#{CheckConfig.get('storage_endpoint')}/
# Mock any call to Alegre like `POST /text/similarity/` with a "text" parameter that contains "who are you"
Bot::Alegre.stubs(:request).with{ |x, y, z| x == 'post' && y == '/text/similarity/' && z[:text] =~ /who are you/ }.returns(true)
Bot::Alegre.stubs(:request).with{ |x, y, z| x == 'post' && y == '/similarity/sync/text' && z[:text] =~ /who are you/ }.returns(true)
# Mock any call to Alegre like `GET /text/similarity/` with a "text" parameter that does not contain "who are you"
Bot::Alegre.stubs(:request).with{ |x, y, z| x == 'post' && y == '/text/similarity/search/' && (z[:text] =~ /who are you/).nil? }.returns({ 'result' => [] })
Bot::Alegre.stubs(:request).with{ |x, y, z| x == 'post' && y == '/similarity/sync/text' && (z[:text] =~ /who are you/).nil? }.returns({ 'result' => [] })

# Enable NLU and add a couple of keywords to a new "About Us" resource
nlu = SmoochNlu.new(@team.slug)
Expand All @@ -889,7 +889,7 @@ def send_message_outside_24_hours_window(template, pm = nil)
r.add_keyword('who are you')

# Mock a call to Alegre like `GET /text/similarity/` with a "text" parameter that contains "who are you"
Bot::Alegre.stubs(:request).with{ |x, y, z| x == 'post' && y == '/text/similarity/search/' && z[:text] =~ /who are you/ }.returns({ 'result' => [
Bot::Alegre.stubs(:request).with{ |x, y, z| x == 'post' && y == '/similarity/sync/text' && z[:text] =~ /who are you/ }.returns({ 'result' => [
{ '_score' => 0.9, '_source' => { 'context' => { 'resource_id' => 0 } } },
{ '_score' => 0.8, '_source' => { 'context' => { 'resource_id' => r.id } } }
]})
Expand All @@ -907,7 +907,7 @@ def send_message_outside_24_hours_window(template, pm = nil)
assert_no_saved_query

# Delete one keyword, so expect one call to Alegre
Bot::Alegre.expects(:request).with{ |x, y, _z| x == 'delete' && y == '/text/similarity/' }.once
Bot::Alegre.expects(:request).with{ |x, y, _z| x == 'delete' && y == '/similarity/sync/text' }.once
r.remove_keyword('who are you')
Bot::Alegre.unstub(:request)
end
Expand Down

0 comments on commit a1ad41e

Please sign in to comment.