Project

General

Profile

metacat / src / ruby / test / data_table_test.rb @ 8561

1
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
2

    
3
require 'test/unit'
4
require 'eml.rb'
5
require 'metacat.rb'
6
require 'data_table.rb'
7

    
8
class DataTableTest < Test::Unit::TestCase
9

    
10
  def setup
11
    @eml = Metacat.find(:docid => 'HMS001_020ADCP019R00_20060612.50.1')
12
    @data_table = @eml.largest_data_table
13
  end
14
  
15
  def teardown
16
  end
17

    
18
  # Replace this with your real tests.
19
  def test_id
20
    assert_equal  @data_table.docid, @data_table.id
21
  end
22
  
23
  def test_docid
24
    assert_equal  'HMS001_020ADCP019R00_20060612.40.1', @data_table.docid
25
  end
26
  
27
  def test_location
28
    assert_equal  'ecogrid://knb/HMS001_020ADCP019R00_20060612.40.1', 
29
                    @data_table.location
30
  end
31
  
32
  def test_size
33
    assert_equal @data_table.size, 158041130
34
  end
35
  
36
  def test_physical
37
    assert_kind_of  REXML::Element, @data_table.physical
38
  end
39
  
40
  def test_data_format
41
    assert_equal 'textFormat', @data_table.data_format
42
  end
43
  
44
  def test_text_format
45
    assert_kind_of REXML::Element, @data_table.text_format
46
  end
47
  
48
  def test_simple_delimited
49
    assert_kind_of REXML::Element, @data_table.simple_delimited
50
  end
51
  
52
  def test_field_delimiter
53
    assert_kind_of  String, @data_table.field_delimiter
54
  end
55
  
56
  def test_num_headers
57
    assert_equal 1, @data_table.num_headers
58
  end
59
  
60
  def test_record_delimiter
61
    assert_equal '#x0A', @data_table.record_delimiter
62
  end
63
    
64
  def test_metadata_attr_reader
65
    assert_kind_of  REXML::Element, @data_table.metadata
66
  end
67
  
68
  def test_read
69
    f1 = File.new("tmp/#{@data_table.docid}", "w+")
70
    @data_table.read do |buffer|
71
      f1.write buffer
72
    end
73
    f1.close
74
    assert_equal  File.size("test/fixtures/#{@data_table.id}"),
75
                    File.size("tmp/#{@data_table.id}")
76
  end
77

    
78
end