Skip to content

Commit

Permalink
Merge pull request #21 from upmc-enterprises/HOPS-310-12-months-volum…
Browse files Browse the repository at this point in the history
…e-report-review

[HOPS-320]12 months volumes report.
  • Loading branch information
batessr authored Sep 4, 2020
2 parents 683cebc + de98b8f commit f319d44
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
neutrino_api_client (5.0.0dev0.02)
neutrino_api_client (5.1.0dev0.01)
activesupport (~> 6.0)
api-auth (= 2.3.1)
mime-types (= 3.2.2)
Expand Down
13 changes: 11 additions & 2 deletions lib/neutrino/gateway/data_quality_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,25 @@ module Gateway
class DataQualityReport < Neutrino::Gateway::Requestor
private_class_method :new
class << self

# Get the summary of data quality
# @param [Hash] options specify query values
# @return [Hash] NEUTRINO response
def summary(options = {})
path = "#{api}/reports/data-quality/summary"
request(path, options).
if_400_raise(Neutrino::Gateway::Exceptions::BadRequestError.new()).to_hash
if_400_raise(Neutrino::Gateway::Exceptions::BadRequestError.new).to_hash
end

# Update the twelve month volume report
# Create a new one if there is no existing report
# @param [Hash] options specify query values
# @return [Hash] NEUTRINO response
def twelve_month_volume(options = {})
path = "#{api}/reports/data-quality/twelve_month_volume"
request(path, options)
.if_400_raise(Neutrino::Gateway::Exceptions::BadRequestError.new).to_hash
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/neutrino/gateway/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Neutrino
module Gateway
VERSION = '5.0.0dev0.02'.freeze
VERSION = '5.1.0dev0.01'.freeze
end
end
32 changes: 29 additions & 3 deletions spec/neutrino/gateway/data_quality_report_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
require './lib/neutrino/gateway/exceptions'

describe Neutrino::Gateway::DataQualityReport do

before(:each) do
Neutrino::Api::Client.config = TestConfig.to_hash
end

describe 'self.summary' do

let(:path) { '/api/v1/reports/data-quality/summary' }
let(:response_message) { { 'content' => 'some data', 'message'=>'The system is updating the report' } }

Expand All @@ -27,7 +25,6 @@
end

context 'when the server returns a 400 error' do

before(:each) do
WebMock.stub_request(
:get,
Expand All @@ -39,8 +36,37 @@
it 'raises a bad request error' do
expect { described_class.summary(OPTIONS_WITH_REMOTE_IP) }.to raise_error(Neutrino::Gateway::Exceptions::BadRequestError)
end
end
end

describe 'self.twelve_month_volume' do
let(:path) { '/api/v1/reports/data-quality/twelve_month_volume' }
let(:response_message) { { 'content' => 'some data', 'message'=>'The system is updating the report' } }

before(:each) do
WebMock.stub_request(
:get,
'http://testhost:4242/api/v1/reports/data-quality/twelve_month_volume?user%5Bextension%5D=spameggs&user%5Broot%5D=foobar')
.with(headers: { 'X-Forwarded-For' => REMOTE_IP })
.to_return(body: response_message.to_json , status: ['200', 'OK'])
end

it 'returns the expected result' do
expect(described_class.twelve_month_volume(OPTIONS_WITH_REMOTE_IP)).to eq(response_message)
end

context 'when the server returns a 400 error' do
before(:each) do
WebMock.stub_request(
:get,
'http://testhost:4242/api/v1/reports/data-quality/twelve_month_volume?user%5Bextension%5D=spameggs&user%5Broot%5D=foobar')
.with(headers: { 'X-Forwarded-For' => REMOTE_IP })
.to_return(body: 'Bad Request', status: ['400', 'Bad Request'])
end

it 'raises a bad request error' do
expect { described_class.twelve_month_volume(OPTIONS_WITH_REMOTE_IP) }.to raise_error(Neutrino::Gateway::Exceptions::BadRequestError)
end
end
end
end

0 comments on commit f319d44

Please sign in to comment.