Sha256: 404ca349b12031e0ab11a38462cfdb2cff0dda90f3959fdaeb36adda93001e1a

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

require 'test_helper'

# test the XML mapping objects
# and see that they parse OK
# against the captured samples
class TestParse < Test::Unit::TestCase
  def open_sample(file)
    File.open(File.join(File.dirname(__FILE__), file)) do |f|
      return REXML::Document.new f
    end
  end
  def test_request_url
    api = OpenAustralia::Api.new 'ASDF'

    url = api.send(:request_url, 'getDivisions', { :postcode => '2032'})
    assert_equal('http://www.openaustralia.org/api/getDivisions?key=ASDF&output=xml&postcode=2032', url)
  end

  def test_parse_debate_search_reps
    doc = open_sample('debate_search_reps.xml')
    srch = OpenAustralia::DebateSearch.load_from_xml doc.root

    assert(srch != nil, 'should have parsed the search results object')
    assert(srch.search_description != nil, "search description didn't parse")
    assert(srch.results.count > 0, 'should have multiple results')
  end

  def test_parse_debate_search_senate
    doc = open_sample('debate_search_senate.xml')
    srch = OpenAustralia::DebateSearch.load_from_xml doc.root

    assert(srch != nil, 'should have parsed the search results object')
    assert(srch.search_description != nil, "search description didn't parse")
    assert(srch.results.count > 0, 'should have multiple results')
  end

  def test_hansard_utegate_search
    doc = open_sample('hansard_utegate_search.xml')
    srch = OpenAustralia::HansardSearch.load_from_xml doc.root

    assert(srch != nil, 'should have parsed the search results object')
    assert(srch.search_description != nil, "search description didn't parse")
    assert(srch.results.count > 0, 'should have multiple results')
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
openaustralia-1.0.2 test/test_parse.rb
openaustralia-1.0.1 test/test_parse.rb
openaustralia-1.0.0 test/test_parse.rb