Migrated to proforma 0.6

Fixed all failing specs
This commit is contained in:
Karol
2021-05-24 14:58:36 +02:00
parent aabb6ca6bc
commit 8a7eae1a56
10 changed files with 39 additions and 29 deletions

View File

@ -24,7 +24,7 @@ gem 'net-http-persistent'
gem 'nokogiri'
gem 'pagedown-bootstrap-rails'
gem 'pg'
gem 'proforma', github: 'openHPI/proforma', tag: 'v0.5.1'
gem 'proforma', github: 'openHPI/proforma', tag: 'v0.6'
gem 'prometheus_exporter'
gem 'pry-byebug'
gem 'puma'

View File

@ -17,10 +17,10 @@ GIT
GIT
remote: https://github.com/openHPI/proforma.git
revision: dc68000325388e1d75f31be9e136a82edad8a56d
tag: v0.5.1
revision: 4b543be15c618ee3e5671fddb0e438be0278a249
tag: v0.6
specs:
proforma (0.5)
proforma (0.6)
activemodel (>= 5.2.3, < 6.2.0)
activesupport (>= 5.2.3, < 6.2.0)
nokogiri (>= 1.10.2, < 1.12.0)

View File

@ -63,13 +63,16 @@ module ProformaService
id: file.id,
title: file.name,
files: test_file(file),
meta_data: {
'feedback-message' => file.feedback_message,
}.compact
meta_data: test_meta_data(file)
)
end
end
def test_meta_data(file)
[{namespace: 'openHPI', key: 'entry-point', value: file.filepath},
{namespace: 'openHPI', key: 'feedback-message', value: file.feedback_message}]
end
def test_file(file)
[
task_file(file).tap do |t_file|

View File

@ -34,7 +34,7 @@ module ProformaService
@task.tests.map do |test_object|
task_files.delete(test_object.files.first.id).tap do |file|
file.weight = 1.0
file.feedback_message = test_object.meta_data['feedback-message']
file.feedback_message = test_object.meta_data.detect {|meta_data| meta_data[:namespace] == 'openHPI' && meta_data[:key] == 'feedback-message' }[:value]
end
end
end

View File

@ -9,7 +9,8 @@ module ProformaService
def execute
@task = ConvertExerciseToTask.call(exercise: @exercise)
exporter = Proforma::Exporter.new(@task)
namespaces = [{prefix: 'openHPI', uri: 'open.hpi.de'}]
exporter = Proforma::Exporter.new(task: @task, custom_namespaces: namespaces)
exporter.perform
end
end

View File

@ -10,8 +10,9 @@ module ProformaService
def execute
if single_task?
importer = Proforma::Importer.new(@zip)
@task = importer.perform
importer = Proforma::Importer.new(zip: @zip)
import_result = importer.perform
@task = import_result[:task]
exercise = base_exercise
exercise_files = exercise&.files&.to_a

View File

@ -161,7 +161,8 @@ RSpec.describe ProformaService::ConvertExerciseToTask do
id: test_file.id,
title: test_file.name,
files: have(1).item,
meta_data: {'feedback-message' => test_file.feedback_message}
meta_data: [{key: 'entry-point', namespace: 'openHPI', value: test_file.filepath},
{key: 'feedback-message', namespace: 'openHPI', value: 'feedback_message'}]
)
end

View File

@ -229,11 +229,11 @@ describe ProformaService::ConvertTaskToExercise do
internal_description: 'internal_description',
test_type: 'test_type',
files: test_files,
meta_data: {
'feedback-message' => 'feedback-message',
'testing-framework' => 'testing-framework',
'testing-framework-version' => 'testing-framework-version',
}
meta_data: [
{namespace: 'openHPI', key: 'feedback-message', value: 'feedback-message'},
{namespace: 'openHPI', key: 'testing-framework', value: 'testing-framework'},
{namespace: 'openHPI', key: 'testing-framework-version', value: 'testing-framework-version'},
]
)
end
@ -272,11 +272,11 @@ describe ProformaService::ConvertTaskToExercise do
let(:test2) do
Proforma::Test.new(
files: test_files2,
meta_data: {
'feedback-message' => 'feedback-message',
'testing-framework' => 'testing-framework',
'testing-framework-version' => 'testing-framework-version',
}
meta_data: [
{namespace: 'openHPI', key: 'feedback-message', value: 'feedback-message'},
{namespace: 'openHPI', key: 'testing-framework', value: 'testing-framework'},
{namespace: 'openHPI', key: 'testing-framework-version', value: 'testing-framework-version'},
]
)
end
let(:test_files2) { [test_file2] }
@ -352,11 +352,11 @@ describe ProformaService::ConvertTaskToExercise do
internal_description: 'regular_file',
test_type: 'test_type',
files: test_files,
meta_data: {
'feedback-message' => 'feedback-message',
'testing-framework' => 'testing-framework',
'testing-framework-version' => 'testing-framework-version',
}
meta_data: [
{namespace: 'openHPI', key: 'feedback-message', value: 'feedback-message'},
{namespace: 'openHPI', key: 'testing-framework', value: 'testing-framework'},
{namespace: 'openHPI', key: 'testing-framework-version', value: 'testing-framework-version'},
]
)
end
let(:test_files) { [test_file] }

View File

@ -30,7 +30,7 @@ describe ProformaService::ExportTask do
before do
allow(ProformaService::ConvertExerciseToTask).to receive(:call).with(exercise: exercise).and_return(task)
allow(Proforma::Exporter).to receive(:new).with(task).and_return(exporter)
allow(Proforma::Exporter).to receive(:new).with(task: task, custom_namespaces: [{prefix: 'openHPI', uri: 'open.hpi.de'}]).and_return(exporter)
end
it do

View File

@ -31,7 +31,11 @@ RSpec::Matchers.define :be_an_equal_exercise_as do |exercise|
return true if object == other # for []
return false if object.length != other.length
object.to_a.product(other.to_a).map {|k, v| equal?(k, v) }.any?
object.map do |element|
other.map {|other_element| equal?(element, other_element) }.any?
end.all? && other.map do |element|
object.map {|other_element| equal?(element, other_element) }.any?
end.all?
end
def attributes_and_associations(object)