Skip to content

Commit

Permalink
WIP: #export
Browse files Browse the repository at this point in the history
  • Loading branch information
taitus committed Apr 11, 2024
1 parent c33a993 commit 47a71b5
Showing 1 changed file with 50 additions and 50 deletions.
100 changes: 50 additions & 50 deletions spec/models/machine_learning_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -327,56 +327,56 @@ def full_sanitizer(string)
end
end

# describe "#export_budget_investments_to_json" do
# it "creates a JSON file with all budget investments" do
# first_budget_investment = create(:budget_investment)
# last_budget_investment = create(:budget_investment)
#
# machine_learning = MachineLearning.new(job)
# machine_learning.send(:export_budget_investments_to_json)
#
# json_file = MachineLearning.data_folder.join("budget_investments.json")
# json = JSON.parse(File.read(json_file))
#
# expect(json).to be_an Array
# expect(json.size).to be 2
#
# expect(json.first["id"]).to eq first_budget_investment.id
# expect(json.first["title"]).to eq first_budget_investment.title
# expect(json.first["description"]).to eq full_sanitizer(first_budget_investment.description)
#
# expect(json.last["id"]).to eq last_budget_investment.id
# expect(json.last["title"]).to eq last_budget_investment.title
# expect(json.last["description"]).to eq full_sanitizer(last_budget_investment.description)
# end
# end
#
# describe "#export_comments_to_json" do
# it "creates a JSON file with all comments" do
# first_comment = create(:comment)
# last_comment = create(:comment)
#
# machine_learning = MachineLearning.new(job)
# machine_learning.send(:export_comments_to_json)
#
# json_file = MachineLearning.data_folder.join("comments.json")
# json = JSON.parse(File.read(json_file))
#
# expect(json).to be_an Array
# expect(json.size).to be 2
#
# expect(json.first["id"]).to eq first_comment.id
# expect(json.first["commentable_id"]).to eq first_comment.commentable_id
# expect(json.first["commentable_type"]).to eq first_comment.commentable_type
# expect(json.first["body"]).to eq full_sanitizer(first_comment.body)
#
# expect(json.last["id"]).to eq last_comment.id
# expect(json.last["commentable_id"]).to eq last_comment.commentable_id
# expect(json.last["commentable_type"]).to eq last_comment.commentable_type
# expect(json.last["body"]).to eq full_sanitizer(last_comment.body)
# end
# end
#
describe "#export_budget_investments_to_json" do
it "creates a JSON file with all budget investments" do
first_budget_investment = create(:budget_investment)
last_budget_investment = create(:budget_investment)

machine_learning = MachineLearning.new(job)
machine_learning.send(:export_budget_investments_to_json)

json_file = MachineLearning.data_folder.join("budget_investments.json")
json = JSON.parse(File.read(json_file))

expect(json).to be_an Array
expect(json.size).to be 2

expect(json.first["id"]).to eq first_budget_investment.id
expect(json.first["title"]).to eq first_budget_investment.title
expect(json.first["description"]).to eq full_sanitizer(first_budget_investment.description)

expect(json.last["id"]).to eq last_budget_investment.id
expect(json.last["title"]).to eq last_budget_investment.title
expect(json.last["description"]).to eq full_sanitizer(last_budget_investment.description)
end
end

describe "#export_comments_to_json" do
it "creates a JSON file with all comments" do
first_comment = create(:comment)
last_comment = create(:comment)

machine_learning = MachineLearning.new(job)
machine_learning.send(:export_comments_to_json)

json_file = MachineLearning.data_folder.join("comments.json")
json = JSON.parse(File.read(json_file))

expect(json).to be_an Array
expect(json.size).to be 2

expect(json.first["id"]).to eq first_comment.id
expect(json.first["commentable_id"]).to eq first_comment.commentable_id
expect(json.first["commentable_type"]).to eq first_comment.commentable_type
expect(json.first["body"]).to eq full_sanitizer(first_comment.body)

expect(json.last["id"]).to eq last_comment.id
expect(json.last["commentable_id"]).to eq last_comment.commentable_id
expect(json.last["commentable_type"]).to eq last_comment.commentable_type
expect(json.last["body"]).to eq full_sanitizer(last_comment.body)
end
end

# describe "#run_machine_learning_scripts" do
# it "returns true if python script executed correctly" do
# machine_learning = MachineLearning.new(job)
Expand Down

0 comments on commit 47a71b5

Please sign in to comment.