Project

General

Profile

1 3132 perry
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
2
require 'test/unit'
3
require 'eml.rb'
4
require 'metacat.rb'
5
6
class EmlTest < Test::Unit::TestCase
7
8
  def setup
9
    @metacat = Metacat.new('http://data.piscoweb.org/catalog/metacat')
10
    @eml = @metacat.find(:docid => 'HMS001_020ADCP019R00_20060612.50.1')
11
  end
12
13
  def teardown
14
  end
15
16
  def test_temporal_coverage
17
    assert_equal [Date.strptime('2006-06-12'), Date.strptime('2006-08-30')] ,
18
                  @eml.temporal_coverage
19
  end
20
21
  def test_has_data_tables
22
    assert_kind_of  Array, @eml.data_tables
23
    assert_kind_of  DataTable, @eml.data_tables[0]
24
  end
25
26
  def test_largest_of_one_data_table
27
    assert_kind_of  DataTable, @eml.largest_data_table
28
  end
29
30
  def test_largest_of_many_data_table
31
    eml = @metacat.find(:docid => 'pisco_subtidal.12.3')
32
    assert_kind_of  DataTable, eml.largest_data_table
33
    assert_equal    'pisco_subtidal.14.1', eml.largest_data_table.docid
34
  end
35
36
  def test_to_s
37
    assert_kind_of  String, @eml.to_s
38
  end
39
40
  def test_has_xml_doc
41
    assert_kind_of  REXML::Document, @eml.doc
42
  end
43
44
  def test_correct_docid
45
    assert_equal  'HMS001_020ADCP019R00_20060612.50.1', @eml.docid
46
  end
47
48
  def text_to_xml
49
    # While the method is to_xml, this method outputs the xml as a string,
50
    # not a REXML DOM object
51
    assert_kind_of  String, @eml.to_xml
52
  end
53
54
end