Skip to content

Commit

Permalink
add tests for explicitly disabling similarity
Browse files Browse the repository at this point in the history
  • Loading branch information
DGaffney committed Jan 24, 2024
1 parent 7c517be commit fdbe6f9
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/models/bot/alegre_v2_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -650,4 +650,38 @@ def teardown
assert_equal relationship.relationship_type, Relationship.suggested_type
Bot::Alegre.unstub(:get_similar_items_v2)
end

test "should not relate project media for audio if disabled on workspace" do
tbi = @team.team_bot_installations.select{|x| x.user_id == @bot.id}
tbi.set_audio_similarity_enabled = false
tb.save!
pm1 = create_project_media team: @team, media: create_uploaded_audio
pm2 = create_project_media team: @team, media: create_uploaded_audio
Bot::Alegre.stubs(:get_similar_items_v2).returns({pm2.id=>{:score=>0.91, :context=>{"team_id"=>pm2.team_id, "has_custom_id"=>true, "project_media_id"=>pm2.id}, :model=>"audio", :source_field=>"audio", :target_field=>"audio", :relationship_type=>Relationship.suggested_type}})
relationship = nil
assert_no_difference 'Relationship.count' do
relationship = Bot::Alegre.relate_project_media(pm1)
end
assert_equal relationship, nil
Bot::Alegre.unstub(:get_similar_items_v2)
tbi.set_audio_similarity_enabled = true
tb.save!
end

test "should not relate project media for image if disabled on workspace" do
tbi = @team.team_bot_installations.select{|x| x.user_id == @bot.id}
tbi.set_image_similarity_enabled = false
tb.save!
pm1 = create_project_media team: @team, media: create_uploaded_image
pm2 = create_project_media team: @team, media: create_uploaded_image
Bot::Alegre.stubs(:get_similar_items_v2).returns({pm2.id=>{:score=>0.91, :context=>{"team_id"=>pm2.team_id, "has_custom_id"=>true, "project_media_id"=>pm2.id}, :model=>"audio", :source_field=>"audio", :target_field=>"audio", :relationship_type=>Relationship.suggested_type}})
relationship = nil
assert_no_difference 'Relationship.count' do
relationship = Bot::Alegre.relate_project_media(pm1)
end
assert_equal relationship, nil
Bot::Alegre.unstub(:get_similar_items_v2)
tbi.set_image_similarity_enabled = true
tb.save!
end
end

0 comments on commit fdbe6f9

Please sign in to comment.