set proglang based on exenv

try to guess exenv based on proglang
This commit is contained in:
Karol
2022-09-24 15:24:12 +02:00
parent f5758ecb5e
commit 77999f75df
4 changed files with 42 additions and 10 deletions

View File

@ -19,22 +19,19 @@ RSpec.describe ProformaService::ConvertExerciseToTask do
let(:convert_to_task) { described_class.new(exercise: exercise) }
let(:exercise) do
create(:dummy,
execution_environment: execution_environment,
instructions: 'instruction',
uuid: SecureRandom.uuid,
files: files + tests)
end
let(:files) { [] }
let(:tests) { [] }
let(:execution_environment) { create(:java) }
it 'creates a task with all basic attributes' do
expect(task).to have_attributes(
title: exercise.title,
description: exercise.description,
# internal_description: exercise.instructions,
# proglang: {
# name: exercise.execution_environment.language,
# version: exercise.execution_environment.version
# },
uuid: exercise.uuid,
language: described_class::DEFAULT_LANGUAGE,
meta_data: {
@ -48,13 +45,18 @@ RSpec.describe ProformaService::ConvertExerciseToTask do
files: {},
},
},
# parent_uuid: exercise.clone_relations.first&.origin&.uuid,
files: [],
tests: [],
model_solutions: []
)
end
context 'when exercise has execution_environment with correct docker-image name' do
it 'creates a task with the correct proglang attribute' do
expect(task).to have_attributes(proglang: {name: 'java', version: '8'})
end
end
context 'when exercise has a mainfile' do
let(:files) { [file] }
let(:file) { build(:file) }

View File

@ -32,7 +32,7 @@ describe ProformaService::ConvertTaskToExercise do
Proforma::Task.new(
title: 'title',
description: 'description',
# proglang: {name: 'proglang-name', version: 'proglang-version'},
proglang: {name: 'python', version: '3.4'},
uuid: 'uuid',
parent_uuid: 'parent_uuid',
language: 'language',
@ -57,7 +57,7 @@ describe ProformaService::ConvertTaskToExercise do
allow_file_creation: allow_file_creation,
allow_auto_completion: allow_auto_completion,
expected_difficulty: expected_difficulty,
execution_environment_id: execution_environment.id,
execution_environment_id: execution_environment&.id,
files: files_meta_data,
},
}
@ -87,6 +87,16 @@ describe ProformaService::ConvertTaskToExercise do
)
end
context 'when execution environment is not set in meta_data' do
let(:execution_environment) { nil }
before { create(:python) }
it 'sets the execution_environment based on proglang name and value' do
expect(convert_to_exercise_service).to have_attributes(execution_environment: have_attributes(name: 'Python 3.4'))
end
end
context 'when task has a file' do
let(:files) { [file] }
let(:file) do