Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 5ac3f09

Browse files
committed
fix some tests
1 parent 0d65c3d commit 5ac3f09

File tree

6 files changed

+17
-6
lines changed

6 files changed

+17
-6
lines changed

spec/lib/modules/sentiment/entry_point_spec.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@
5353
end
5454

5555
describe "custom reports" do
56-
before { SiteSetting.ai_sentiment_inference_service_api_endpoint = "http://test.com" }
56+
before do
57+
SiteSetting.ai_sentiment_model_configs =
58+
"[{\"model_name\":\"SamLowe/roberta-base-go_emotions\",\"endpoint\":\"http://samlowe-emotion.com\",\"api_key\":\"123\"},{\"model_name\":\"j-hartmann/emotion-english-distilroberta-base\",\"endpoint\":\"http://jhartmann-emotion.com\",\"api_key\":\"123\"},{\"model_name\":\"cardiffnlp/twitter-roberta-base-sentiment-latest\",\"endpoint\":\"http://cardiffnlp-sentiment.com\",\"api_key\":\"123\"}]"
59+
end
5760

5861
fab!(:pm) { Fabricate(:private_message_post) }
5962

spec/lib/modules/sentiment/jobs/regular/post_sentiment_analysis_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
before do
1010
SiteSetting.ai_sentiment_enabled = true
11-
SiteSetting.ai_sentiment_inference_service_api_endpoint = "http://test.com"
11+
SiteSetting.ai_sentiment_model_configs =
12+
"[{\"model_name\":\"SamLowe/roberta-base-go_emotions\",\"endpoint\":\"http://samlowe-emotion.com\",\"api_key\":\"123\"},{\"model_name\":\"j-hartmann/emotion-english-distilroberta-base\",\"endpoint\":\"http://jhartmann-emotion.com\",\"api_key\":\"123\"},{\"model_name\":\"cardiffnlp/twitter-roberta-base-sentiment-latest\",\"endpoint\":\"http://cardiffnlp-sentiment.com\",\"api_key\":\"123\"}]"
1213
end
1314

1415
describe "scenarios where we return early without doing anything" do

spec/lib/modules/sentiment/sentiment_classification_spec.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
fab!(:target) { Fabricate(:post) }
77

88
describe "#request" do
9-
before { SiteSetting.ai_sentiment_inference_service_api_endpoint = "http://test.com" }
9+
before do
10+
SiteSetting.ai_sentiment_model_configs =
11+
"[{\"model_name\":\"SamLowe/roberta-base-go_emotions\",\"endpoint\":\"http://samlowe-emotion.com\",\"api_key\":\"123\"},{\"model_name\":\"j-hartmann/emotion-english-distilroberta-base\",\"endpoint\":\"http://jhartmann-emotion.com\",\"api_key\":\"123\"},{\"model_name\":\"cardiffnlp/twitter-roberta-base-sentiment-latest\",\"endpoint\":\"http://cardiffnlp-sentiment.com\",\"api_key\":\"123\"}]"
12+
end
1013

1114
it "returns the classification and the model used for it" do
1215
SentimentInferenceStubs.stub_classification(target)

spec/shared/classificator_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
fab!(:target) { Fabricate(:post) }
2121

2222
before do
23-
SiteSetting.ai_sentiment_inference_service_api_endpoint = "http://test.com"
23+
SiteSetting.ai_sentiment_model_configs =
24+
"[{\"model_name\":\"SamLowe/roberta-base-go_emotions\",\"endpoint\":\"http://samlowe-emotion.com\",\"api_key\":\"123\"},{\"model_name\":\"j-hartmann/emotion-english-distilroberta-base\",\"endpoint\":\"http://jhartmann-emotion.com\",\"api_key\":\"123\"},{\"model_name\":\"cardiffnlp/twitter-roberta-base-sentiment-latest\",\"endpoint\":\"http://cardiffnlp-sentiment.com\",\"api_key\":\"123\"}]"
2425
SentimentInferenceStubs.stub_classification(target)
2526
end
2627

spec/support/sentiment_inference_stubs.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class SentimentInferenceStubs
44
class << self
55
def endpoint
6-
"#{SiteSetting.ai_sentiment_inference_service_api_endpoint}/api/v1/classify"
6+
"http://test.com/api/v1/classify"
77
end
88

99
def model_response(model)

spec/tasks/backfill_spec.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
end
1010

1111
describe "ai:sentiment:backfill" do
12-
before { SiteSetting.ai_sentiment_inference_service_api_endpoint = "http://test.com" }
12+
before do
13+
SiteSetting.ai_sentiment_model_configs =
14+
"[{\"model_name\":\"SamLowe/roberta-base-go_emotions\",\"endpoint\":\"http://samlowe-emotion.com\",\"api_key\":\"123\"},{\"model_name\":\"j-hartmann/emotion-english-distilroberta-base\",\"endpoint\":\"http://jhartmann-emotion.com\",\"api_key\":\"123\"},{\"model_name\":\"cardiffnlp/twitter-roberta-base-sentiment-latest\",\"endpoint\":\"http://cardiffnlp-sentiment.com\",\"api_key\":\"123\"}]"
15+
end
1316

1417
it "does nothing if the topic is soft-deleted" do
1518
target = Fabricate(:post)

0 commit comments

Comments
 (0)