Skip to content

Commit

Permalink
Merge #17
Browse files Browse the repository at this point in the history
17: transactor/status_test: Add application/user_id existence testing r=unleashed,davidor,eguzki a=miguelsorianod

Add unit tests that cover application_id and user_id existence in responses

Co-authored-by: Miguel Soriano <[email protected]>
  • Loading branch information
bors[bot] and miguelsorianod committed Apr 16, 2018
2 parents 81af74e + 32efd61 commit 18edf5c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/unit/transactor/status_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,5 +237,33 @@ def setup
assert_nil month['exceeded']
assert_equal 'true', day['exceeded']
end

test '#to_xml shows the application id when OAuth is used' do
usage = {:month => {@metric_id.to_s => 429}}
status = Transactor::Status.new(service_id: @service_id,
application: @application,
values: usage,
oauth: true)

doc = Nokogiri::XML(status.to_xml)

assert_equal @application.id, doc.at('status application id').content
end

test '#to_xml shows the username along with the application when OAuth and a User are used' do
usage = {:month => {@metric_id.to_s => 429}}
user = User.new(service_id: @service_id,
username: "testusername")
status = Transactor::Status.new(service_id: @service_id,
application: @application,
values: usage,
oauth: true,
user: user
)
doc = Nokogiri::XML(status.to_xml)

assert_equal "testusername", doc.at('status user id').content
assert_equal @application.id, doc.at('status application id').content
end
end
end

0 comments on commit 18edf5c

Please sign in to comment.