Migrated to proforma 0.6
Fixed all failing specs
This commit is contained in:
2
Gemfile
2
Gemfile
@ -24,7 +24,7 @@ gem 'net-http-persistent'
|
|||||||
gem 'nokogiri'
|
gem 'nokogiri'
|
||||||
gem 'pagedown-bootstrap-rails'
|
gem 'pagedown-bootstrap-rails'
|
||||||
gem 'pg'
|
gem 'pg'
|
||||||
gem 'proforma', github: 'openHPI/proforma', tag: 'v0.5.1'
|
gem 'proforma', github: 'openHPI/proforma', tag: 'v0.6'
|
||||||
gem 'prometheus_exporter'
|
gem 'prometheus_exporter'
|
||||||
gem 'pry-byebug'
|
gem 'pry-byebug'
|
||||||
gem 'puma'
|
gem 'puma'
|
||||||
|
@ -17,10 +17,10 @@ GIT
|
|||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: https://github.com/openHPI/proforma.git
|
remote: https://github.com/openHPI/proforma.git
|
||||||
revision: dc68000325388e1d75f31be9e136a82edad8a56d
|
revision: 4b543be15c618ee3e5671fddb0e438be0278a249
|
||||||
tag: v0.5.1
|
tag: v0.6
|
||||||
specs:
|
specs:
|
||||||
proforma (0.5)
|
proforma (0.6)
|
||||||
activemodel (>= 5.2.3, < 6.2.0)
|
activemodel (>= 5.2.3, < 6.2.0)
|
||||||
activesupport (>= 5.2.3, < 6.2.0)
|
activesupport (>= 5.2.3, < 6.2.0)
|
||||||
nokogiri (>= 1.10.2, < 1.12.0)
|
nokogiri (>= 1.10.2, < 1.12.0)
|
||||||
|
@ -63,13 +63,16 @@ module ProformaService
|
|||||||
id: file.id,
|
id: file.id,
|
||||||
title: file.name,
|
title: file.name,
|
||||||
files: test_file(file),
|
files: test_file(file),
|
||||||
meta_data: {
|
meta_data: test_meta_data(file)
|
||||||
'feedback-message' => file.feedback_message,
|
|
||||||
}.compact
|
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
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)
|
def test_file(file)
|
||||||
[
|
[
|
||||||
task_file(file).tap do |t_file|
|
task_file(file).tap do |t_file|
|
||||||
|
@ -34,7 +34,7 @@ module ProformaService
|
|||||||
@task.tests.map do |test_object|
|
@task.tests.map do |test_object|
|
||||||
task_files.delete(test_object.files.first.id).tap do |file|
|
task_files.delete(test_object.files.first.id).tap do |file|
|
||||||
file.weight = 1.0
|
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
|
end
|
||||||
end
|
end
|
||||||
|
@ -9,7 +9,8 @@ module ProformaService
|
|||||||
|
|
||||||
def execute
|
def execute
|
||||||
@task = ConvertExerciseToTask.call(exercise: @exercise)
|
@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
|
exporter.perform
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -10,8 +10,9 @@ module ProformaService
|
|||||||
|
|
||||||
def execute
|
def execute
|
||||||
if single_task?
|
if single_task?
|
||||||
importer = Proforma::Importer.new(@zip)
|
importer = Proforma::Importer.new(zip: @zip)
|
||||||
@task = importer.perform
|
import_result = importer.perform
|
||||||
|
@task = import_result[:task]
|
||||||
|
|
||||||
exercise = base_exercise
|
exercise = base_exercise
|
||||||
exercise_files = exercise&.files&.to_a
|
exercise_files = exercise&.files&.to_a
|
||||||
|
@ -161,7 +161,8 @@ RSpec.describe ProformaService::ConvertExerciseToTask do
|
|||||||
id: test_file.id,
|
id: test_file.id,
|
||||||
title: test_file.name,
|
title: test_file.name,
|
||||||
files: have(1).item,
|
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
|
end
|
||||||
|
|
||||||
|
@ -229,11 +229,11 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
internal_description: 'internal_description',
|
internal_description: 'internal_description',
|
||||||
test_type: 'test_type',
|
test_type: 'test_type',
|
||||||
files: test_files,
|
files: test_files,
|
||||||
meta_data: {
|
meta_data: [
|
||||||
'feedback-message' => 'feedback-message',
|
{namespace: 'openHPI', key: 'feedback-message', value: 'feedback-message'},
|
||||||
'testing-framework' => 'testing-framework',
|
{namespace: 'openHPI', key: 'testing-framework', value: 'testing-framework'},
|
||||||
'testing-framework-version' => 'testing-framework-version',
|
{namespace: 'openHPI', key: 'testing-framework-version', value: 'testing-framework-version'},
|
||||||
}
|
]
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -272,11 +272,11 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
let(:test2) do
|
let(:test2) do
|
||||||
Proforma::Test.new(
|
Proforma::Test.new(
|
||||||
files: test_files2,
|
files: test_files2,
|
||||||
meta_data: {
|
meta_data: [
|
||||||
'feedback-message' => 'feedback-message',
|
{namespace: 'openHPI', key: 'feedback-message', value: 'feedback-message'},
|
||||||
'testing-framework' => 'testing-framework',
|
{namespace: 'openHPI', key: 'testing-framework', value: 'testing-framework'},
|
||||||
'testing-framework-version' => 'testing-framework-version',
|
{namespace: 'openHPI', key: 'testing-framework-version', value: 'testing-framework-version'},
|
||||||
}
|
]
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
let(:test_files2) { [test_file2] }
|
let(:test_files2) { [test_file2] }
|
||||||
@ -352,11 +352,11 @@ describe ProformaService::ConvertTaskToExercise do
|
|||||||
internal_description: 'regular_file',
|
internal_description: 'regular_file',
|
||||||
test_type: 'test_type',
|
test_type: 'test_type',
|
||||||
files: test_files,
|
files: test_files,
|
||||||
meta_data: {
|
meta_data: [
|
||||||
'feedback-message' => 'feedback-message',
|
{namespace: 'openHPI', key: 'feedback-message', value: 'feedback-message'},
|
||||||
'testing-framework' => 'testing-framework',
|
{namespace: 'openHPI', key: 'testing-framework', value: 'testing-framework'},
|
||||||
'testing-framework-version' => 'testing-framework-version',
|
{namespace: 'openHPI', key: 'testing-framework-version', value: 'testing-framework-version'},
|
||||||
}
|
]
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
let(:test_files) { [test_file] }
|
let(:test_files) { [test_file] }
|
||||||
|
@ -30,7 +30,7 @@ describe ProformaService::ExportTask do
|
|||||||
|
|
||||||
before do
|
before do
|
||||||
allow(ProformaService::ConvertExerciseToTask).to receive(:call).with(exercise: exercise).and_return(task)
|
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
|
end
|
||||||
|
|
||||||
it do
|
it do
|
||||||
|
@ -31,7 +31,11 @@ RSpec::Matchers.define :be_an_equal_exercise_as do |exercise|
|
|||||||
return true if object == other # for []
|
return true if object == other # for []
|
||||||
return false if object.length != other.length
|
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
|
end
|
||||||
|
|
||||||
def attributes_and_associations(object)
|
def attributes_and_associations(object)
|
||||||
|
Reference in New Issue
Block a user