This repository was archived by the owner on Sep 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Implement job retrieval #2
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d921b77
Add VCR to development dependencies for mocking web requests.
lowjoel e902cbb
Implement the basic Programming Evaluation model.
lowjoel 7629981
Implement following redirects.
lowjoel ac1bbc9
Implement package retrieval.
lowjoel 6c3aa46
Extract the package logic into a separate class.
lowjoel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
lib/coursemology/evaluator/models/programming_evaluation.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class Coursemology::Evaluator::Models::ProgrammingEvaluation < Coursemology::Evaluator::Models::Base | ||
extend ActiveSupport::Autoload | ||
autoload :Package | ||
|
||
get :find, 'courses/assessment/programming_evaluations/:id' | ||
post :allocate, 'courses/assessment/programming_evaluations/allocate' | ||
|
||
# Obtains the package. | ||
# | ||
# @return [Coursemology::Evaluator::Models::ProgrammingEvaluation::Package] | ||
def package | ||
body = plain_request('courses/assessment/programming_evaluations/:id/package', id: id) | ||
Package.new(StringIO.new(body)) | ||
end | ||
|
||
private | ||
|
||
# Performs a plain request. | ||
# | ||
# @param [String] url The URL to request. | ||
# @param [Hash] params The parameter to be part of the request. | ||
# @return [String] The response body. | ||
def plain_request(url, params = {}) | ||
request = ActiveRestClient::Request.new({ url: url, method: :get, options: { plain: true } }, | ||
self.class) | ||
request.call(params) | ||
end | ||
end |
7 changes: 7 additions & 0 deletions
7
lib/coursemology/evaluator/models/programming_evaluation/package.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Coursemology::Evaluator::Models::ProgrammingEvaluation::Package | ||
# Constructs a new Package. | ||
# | ||
# @param [IO] io The IO object containing the package data. | ||
def initialize(io) | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
spec/coursemology/evaluator/models/programming_evaluation/package_spec.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe Coursemology::Evaluator::Models::ProgrammingEvaluation::Package do | ||
around(:each) do |example| | ||
File.open(Pathname.new(__dir__).join('../../../..', | ||
'fixtures/programming_question_template.zip')) do |file| | ||
define_singleton_method(:file) { file } | ||
example.call | ||
end | ||
end | ||
|
||
let(:package) { Coursemology::Evaluator::Models::ProgrammingEvaluation::Package.new(file) } | ||
describe '#initialize' do | ||
it 'accepts an IO object' do | ||
package | ||
end | ||
end | ||
end |
34 changes: 34 additions & 0 deletions
34
spec/coursemology/evaluator/models/programming_evaluation_spec.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe Coursemology::Evaluator::Models::ProgrammingEvaluation do | ||
describe '.allocate' do | ||
let(:evaluation) { Coursemology::Evaluator::Models::ProgrammingEvaluation.allocate.first } | ||
it 'obtains an unallocated evaluation' do | ||
VCR.use_cassette 'programming_evaluation/allocate' do | ||
expect(evaluation.id).not_to be_nil | ||
end | ||
end | ||
end | ||
|
||
describe '.find' do | ||
let(:find_id) { 2 } | ||
let(:evaluation) { Coursemology::Evaluator::Models::ProgrammingEvaluation.find(find_id) } | ||
|
||
it 'obtains the requested evaluation' do | ||
VCR.use_cassette 'programming_evaluation/find' do | ||
expect(evaluation.id).to eq(find_id) | ||
end | ||
end | ||
end | ||
|
||
describe '#package' do | ||
let(:evaluation) { Coursemology::Evaluator::Models::ProgrammingEvaluation.find(3) } | ||
|
||
it 'obtains the requested package' do | ||
VCR.use_cassette 'programming_evaluation/package' do | ||
expect(evaluation.package).to \ | ||
be_a(Coursemology::Evaluator::Models::ProgrammingEvaluation::Package) | ||
end | ||
end | ||
end | ||
end |
Binary file not shown.
58 changes: 58 additions & 0 deletions
58
spec/fixtures/vcr/cassettes/programming_evaluation/allocate.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
spec/fixtures/vcr/cassettes/programming_evaluation/find.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused method argument -
io
. If it's necessary, use_
or_io
as an argument name to indicate that it won't be used. You can also write asinitialize(*)
if you want the method to accept any arguments but don't care about them.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@allenwq I'll ignore this first, I want to implement the logic in a separate PR.