voruby 1.1.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile.rb +107 -224
- data/lib/misc.rb +1 -0
- data/lib/misc/misc.rb +60 -0
- data/lib/misc/propertyfile.rb +31 -0
- data/lib/symphony.rb +1 -0
- data/lib/symphony/symphony.rb +247 -0
- data/lib/voruby.rb +186 -0
- data/lib/voruby/active_votable/active_votable.rb +468 -347
- data/lib/voruby/adql/1.0/adql.rb +2418 -0
- data/lib/voruby/adql/support.rb +2 -0
- data/lib/voruby/misc.rb +351 -0
- data/lib/voruby/misc/connection_monitor.rb +97 -0
- data/lib/voruby/misc/libxml_ext.rb +121 -0
- data/lib/voruby/misc/rexml_ext.rb +223 -0
- data/lib/voruby/resolver/resolver.rb +12 -0
- data/lib/voruby/resolver/sesame.rb +299 -0
- data/lib/voruby/sky_query/sky_query.rb +192 -0
- data/lib/voruby/stc/1.10/coords.rb +2272 -0
- data/lib/voruby/stc/1.10/region.rb +892 -0
- data/lib/voruby/stc/1.10/stc.rb +3271 -0
- data/lib/voruby/stc/1.30/stc.rb +8666 -0
- data/lib/voruby/stc/support.rb +2 -0
- data/lib/voruby/ucd/ucd.rb +173 -0
- data/lib/voruby/voevent/1.1/voevent.rb +1124 -0
- data/lib/voruby/voevent/support.rb +5 -0
- data/lib/voruby/votable/1.0/votable.rb +1807 -0
- data/lib/voruby/votable/1.1/votable.rb +2100 -0
- data/lib/voruby/votable/votable.rb +305 -0
- data/lib/voruby/wesix/wesix.rb +491 -0
- data/lib/voruby/xlink/1.2/xlink.rb +21 -0
- data/test/voruby/active_votable/complex.vot +60 -0
- data/test/voruby/active_votable/error.vot +6 -0
- data/test/voruby/active_votable/large.vot +130040 -0
- data/test/voruby/active_votable/simple1.vot +38 -0
- data/test/voruby/active_votable/simple2.vot +38 -0
- data/test/voruby/active_votable/test.rb +193 -0
- data/test/voruby/adql/1.0/adql-alias.sql +1 -0
- data/test/voruby/adql/1.0/adql-alias.xml +26 -0
- data/test/voruby/adql/1.0/adql-avg.sql +1 -0
- data/test/voruby/adql/1.0/adql-avg.xml +31 -0
- data/test/voruby/adql/1.0/adql-circle.sql +1 -0
- data/test/voruby/adql/1.0/adql-circle.xml +46 -0
- data/test/voruby/adql/1.0/adql-expr.sql +1 -0
- data/test/voruby/adql/1.0/adql-expr.xml +34 -0
- data/test/voruby/adql/1.0/adql-function.sql +1 -0
- data/test/voruby/adql/1.0/adql-function.xml +41 -0
- data/test/voruby/adql/1.0/adql-group.sql +1 -0
- data/test/voruby/adql/1.0/adql-group.xml +51 -0
- data/test/voruby/adql/1.0/adql-having.sql +1 -0
- data/test/voruby/adql/1.0/adql-having.xml +25 -0
- data/test/voruby/adql/1.0/adql-like.sql +1 -0
- data/test/voruby/adql/1.0/adql-like.xml +17 -0
- data/test/voruby/adql/1.0/adql-order.sql +1 -0
- data/test/voruby/adql/1.0/adql-order.xml +37 -0
- data/test/voruby/adql/1.0/adql-simple.sql +1 -0
- data/test/voruby/adql/1.0/adql-simple.xml +12 -0
- data/test/voruby/adql/1.0/adql-top.sql +1 -0
- data/test/voruby/adql/1.0/adql-top.xml +33 -0
- data/test/voruby/adql/1.0/test.rb +2220 -0
- data/test/voruby/misc/test.rb +32 -0
- data/test/voruby/resolver/sesame/test.rb +56 -0
- data/test/voruby/sky_query/test.rb +107 -0
- data/test/voruby/stc/1.10/coords_test.rb +3704 -0
- data/test/voruby/stc/1.10/region_test.rb +993 -0
- data/test/voruby/stc/1.10/stc-catalog-entry-location.xml +112 -0
- data/test/voruby/stc/1.10/stc-obs-data-location.xml +126 -0
- data/test/voruby/stc/1.10/stc-region-circle.xml +5 -0
- data/test/voruby/stc/1.10/stc-region-convex.xml +11 -0
- data/test/voruby/stc/1.10/stc-region-convexhull.xml +5 -0
- data/test/voruby/stc/1.10/stc-region-ellipse.xml +7 -0
- data/test/voruby/stc/1.10/stc-region-intersection.xml +25 -0
- data/test/voruby/stc/1.10/stc-region-negation.xml +7 -0
- data/test/voruby/stc/1.10/stc-region-polygon.xml +13 -0
- data/test/voruby/stc/1.10/stc-region-sector.xml +6 -0
- data/test/voruby/stc/1.10/stc-region-union.xml +25 -0
- data/test/voruby/stc/1.10/stc-resource-profile.xml +60 -0
- data/test/voruby/stc/1.10/stc-search-location.xml +54 -0
- data/test/voruby/stc/1.10/stc_test.rb +4626 -0
- data/test/voruby/stc/1.30/stc-catalog-entry-location.xml +210 -0
- data/test/voruby/stc/1.30/stc-obs-data-location-arecibo.xml +353 -0
- data/test/voruby/stc/1.30/stc-obs-data-location-fits.xml +250 -0
- data/test/voruby/stc/1.30/stc-obs-data-location-xlink.xml +63 -0
- data/test/voruby/stc/1.30/stc-obs-data-location.xml +216 -0
- data/test/voruby/stc/1.30/stc-resource-profile-unusual-ref-pos.xml +39 -0
- data/test/voruby/stc/1.30/stc-resource-profile.xml +129 -0
- data/test/voruby/stc/1.30/stc-search-location-arecibo.xml +86 -0
- data/test/voruby/stc/1.30/stc-search-location.xml +101 -0
- data/test/voruby/stc/1.30/test.rb +6274 -0
- data/test/voruby/ucd/test.rb +48 -0
- data/test/voruby/voevent/1.1/test.rb +812 -0
- data/test/{voevent/voevent_v1_1.xml → voruby/voevent/1.1/voevent.xml} +2 -2
- data/test/voruby/voregistry/0.3/test.rb +137 -0
- data/test/voruby/votable/1.0/test.rb +714 -0
- data/test/voruby/votable/1.0/votable.basic.xml +660 -0
- data/test/voruby/votable/1.0/votable.html +86 -0
- data/test/voruby/votable/1.0/votable.ns.xml +56 -0
- data/test/voruby/votable/1.1/test.rb +785 -0
- data/test/voruby/votable/1.1/votable.basic.xml +38 -0
- data/test/voruby/votable/1.1/votable.html +86 -0
- data/test/voruby/votable/1.1/votable.ns.xml +56 -0
- data/test/voruby/votable/test.rb +15 -0
- data/test/voruby/wesix/test.rb +268 -0
- data/test/voruby/wesix/testr.fits +28 -0
- metadata +234 -247
- data/REQUIREMENTS +0 -6
- data/lib/voruby/active_votable/loader.rb +0 -5
- data/lib/voruby/adql/adql.rb +0 -2787
- data/lib/voruby/adql/ext.rb +0 -14
- data/lib/voruby/adql/loader.rb +0 -6
- data/lib/voruby/adql/operations.rb +0 -54
- data/lib/voruby/adql/parser.rb +0 -160
- data/lib/voruby/adql/transforms.rb +0 -573
- data/lib/voruby/ext.rb +0 -17
- data/lib/voruby/loader.rb +0 -4
- data/lib/voruby/misc/propertyfile.rb +0 -36
- data/lib/voruby/plastic/applications.rb +0 -174
- data/lib/voruby/plastic/constants.rb +0 -30
- data/lib/voruby/plastic/loader.rb +0 -10
- data/lib/voruby/plastic/plastic.rb +0 -1
- data/lib/voruby/resources/conesearch/conesearch.rb +0 -9
- data/lib/voruby/resources/conesearch/conesearch_v0_2.rb +0 -55
- data/lib/voruby/resources/conesearch/conesearch_v0_3.rb +0 -50
- data/lib/voruby/resources/conesearch/conesearch_v1_0.rb +0 -72
- data/lib/voruby/resources/conesearch/loader.rb +0 -4
- data/lib/voruby/resources/loader.rb +0 -50
- data/lib/voruby/resources/nodes.rb +0 -190
- data/lib/voruby/resources/openskynode/loader.rb +0 -4
- data/lib/voruby/resources/openskynode/openskynode.rb +0 -9
- data/lib/voruby/resources/openskynode/openskynode_v0_1.rb +0 -54
- data/lib/voruby/resources/sia/loader.rb +0 -5
- data/lib/voruby/resources/sia/sia.rb +0 -9
- data/lib/voruby/resources/sia/sia_v0_6.rb +0 -90
- data/lib/voruby/resources/sia/sia_v0_7.rb +0 -89
- data/lib/voruby/resources/sia/sia_v1_0.rb +0 -122
- data/lib/voruby/resources/stsci.rb +0 -59
- data/lib/voruby/resources/vodataservice/coverage_v0_2.rb +0 -195
- data/lib/voruby/resources/vodataservice/coverage_v0_3.rb +0 -158
- data/lib/voruby/resources/vodataservice/loader.rb +0 -5
- data/lib/voruby/resources/vodataservice/vodataservice.rb +0 -9
- data/lib/voruby/resources/vodataservice/vodataservice_v0_4.rb +0 -189
- data/lib/voruby/resources/vodataservice/vodataservice_v0_5.rb +0 -163
- data/lib/voruby/resources/vodataservice/vodataservice_v1_0.rb +0 -221
- data/lib/voruby/resources/voregistry/loader.rb +0 -4
- data/lib/voruby/resources/voregistry/voregistry.rb +0 -9
- data/lib/voruby/resources/voregistry/voregistry_v0_2.rb +0 -40
- data/lib/voruby/resources/voregistry/voregistry_v0_3.rb +0 -30
- data/lib/voruby/resources/voregistry/voregistry_v1_0.rb +0 -86
- data/lib/voruby/resources/voresource/loader.rb +0 -17
- data/lib/voruby/resources/voresource/voresource.rb +0 -9
- data/lib/voruby/resources/voresource/voresource_v0_10.rb +0 -327
- data/lib/voruby/resources/voresource/voresource_v0_9.rb +0 -405
- data/lib/voruby/resources/voresource/voresource_v1_0.rb +0 -230
- data/lib/voruby/services/ext.rb +0 -11
- data/lib/voruby/services/gestalt/footprint.rb +0 -95
- data/lib/voruby/services/gestalt/wcs_fixer.rb +0 -105
- data/lib/voruby/services/gestalt/wesix.rb +0 -155
- data/lib/voruby/services/loader.rb +0 -7
- data/lib/voruby/services/registry/registry.rb +0 -53
- data/lib/voruby/services/resolver/resolver.rb +0 -35
- data/lib/voruby/services/schema/schema.rb +0 -644
- data/lib/voruby/sesame/loader.rb +0 -6
- data/lib/voruby/sesame/sesame_v1_0.rb +0 -64
- data/lib/voruby/simple/loader.rb +0 -6
- data/lib/voruby/simple/parameters.rb +0 -196
- data/lib/voruby/simple/sap.rb +0 -446
- data/lib/voruby/spacetime/loader.rb +0 -3
- data/lib/voruby/spacetime/spacetime.rb +0 -607
- data/lib/voruby/stc/coords_v1_20.rb +0 -900
- data/lib/voruby/stc/loader.rb +0 -55
- data/lib/voruby/stc/region_v1_20.rb +0 -274
- data/lib/voruby/stc/stc_v1_20.rb +0 -1196
- data/lib/voruby/util.rb +0 -27
- data/lib/voruby/voevent/loader.rb +0 -7
- data/lib/voruby/voevent/voevent_v1_0.rb +0 -213
- data/lib/voruby/voevent/voevent_v1_1.rb +0 -196
- data/lib/voruby/votables/chandra.rb +0 -373
- data/lib/voruby/votables/data.rb +0 -179
- data/lib/voruby/votables/galex.rb +0 -377
- data/lib/voruby/votables/int.rb +0 -354
- data/lib/voruby/votables/libxml_parser.rb +0 -411
- data/lib/voruby/votables/libxml_votable.rb +0 -67
- data/lib/voruby/votables/loader.rb +0 -10
- data/lib/voruby/votables/meta.rb +0 -763
- data/lib/voruby/votables/misc.rb +0 -51
- data/lib/voruby/votables/nsa.rb +0 -410
- data/lib/voruby/votables/rexml_parser.rb +0 -408
- data/lib/voruby/votables/rexml_votable.rb +0 -67
- data/lib/voruby/votables/sdss.rb +0 -356
- data/lib/voruby/votables/transforms.rb +0 -388
- data/lib/voruby/votables/tree.rb +0 -45
- data/lib/voruby/votables/types.rb +0 -391
- data/lib/voruby/votables/votable.rb +0 -687
- data/test/active_votable/database.yml +0 -6
- data/test/active_votable/test.vot +0 -168492
- data/test/active_votable/unittest.rb +0 -41
- data/test/adql/test1.adql +0 -49
- data/test/adql/test2.adql +0 -51
- data/test/adql/test3.adql +0 -81
- data/test/adql/test4.adql +0 -53
- data/test/adql/test5.adql +0 -55
- data/test/adql/test6.adql +0 -18
- data/test/adql/test7.adql +0 -48
- data/test/adql/unittest.rb +0 -1672
- data/test/plastic/test.rb +0 -44
- data/test/plastic/test.vot +0 -5385
- data/test/plastic/unittest.rb +0 -66
- data/test/resources/conesearch/conesearch_v0_3.xml +0 -31
- data/test/resources/conesearch/conesearch_v1_0.xml +0 -86
- data/test/resources/conesearch/unittest_v0_3.rb +0 -22
- data/test/resources/conesearch/unittest_v1_0.rb +0 -24
- data/test/resources/openskynode/open_sky_node_v0_1.xml +0 -32
- data/test/resources/openskynode/unittest_v0_1.rb +0 -31
- data/test/resources/sia/simple_image_access_v0_7.xml +0 -36
- data/test/resources/sia/simple_image_access_v1_0.xml +0 -122
- data/test/resources/sia/unittest_v0_7.rb +0 -24
- data/test/resources/sia/unittest_v1_0.rb +0 -29
- data/test/resources/stsci.xml +0 -336
- data/test/resources/unittest_stsci.rb +0 -25
- data/test/resources/vodataservice/catalog_service_resource_v1_0.xml +0 -128
- data/test/resources/vodataservice/data_collection_resource_v0_5.xml +0 -54
- data/test/resources/vodataservice/data_collection_resource_v1_0.xml +0 -117
- data/test/resources/vodataservice/data_service_resource_v1_0.xml +0 -115
- data/test/resources/vodataservice/sky_service_resource_v0_10.xml +0 -45
- data/test/resources/vodataservice/table_service_resource_v1_0.xml +0 -122
- data/test/resources/vodataservice/tabular_sky_service_resource_v0_10.xml +0 -60
- data/test/resources/vodataservice/unittest_v0_5.rb +0 -126
- data/test/resources/vodataservice/unittest_v1_0.rb +0 -151
- data/test/resources/voregistry/authority_resource_v0_3.xml +0 -20
- data/test/resources/voregistry/authority_resource_v1_0.xml +0 -82
- data/test/resources/voregistry/registry_service_v0_3.xml +0 -20
- data/test/resources/voregistry/registry_service_v1_0.xml +0 -107
- data/test/resources/voregistry/unittest_v0_3.rb +0 -31
- data/test/resources/voregistry/unittest_v1_0.rb +0 -34
- data/test/resources/voresource/organisation_resource_v1_0.xml +0 -90
- data/test/resources/voresource/resource_organisation_v0_10.xml +0 -22
- data/test/resources/voresource/resource_service_v0_10.xml +0 -19
- data/test/resources/voresource/resource_v0_10.xml +0 -19
- data/test/resources/voresource/resource_v1_0.xml +0 -79
- data/test/resources/voresource/service_resource_v1_0.xml +0 -91
- data/test/resources/voresource/unittest_v0_10.rb +0 -61
- data/test/resources/voresource/unittest_v0_9.rb +0 -4
- data/test/resources/voresource/unittest_v1_0.rb +0 -190
- data/test/services/gestalt/unittest.rb +0 -74
- data/test/services/registry/unittest.rb +0 -34
- data/test/services/resolver/unittest.rb +0 -38
- data/test/simple/unittest.rb +0 -46
- data/test/spacetime/unittest.rb +0 -39
- data/test/stc/catalog_entry_location_v1_20.xml +0 -112
- data/test/stc/obs_data_location_v1_20.xml +0 -108
- data/test/stc/search_location_v1_20.xml +0 -54
- data/test/stc/stc_resource_profile_v1_20.xml +0 -60
- data/test/stc/unittest_v1_20.rb +0 -620
- data/test/voevent/unittest_v1_0.rb +0 -79
- data/test/voevent/unittest_v1_1.rb +0 -70
- data/test/voevent/voevent_v1_0.xml +0 -96
- data/test/votables/test.vot +0 -366
- data/test/votables/unittest.rb +0 -54
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
require 'voruby/ucd/ucd'
|
4
|
+
include VORuby
|
5
|
+
|
6
|
+
class UCDTest < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@ucd = UCD.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_translate
|
12
|
+
assert_equal 'phot.mag;em.opt.V', @ucd.translate('PHOT_JHN_V')
|
13
|
+
assert_equal 'pos.eq.ra;meta.main', @ucd.translate('POS_EQ_RA_MAIN')
|
14
|
+
assert_equal nil, @ucd.translate('blah')
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_assign
|
18
|
+
assert_equal 'phot.mag;em.opt.V', @ucd.assign('V magnitude')
|
19
|
+
assert_equal nil, @ucd.assign('blah')
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_explain
|
23
|
+
assert_equal 'Photometric magnitude / Optical band between 400 and 500 nm', @ucd.explain('ivoa:phot.mag;em.opt.B')
|
24
|
+
assert_equal nil, @ucd.explain('blah')
|
25
|
+
|
26
|
+
assert_equal 'Johnson magnitude V (JHN)', @ucd.explain('PHOT_JHN_V', '1')
|
27
|
+
assert_equal nil, @ucd.explain('blah', '1')
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_validate
|
31
|
+
result = @ucd.validate('ivob:phot.mag;em.opt.Z')
|
32
|
+
assert_equal 5, result.code
|
33
|
+
assert_equal ["use of non-standard namespace 'ivob'", "invalid UCD word 'em.opt.Z'"], result.errors
|
34
|
+
|
35
|
+
result = @ucd.validate('ivoa:phot.mag;em.opt.B')
|
36
|
+
assert_equal 0, result.code
|
37
|
+
assert_equal [], result.errors
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_valid
|
41
|
+
assert_equal false, @ucd.valid?('ivob:phot.mag;em.opt.Z')
|
42
|
+
assert_equal true, @ucd.valid?('ivoa:phot.mag;em.opt.B')
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_upgrade
|
46
|
+
assert_equal 'pos.galactic.lat', @ucd.upgrade('pos.gal.lat')
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,812 @@
|
|
1
|
+
require 'voruby/voevent/1.1/voevent'
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
include VORuby::VOEvent::V1_1
|
5
|
+
|
6
|
+
module VORuby
|
7
|
+
module VOEvent
|
8
|
+
module V1_1
|
9
|
+
module Test
|
10
|
+
|
11
|
+
class ReferenceTest < ::Test::Unit::TestCase
|
12
|
+
def setup
|
13
|
+
@uri = URI.parse('http://www.noao.edu/')
|
14
|
+
@type = 'ref'
|
15
|
+
@name = 'NOAO'
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_construction
|
19
|
+
assert_nothing_raised {
|
20
|
+
Reference.new(@uri, @type, @name)
|
21
|
+
Reference.new(@uri, @type)
|
22
|
+
Reference.new(@uri)
|
23
|
+
}
|
24
|
+
|
25
|
+
assert_raises ArgumentError do
|
26
|
+
Reference.new(nil)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_accessors
|
31
|
+
r = Reference.new(@uri, @type, @name)
|
32
|
+
|
33
|
+
assert_equal @uri, r.uri
|
34
|
+
assert_equal @type, r.type
|
35
|
+
assert_equal @name, r.name
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_xml
|
39
|
+
r1 = Reference.new(@uri, @type, @name)
|
40
|
+
r2 = Reference.from_xml(r1.to_xml)
|
41
|
+
|
42
|
+
assert_equal r1, r2
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class DescriptionTest < ::Test::Unit::TestCase
|
47
|
+
def setup
|
48
|
+
@value = 'This is a description...'
|
49
|
+
@format = 'image/gif'
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_construction
|
53
|
+
assert_nothing_raised {
|
54
|
+
Description.new(@value, @format)
|
55
|
+
Description.new(@value)
|
56
|
+
}
|
57
|
+
|
58
|
+
assert_raises ArgumentError do
|
59
|
+
Description.new(nil)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_accessors
|
64
|
+
d = Description.new(@value, @format)
|
65
|
+
|
66
|
+
assert_equal @value, d.value
|
67
|
+
assert_equal @format, d.format
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_xml
|
71
|
+
d1 = Description.new(@value, @format)
|
72
|
+
d2 = Description.from_xml(d1.to_xml)
|
73
|
+
|
74
|
+
assert_equal d1, d2
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
class EventIVORNTest < ::Test::Unit::TestCase
|
79
|
+
def setup
|
80
|
+
@uri = URI.parse('http://www.noao.edu/')
|
81
|
+
@cite = Cite.new('supersedes')
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_construction
|
85
|
+
assert_nothing_raised {
|
86
|
+
EventIVORN.new(@uri, @cite)
|
87
|
+
}
|
88
|
+
|
89
|
+
assert_raises TypeError do
|
90
|
+
EventIVORN.new(@uri, 123)
|
91
|
+
end
|
92
|
+
|
93
|
+
assert_raises ArgumentError do
|
94
|
+
EventIVORN.new(@uri, nil)
|
95
|
+
end
|
96
|
+
assert_raises ArgumentError do
|
97
|
+
EventIVORN.new(nil, @cite)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_accessors
|
102
|
+
i = EventIVORN.new(@uri, @cite)
|
103
|
+
|
104
|
+
assert_equal @uri, i.uri
|
105
|
+
assert_equal @cite, i.cite
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_xml
|
109
|
+
i1 = EventIVORN.new(@uri, @cite)
|
110
|
+
i2 = EventIVORN.from_xml(i1.to_xml)
|
111
|
+
|
112
|
+
assert_equal i1, i2
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
class CitationsTest < ::Test::Unit::TestCase
|
117
|
+
def setup
|
118
|
+
@ivorns = [
|
119
|
+
EventIVORN.new('http://www.noao.edu/', 'supersedes'),
|
120
|
+
EventIVORN.new('http://www.stsci.edu/', 'followup')
|
121
|
+
]
|
122
|
+
@descriptions = [Description.new('We did stuff to cause this change.')]
|
123
|
+
@references = [Reference.new('http://www.noao.edu/staff/dgasson', 'url', 'Me')]
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_construction
|
127
|
+
assert_nothing_raised {
|
128
|
+
Citations.new(@ivorns, @descriptions, @references)
|
129
|
+
Citations.new(@ivorns, @descriptions)
|
130
|
+
Citations.new(@ivorns)
|
131
|
+
}
|
132
|
+
|
133
|
+
assert_raises ArgumentError do
|
134
|
+
Citations.new(nil)
|
135
|
+
end
|
136
|
+
|
137
|
+
assert_raises TypeError do
|
138
|
+
Citations.new(@ivorns, @descriptions, 123)
|
139
|
+
end
|
140
|
+
assert_raises TypeError do
|
141
|
+
Citations.new(@ivorns, 123, @references)
|
142
|
+
end
|
143
|
+
assert_raises TypeError do
|
144
|
+
Citations.new('blah', @descriptions, @references)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_accessors
|
149
|
+
c = Citations.new(@ivorns, @descriptions, @references)
|
150
|
+
|
151
|
+
assert_equal @ivorns, c.event_ivorns
|
152
|
+
assert_equal @descriptions, c.descriptions
|
153
|
+
assert_equal @references, c.references
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_xml
|
157
|
+
c1 = Citations.new(@ivorns, @descriptions, @references)
|
158
|
+
c2 = Citations.from_xml(c1.to_xml)
|
159
|
+
|
160
|
+
assert_equal c1, c2
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
class HowTest < ::Test::Unit::TestCase
|
165
|
+
def setup
|
166
|
+
@descriptions = [Description.new('We did stuff.')]
|
167
|
+
@references = [Reference.new('http://nsa.noao.edu/kp012345.rtml', 'rtml', 'Echelle')]
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_construction
|
171
|
+
assert_nothing_raised {
|
172
|
+
How.new(@descriptions, @references)
|
173
|
+
How.new(@descriptions)
|
174
|
+
How.new(nil, @references)
|
175
|
+
How.new
|
176
|
+
}
|
177
|
+
|
178
|
+
assert_raises TypeError do
|
179
|
+
How.new(@descriptions, 'blah')
|
180
|
+
end
|
181
|
+
assert_raises TypeError do
|
182
|
+
How.new('blah', @references)
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def test_accessors
|
187
|
+
h = How.new(@descriptions, @references)
|
188
|
+
|
189
|
+
assert_equal @descriptions, h.descriptions
|
190
|
+
assert_equal @references, h.references
|
191
|
+
end
|
192
|
+
|
193
|
+
def test_xml
|
194
|
+
h1 = How.new(@descriptions, @references)
|
195
|
+
h2 = How.from_xml(h1.to_xml)
|
196
|
+
|
197
|
+
assert_equal h1, h2
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
class WhereWhenTest < ::Test::Unit::TestCase
|
202
|
+
def setup
|
203
|
+
observatory_location = ObservatoryLocationType.new(
|
204
|
+
[AstroCoordSystem.new(
|
205
|
+
nil,
|
206
|
+
TimeFrame.new(TOPOCENTER.new, TimeScaleType.new('TT')),
|
207
|
+
SpaceFrame.new(GEO_D.new(nil, nil, nil, nil), TOPOCENTER.new, SPHERICAL.new(3)),
|
208
|
+
nil, nil, :id => 'TT-GEOD-TOPO'
|
209
|
+
)],
|
210
|
+
[AstroCoords.new(
|
211
|
+
'TT-GEOD-TOPO',
|
212
|
+
nil,
|
213
|
+
:position => Position3D.new(
|
214
|
+
:value => Value3.new(
|
215
|
+
Double1Type.new(248.4056, :pos_unit => 'deg'),
|
216
|
+
Double1Type.new(31.9586, :pos_unit => 'deg'),
|
217
|
+
Double1Type.new(2158.0, :pos_unit => 'm')
|
218
|
+
)
|
219
|
+
)
|
220
|
+
)],
|
221
|
+
nil,
|
222
|
+
:id => 'KPNO'
|
223
|
+
)
|
224
|
+
|
225
|
+
observation_location = AstroSTCDescriptionType.new(
|
226
|
+
[AstroCoordSystem.new(
|
227
|
+
[CoordFrame.new(ScalarRefFrame.new(1.0, nil, nil), nil, CARTESIAN.new(1), 'Brightness', :ucd => 'em...', :id => 'brightness')],
|
228
|
+
TimeFrame.new(TOPOCENTER.new, TimeScaleType.new('TT')),
|
229
|
+
SpaceFrame.new(ICRS.new, TOPOCENTER.new, SPHERICAL.new(2), nil, nil, :id => 'spaceFrame'),
|
230
|
+
SpectralFrame.new(TOPOCENTER.new),
|
231
|
+
nil,
|
232
|
+
:id => 'TT-ICRS-WAVELENGTH-TOPO'
|
233
|
+
)],
|
234
|
+
[AstroCoords.new(
|
235
|
+
'TT-ICRS-WAVELENGTH-TOPO',
|
236
|
+
[ScalarCoordinate.new(
|
237
|
+
:unit => 'mJy/arcsec**2',
|
238
|
+
:frame_id => 'brightness',
|
239
|
+
:error => [Error.new(0.001)]
|
240
|
+
)],
|
241
|
+
:time => STC::V1_30::Time.new(
|
242
|
+
:time_instant => AstronTimeType.new(:absolute_time => ISOTime.new('2004-07-15T08:23:56')),
|
243
|
+
:resolution => [Resolution.new(1000.0)],
|
244
|
+
:pix_size => [PixSize.new(1000.0)]
|
245
|
+
),
|
246
|
+
:position => Position2D.new(
|
247
|
+
:unit => 'deg',
|
248
|
+
:value => Value2.new(148.88821, 69.06529, :id => 'Center'),
|
249
|
+
:error => [Error2Radius.new(0.0003)],
|
250
|
+
:resolution => [Resolution2.new(0.00025, 0.00025)],
|
251
|
+
:pix_size => [PixSize2.new(0.0001, 0.0001)]
|
252
|
+
),
|
253
|
+
:spectral => Spectral.new(
|
254
|
+
:unit => 'Angstrom',
|
255
|
+
:value => Value.new(4600.0),
|
256
|
+
:resolution => [Resolution.new(400.0)],
|
257
|
+
:pix_size => [PixSize.new(400.0)]
|
258
|
+
)
|
259
|
+
)],
|
260
|
+
[AstroCoordArea.new(
|
261
|
+
'TT-ICRS-WAVELENGTH-TOPO',
|
262
|
+
[CoordScalarInterval.new(0.0, 10.0, nil, nil, :frame_id => 'brightness')],
|
263
|
+
[TimeIntervalType.new(
|
264
|
+
AstronTimeType.new(:absolute_time => ISOTime.new('2004-07-15T08:17:36')),
|
265
|
+
AstronTimeType.new(:absolute_time => ISOTime.new('2004-07-15T08:30:16'))
|
266
|
+
)],
|
267
|
+
Position2VecInterval.new(
|
268
|
+
Double2Type.new(148.18821, 68.81529),
|
269
|
+
Double2Type.new(149.58821, 69.31529),
|
270
|
+
nil, nil,
|
271
|
+
:unit => 'deg'
|
272
|
+
),
|
273
|
+
nil,
|
274
|
+
[SpectralIntervalType.new(
|
275
|
+
'Angstrom',
|
276
|
+
Double1Type.new(4400.0),
|
277
|
+
Double1Type.new(4800.0)
|
278
|
+
)],
|
279
|
+
nil,
|
280
|
+
:id => 'M81Image'
|
281
|
+
)],
|
282
|
+
:id => 'M81'
|
283
|
+
)
|
284
|
+
|
285
|
+
@obs_data_locations = [ObsDataLocation.new(observatory_location, observation_location)]
|
286
|
+
@descriptions = [Description.new('We did stuff.')]
|
287
|
+
@references = [Reference.new('http://nsa.noao.edu/kp012345.rtml', 'rtml', 'Echelle')]
|
288
|
+
end
|
289
|
+
|
290
|
+
def test_construction
|
291
|
+
assert_nothing_raised {
|
292
|
+
WhereWhen.new(@obs_data_locations, @descriptions, @references)
|
293
|
+
WhereWhen.new(@obs_data_locations, @descriptions)
|
294
|
+
WhereWhen.new(@obs_data_locations)
|
295
|
+
WhereWhen.new(nil, nil, nil)
|
296
|
+
WhereWhen.new
|
297
|
+
}
|
298
|
+
|
299
|
+
assert_raises TypeError do
|
300
|
+
WhereWhen.new(@obs_data_locations, @descriptions, 'blah')
|
301
|
+
end
|
302
|
+
assert_raises TypeError do
|
303
|
+
WhereWhen.new(@obs_data_locations, 'blah', @references)
|
304
|
+
end
|
305
|
+
assert_raises TypeError do
|
306
|
+
WhereWhen.new('blah', @descriptions, @references)
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
def test_accessors
|
311
|
+
w = WhereWhen.new(@obs_data_locations, @descriptions, @references)
|
312
|
+
|
313
|
+
assert_equal @obs_data_locations, w.obs_data_locations
|
314
|
+
assert_equal @descriptions, w.descriptions
|
315
|
+
assert_equal @references, w.references
|
316
|
+
end
|
317
|
+
|
318
|
+
def test_xml
|
319
|
+
w1 = WhereWhen.new(@obs_data_locations, @descriptions, @references)
|
320
|
+
w2 = WhereWhen.from_xml(w1.to_xml)
|
321
|
+
|
322
|
+
assert_equal w1, w2
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
class InferenceTest < ::Test::Unit::TestCase
|
327
|
+
def setup
|
328
|
+
@names = ['Tycho\'s Stella Nova']
|
329
|
+
@concepts = ['stars.supernova.Ia']
|
330
|
+
@probability = 1.0
|
331
|
+
@relation = 'associated'
|
332
|
+
@descriptions = [Description.new('We did stuff.')]
|
333
|
+
@references = [Reference.new('http://nsa.noao.edu/kp012345.rtml', 'rtml', 'Echelle')]
|
334
|
+
end
|
335
|
+
|
336
|
+
def test_construction
|
337
|
+
assert_nothing_raised {
|
338
|
+
Inference.new(@names, @concepts, @probability, @relation, @descriptions, @references)
|
339
|
+
Inference.new(@names, @concepts, @probability, @relation)
|
340
|
+
Inference.new(@names, @concepts, @probability)
|
341
|
+
Inference.new(@names, @concepts)
|
342
|
+
Inference.new(@names, nil)
|
343
|
+
Inference.new(nil, @concepts)
|
344
|
+
Inference.new(nil, nil)
|
345
|
+
}
|
346
|
+
|
347
|
+
assert_raises TypeError do
|
348
|
+
Inference.new(123, @concepts)
|
349
|
+
end
|
350
|
+
assert_raises TypeError do
|
351
|
+
Inference.new(@names, 123)
|
352
|
+
end
|
353
|
+
|
354
|
+
assert_raises RuntimeError do
|
355
|
+
Inference.new(@names, @concepts, -0.2)
|
356
|
+
end
|
357
|
+
assert_raises RuntimeError do
|
358
|
+
Inference.new(@names, @concepts, 2.3)
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
def test_accessors
|
363
|
+
i = Inference.new(@names, @concepts, @probability, @relation, @descriptions, @references)
|
364
|
+
|
365
|
+
assert_equal @names, i.names
|
366
|
+
assert_equal @concepts, i.concepts
|
367
|
+
assert_equal @probability, i.probability
|
368
|
+
assert_equal @relation, i.relation
|
369
|
+
assert_equal @descriptions, i.descriptions
|
370
|
+
assert_equal @references, i.references
|
371
|
+
end
|
372
|
+
|
373
|
+
def test_xml
|
374
|
+
i1 = Inference.new(@names, @concepts, @probability, @relation, @descriptions, @references)
|
375
|
+
i2 = Inference.from_xml(i1.to_xml)
|
376
|
+
|
377
|
+
assert_equal i1, i2
|
378
|
+
end
|
379
|
+
end
|
380
|
+
|
381
|
+
class WhyTest < ::Test::Unit::TestCase
|
382
|
+
def setup
|
383
|
+
@inferences = [
|
384
|
+
Inference.new(["Tycho's Stella Nova"], ["stars.supernova.Ia"], 1.0),
|
385
|
+
Inference.new(['3C 10'], ['ISM.SNRemnant'], 1.0, 'associated', [Description.new('Supernova remnant')])
|
386
|
+
]
|
387
|
+
@names = ['Name1']
|
388
|
+
@concepts = ['Concept1']
|
389
|
+
@descriptions = [Description.new('We did stuff.')]
|
390
|
+
@references = [Reference.new('http://nsa.noao.edu/kp012345.rtml', 'rtml', 'Echelle')]
|
391
|
+
@importance = 1.0
|
392
|
+
@expires = DateTime.parse("1574-05-11T12:00:00")
|
393
|
+
end
|
394
|
+
|
395
|
+
def test_construction
|
396
|
+
assert_nothing_raised {
|
397
|
+
Why.new(@inferences, @importance, @expires, @names, @concepts, @descriptions, @references)
|
398
|
+
Why.new(@inferences, @importance, @expires, @names, @concepts)
|
399
|
+
Why.new(@inferences, @importance, @expires)
|
400
|
+
Why.new(@inferences, @importance)
|
401
|
+
Why.new(@inferences)
|
402
|
+
Why.new(nil)
|
403
|
+
}
|
404
|
+
|
405
|
+
assert_raises TypeError do
|
406
|
+
Why.new('blah')
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
def test_accessors
|
411
|
+
w = Why.new(@inferences, @importance, @expires, @names, @concepts, @descriptions, @references)
|
412
|
+
|
413
|
+
assert_equal @inferences, w.inferences
|
414
|
+
assert_equal @importance, w.importance
|
415
|
+
assert_equal @expires, w.expires
|
416
|
+
assert_equal @names, w.names
|
417
|
+
assert_equal @concepts, w.concepts
|
418
|
+
assert_equal @descriptions, w.descriptions
|
419
|
+
assert_equal @references, w.references
|
420
|
+
end
|
421
|
+
|
422
|
+
def test_xml
|
423
|
+
w1 = Why.new(@inferences, @importance, @expires, @names, @concepts, @descriptions, @references)
|
424
|
+
w2 = Why.from_xml(w1.to_xml)
|
425
|
+
|
426
|
+
assert_equal w1, w2
|
427
|
+
end
|
428
|
+
end
|
429
|
+
|
430
|
+
class ParamTest < ::Test::Unit::TestCase
|
431
|
+
def setup
|
432
|
+
@name = 'TRIGGER_NUM'
|
433
|
+
@value = '114299'
|
434
|
+
@ucd = 'meta.id'
|
435
|
+
@unit = 'whatever'
|
436
|
+
end
|
437
|
+
|
438
|
+
def test_construction
|
439
|
+
assert_nothing_raised {
|
440
|
+
Param.new(@name, @value, @ucd, @unit)
|
441
|
+
Param.new(@name, @value, @ucd)
|
442
|
+
Param.new(@name, @value)
|
443
|
+
Param.new(@name, nil)
|
444
|
+
Param.new(nil, @name)
|
445
|
+
Param.new(nil, nil)
|
446
|
+
}
|
447
|
+
end
|
448
|
+
|
449
|
+
def test_accessors
|
450
|
+
p = Param.new(@name, @value, @ucd, @unit)
|
451
|
+
|
452
|
+
assert_equal @name, p.name
|
453
|
+
assert_equal @value, p.value
|
454
|
+
assert_equal @ucd, p.ucd
|
455
|
+
assert_equal @unit, p.unit
|
456
|
+
end
|
457
|
+
|
458
|
+
def test_xml
|
459
|
+
p1 = Param.new(@name, @value, @ucd, @unit)
|
460
|
+
p2 = Param.from_xml(p1.to_xml)
|
461
|
+
|
462
|
+
assert_equal p1, p2
|
463
|
+
end
|
464
|
+
end
|
465
|
+
|
466
|
+
class GroupTest < ::Test::Unit::TestCase
|
467
|
+
def setup
|
468
|
+
@params = [Param.new('TRIGGER_NUM', '114299', 'meta.id', 'whatever')]
|
469
|
+
@name = 'whatever'
|
470
|
+
@type = 'phot_pt'
|
471
|
+
@descriptions = [Description.new('We did stuff.')]
|
472
|
+
@references = [Reference.new('http://nsa.noao.edu/kp012345.rtml', 'rtml', 'Echelle')]
|
473
|
+
end
|
474
|
+
|
475
|
+
def test_construction
|
476
|
+
assert_nothing_raised {
|
477
|
+
Group.new(@params, @name, @type, @descriptions, @references)
|
478
|
+
Group.new(@params, @name, @type)
|
479
|
+
Group.new(@params, @name)
|
480
|
+
Group.new(@params)
|
481
|
+
Group.new(nil)
|
482
|
+
}
|
483
|
+
|
484
|
+
assert_raises TypeError do
|
485
|
+
Group.new('blah')
|
486
|
+
end
|
487
|
+
end
|
488
|
+
|
489
|
+
def test_accessors
|
490
|
+
g = Group.new(@params, @name, @type, @descriptions, @references)
|
491
|
+
|
492
|
+
assert_equal @params, g.params
|
493
|
+
assert_equal @name, g.name
|
494
|
+
assert_equal @type, g.type
|
495
|
+
assert_equal @descriptions, g.descriptions
|
496
|
+
assert_equal @references, g.references
|
497
|
+
end
|
498
|
+
|
499
|
+
def test_xml
|
500
|
+
g1 = Group.new(@params, @name, @type, @descriptions, @references)
|
501
|
+
g2 = Group.from_xml(g1.to_xml)
|
502
|
+
|
503
|
+
assert_equal g1, g2
|
504
|
+
end
|
505
|
+
end
|
506
|
+
|
507
|
+
class WhatTest < ::Test::Unit::TestCase
|
508
|
+
def setup
|
509
|
+
@groups = [
|
510
|
+
Group.new(
|
511
|
+
[Param.new('mag', '13.2', 'phot.ma;em.opt.R'), Param.new('epoch', '245523.12345', 'time.epoch')],
|
512
|
+
nil, 'phot_pt'
|
513
|
+
),
|
514
|
+
Group.new(
|
515
|
+
[Param.new('mag', '13.4', 'phot.ma;em.opt.R'), Param.new('epoch', '245523.46533', 'time.epoch')],
|
516
|
+
nil, 'phot_pt'
|
517
|
+
),
|
518
|
+
Group.new(
|
519
|
+
[Param.new('mag', '13.0', 'phot.ma;em.opt.R'), Param.new('epoch', '245523.76444', 'time.epoch')],
|
520
|
+
nil, 'phot_pt'
|
521
|
+
)
|
522
|
+
]
|
523
|
+
|
524
|
+
@params = [Param.new('TRIGGER_NUM', '114299', 'meta.id', 'whatever')]
|
525
|
+
@descriptions = [Description.new('We did stuff.')]
|
526
|
+
@references = [Reference.new('http://nsa.noao.edu/kp012345.rtml', 'rtml', 'Echelle')]
|
527
|
+
end
|
528
|
+
|
529
|
+
def test_construction
|
530
|
+
assert_nothing_raised {
|
531
|
+
What.new(@groups, @params, @descriptions, @references)
|
532
|
+
What.new(@groups, @params)
|
533
|
+
What.new(@groups)
|
534
|
+
What.new(nil)
|
535
|
+
}
|
536
|
+
|
537
|
+
assert_raise TypeError do
|
538
|
+
What.new('blah', @params)
|
539
|
+
end
|
540
|
+
assert_raise TypeError do
|
541
|
+
What.new(@groups, 'blah')
|
542
|
+
end
|
543
|
+
end
|
544
|
+
|
545
|
+
def test_accessors
|
546
|
+
w = What.new(@groups, @params, @descriptions, @references)
|
547
|
+
|
548
|
+
assert_equal @groups, w.groups
|
549
|
+
assert_equal @params, w.params
|
550
|
+
assert_equal @descriptions, w.descriptions
|
551
|
+
assert_equal @references, w.references
|
552
|
+
end
|
553
|
+
|
554
|
+
def test_xml
|
555
|
+
w1 = What.new(@groups, @params, @descriptions, @references)
|
556
|
+
w2 = What.from_xml(w1.to_xml)
|
557
|
+
|
558
|
+
assert_equal w1, w2
|
559
|
+
end
|
560
|
+
end
|
561
|
+
|
562
|
+
class AuthorTest < ::Test::Unit::TestCase
|
563
|
+
def setup
|
564
|
+
@titles = ['Rapid Telescope for Optical Response']
|
565
|
+
@short_names = ['Raptor']
|
566
|
+
@logo_urls = ['http://www.raptor.lanl.gov/images/RAPTOR_patchLarge.jpg']
|
567
|
+
@contact_names = ['Robert White']
|
568
|
+
@contact_emails = ['rwhite@lanl.gov']
|
569
|
+
@contact_phones = ['+1 800 555 1212']
|
570
|
+
@contributors = ['whoever']
|
571
|
+
end
|
572
|
+
|
573
|
+
def test_construction
|
574
|
+
assert_nothing_raised {
|
575
|
+
Author.new(
|
576
|
+
:titles => @titles, :short_names => @short_names, :logo_urls => @logo_urls,
|
577
|
+
:contact_names => @contact_names, :contact_emails => @contact_emails, :contact_phones => @contact_phones,
|
578
|
+
:contributors => @contributors
|
579
|
+
)
|
580
|
+
Author.new(
|
581
|
+
:titles => @titles, :short_names => @short_names, :logo_urls => @logo_urls,
|
582
|
+
:contact_names => @contact_names, :contact_emails => @contact_emails, :contact_phones => @contact_phones
|
583
|
+
)
|
584
|
+
Author.new(
|
585
|
+
:titles => @titles, :short_names => @short_names, :logo_urls => @logo_urls,
|
586
|
+
:contact_names => @contact_names, :contact_emails => @contact_emails
|
587
|
+
)
|
588
|
+
Author.new(
|
589
|
+
:titles => @titles, :short_names => @short_names, :logo_urls => @logo_urls,
|
590
|
+
:contact_names => @contact_names
|
591
|
+
)
|
592
|
+
Author.new(
|
593
|
+
:titles => @titles, :short_names => @short_names, :logo_urls => @logo_urls
|
594
|
+
)
|
595
|
+
Author.new(
|
596
|
+
:titles => @titles, :short_names => @short_names
|
597
|
+
)
|
598
|
+
Author.new(
|
599
|
+
:titles => @titles
|
600
|
+
)
|
601
|
+
Author.new
|
602
|
+
}
|
603
|
+
|
604
|
+
assert_raises TypeError do
|
605
|
+
Author.new(:titles => 123)
|
606
|
+
end
|
607
|
+
assert_raises TypeError do
|
608
|
+
Author.new(:short_names => 123)
|
609
|
+
end
|
610
|
+
assert_raises TypeError do
|
611
|
+
Author.new(:logo_urls => 123)
|
612
|
+
end
|
613
|
+
assert_raises TypeError do
|
614
|
+
Author.new(:contact_names => 123)
|
615
|
+
end
|
616
|
+
assert_raises TypeError do
|
617
|
+
Author.new(:contact_emails => 123)
|
618
|
+
end
|
619
|
+
assert_raises TypeError do
|
620
|
+
Author.new(:contact_phones => 123)
|
621
|
+
end
|
622
|
+
assert_raises TypeError do
|
623
|
+
Author.new(:contributors => 123)
|
624
|
+
end
|
625
|
+
end
|
626
|
+
|
627
|
+
def test_accessors
|
628
|
+
a = Author.new(
|
629
|
+
:titles => @titles, :short_names => @short_names, :logo_urls => @logo_urls,
|
630
|
+
:contact_names => @contact_names, :contact_emails => @contact_emails, :contact_phones => @contact_phones,
|
631
|
+
:contributors => @contributors
|
632
|
+
)
|
633
|
+
|
634
|
+
assert_equal @titles, a.titles
|
635
|
+
assert_equal @short_names, a.short_names
|
636
|
+
assert_equal @logo_urls, a.logo_urls
|
637
|
+
assert_equal @contact_names, a.contact_names
|
638
|
+
assert_equal @contact_emails, a.contact_emails
|
639
|
+
assert_equal @contact_phones, a.contact_phones
|
640
|
+
assert_equal @contributors, a.contributors
|
641
|
+
end
|
642
|
+
|
643
|
+
def test_xml
|
644
|
+
a1 = Author.new(
|
645
|
+
:titles => @titles, :short_names => @short_names, :logo_urls => @logo_urls,
|
646
|
+
:contact_names => @contact_names, :contact_emails => @contact_emails, :contact_phones => @contact_phones,
|
647
|
+
:contributors => @contributors
|
648
|
+
)
|
649
|
+
a2 = Author.from_xml(a1.to_xml)
|
650
|
+
|
651
|
+
assert_equal a1, a2
|
652
|
+
end
|
653
|
+
end
|
654
|
+
|
655
|
+
class WhoTest < ::Test::Unit::TestCase
|
656
|
+
def setup
|
657
|
+
@author_ivorns = [URI.parse('ivo://uraniborg.hven/Tycho')]
|
658
|
+
@dates = [DateTime.parse('1573-05-05T01:23:45Z')]
|
659
|
+
@authors = [Author.new(:titles => ['Rapid Telescope for Optical Response'])]
|
660
|
+
@descriptions = [Description.new('We did stuff.')]
|
661
|
+
@references = [Reference.new('http://nsa.noao.edu/kp012345.rtml', 'rtml', 'Echelle')]
|
662
|
+
end
|
663
|
+
|
664
|
+
def test_construction
|
665
|
+
assert_nothing_raised {
|
666
|
+
Who.new(@author_ivorns, @dates, @authors, @descriptions, @references)
|
667
|
+
Who.new(@author_ivorns, @dates, @authors)
|
668
|
+
Who.new(@author_ivorns, @dates)
|
669
|
+
Who.new(@author_ivorns, nil)
|
670
|
+
Who.new(nil, @dates)
|
671
|
+
Who.new(nil, nil)
|
672
|
+
}
|
673
|
+
|
674
|
+
assert_raises TypeError do
|
675
|
+
Who.new(@author_ivorns, @dates, 'blah')
|
676
|
+
end
|
677
|
+
assert_raises TypeError do
|
678
|
+
Who.new(@author_ivorns, 'blah', @authors)
|
679
|
+
end
|
680
|
+
assert_raises TypeError do
|
681
|
+
Who.new('blah', @dates, @authors)
|
682
|
+
end
|
683
|
+
end
|
684
|
+
|
685
|
+
def test_accessors
|
686
|
+
w = Who.new(@author_ivorns, @dates, @authors, @descriptions, @references)
|
687
|
+
|
688
|
+
assert_equal @author_ivorns, w.author_ivorns
|
689
|
+
assert_equal @dates, w.dates
|
690
|
+
assert_equal @authors, w.authors
|
691
|
+
assert_equal @descriptions, w.descriptions
|
692
|
+
assert_equal @references, w.references
|
693
|
+
end
|
694
|
+
|
695
|
+
def test_xml
|
696
|
+
w1 = Who.new(@author_ivorns, @dates, @authors, @descriptions, @references)
|
697
|
+
w2 = Who.from_xml(w1.to_xml)
|
698
|
+
|
699
|
+
assert_equal w1, w2
|
700
|
+
end
|
701
|
+
end
|
702
|
+
|
703
|
+
class VOEventTest < ::Test::Unit::TestCase
|
704
|
+
def setup
|
705
|
+
@ivorn = URI.parse('ivo://raptor.lanl/VOEvent#235649409')
|
706
|
+
@role = 'observation'
|
707
|
+
@version = '1.1'
|
708
|
+
@citations = Citations.new(
|
709
|
+
[EventIVORN.new(URI.parse('ivo://raptor.lanl/VOEvent#235649408'), 'followup')],
|
710
|
+
[Description.new('This is an observation of the earlier event but with improved square-galaxy discrimination')]
|
711
|
+
)
|
712
|
+
@who = Who.new(
|
713
|
+
[URI.parse('ivo://raptor.lanl/organization')],
|
714
|
+
[DateTime.parse('2005-04-15T14:34:16')]
|
715
|
+
)
|
716
|
+
@what = What.new(
|
717
|
+
[Group.new([Param.new('counts', '73288', 'phot.count', 'ct'), Param.new('peak', '1310', 'arith.rate;phot.count', 'ct/s')], 'SQUARE_GALAXY_FLUX')],
|
718
|
+
[Param.new('seeing', '2', 'instr.obsty.site.seeing', 'arcsec')],
|
719
|
+
[Description.new('This is the light curve associated with the observation.')],
|
720
|
+
[Reference.new(URI.parse('http://raptor.lanl.gov/data/lightcurves/235649409'))]
|
721
|
+
)
|
722
|
+
@where_when = WhereWhen.new()
|
723
|
+
@how = How.new(
|
724
|
+
[Description.new('This VOEvent packet resulted from observations made with Raptor AB at Los Alamos.')],
|
725
|
+
[Reference.new(URI.parse('http://www.raptor.lanl.gov/documents/phase_zero.rtml'), 'rtml', 'Raptor AB')]
|
726
|
+
)
|
727
|
+
@descriptions = [Description.new('We did stuff.')]
|
728
|
+
@references = [Reference.new('http://nsa.noao.edu/kp012345.rtml', 'rtml', 'Echelle')]
|
729
|
+
@why = Why.new(
|
730
|
+
[Inference.new(['NGC1234'], nil, 0.9, 'associated')],
|
731
|
+
0.8,
|
732
|
+
DateTime.parse('2005-04-16T02:34:16'),
|
733
|
+
nil,
|
734
|
+
['process.variation.burst;em.opt'],
|
735
|
+
[Description.new('Fast Orphan Optical Transient. Do not know what caused it, but looks like we found the host galaxy')]
|
736
|
+
)
|
737
|
+
end
|
738
|
+
|
739
|
+
def test_construction
|
740
|
+
assert_nothing_raised {
|
741
|
+
VOEvent.new(@ivorn, @who, @what, @where_when, @how, @why, @version, @role, @citations, @descriptions, @references)
|
742
|
+
VOEvent.new(@ivorn, @who, @what, @where_when, @how, @why, @version, @role, @citations)
|
743
|
+
VOEvent.new(@ivorn, @who, @what, @where_when, @how, @why, @version, @role)
|
744
|
+
VOEvent.new(@ivorn, @who, @what, @where_when, @how, @why, @version)
|
745
|
+
VOEvent.new(@ivorn, @who, @what, @where_when, @how, @why)
|
746
|
+
VOEvent.new(@ivorn, @who, @what, @where_when, @how, nil)
|
747
|
+
VOEvent.new(@ivorn, @who, @what, @where_when, nil, @why)
|
748
|
+
VOEvent.new(@ivorn, @who, @what, nil, @how, @why)
|
749
|
+
VOEvent.new(@ivorn, @who, nil, @where_when, @how, @why)
|
750
|
+
VOEvent.new(@ivorn, nil, @what, @where_when, @how, @why)
|
751
|
+
}
|
752
|
+
|
753
|
+
assert_raises ArgumentError do
|
754
|
+
VOEvent.new(nil, @who, @what, @where_when, @how, @why)
|
755
|
+
end
|
756
|
+
|
757
|
+
assert_raises TypeError do
|
758
|
+
VOEvent.new(@ivorn, @who, @what, @where_when, @how, @why, @version, @role, 'blah')
|
759
|
+
end
|
760
|
+
assert_raises TypeError do
|
761
|
+
VOEvent.new(@ivorn, @who, @what, @where_when, @how, 'blah', @version, @role, @citations)
|
762
|
+
end
|
763
|
+
assert_raises TypeError do
|
764
|
+
VOEvent.new(@ivorn, @who, @what, @where_when, 'blah', @why, @version, @role, @citations)
|
765
|
+
end
|
766
|
+
assert_raises TypeError do
|
767
|
+
VOEvent.new(@ivorn, @who, @what, 'blah', @how, @why, @version, @role, @citations)
|
768
|
+
end
|
769
|
+
assert_raises TypeError do
|
770
|
+
VOEvent.new(@ivorn, @who, 'blah', @where_when, @how, @why, @version, @role, @citations)
|
771
|
+
end
|
772
|
+
assert_raises TypeError do
|
773
|
+
VOEvent.new(@ivorn, 'blah', @what, @where_when, @how, @why, @version, @role, @citations)
|
774
|
+
end
|
775
|
+
end
|
776
|
+
|
777
|
+
def test_accessors
|
778
|
+
e = VOEvent.new(@ivorn, @who, @what, @where_when, @how, @why, @version, @role, @citations, @descriptions, @references)
|
779
|
+
|
780
|
+
assert_equal @ivorn, e.ivorn
|
781
|
+
assert_equal @who, e.who
|
782
|
+
assert_equal @what, e.what
|
783
|
+
assert_equal @where_when, e.where_when
|
784
|
+
assert_equal @how, e.how
|
785
|
+
assert_equal @why, e.why
|
786
|
+
assert_equal @version, e.version
|
787
|
+
assert_equal @role, e.role
|
788
|
+
assert_equal @citations, e.citations
|
789
|
+
assert_equal @descriptions, e.descriptions
|
790
|
+
assert_equal @references, e.references
|
791
|
+
end
|
792
|
+
|
793
|
+
def test_xml
|
794
|
+
e1 = VOEvent.new(@ivorn, @who, @what, @where_when, @how, @why, @version, @role, @citations, @descriptions, @references)
|
795
|
+
e2 = VOEvent.from_xml(e1.to_xml)
|
796
|
+
|
797
|
+
assert_equal e1, e2
|
798
|
+
end
|
799
|
+
end
|
800
|
+
|
801
|
+
class RealWorldTest < ::Test::Unit::TestCase
|
802
|
+
def test_real_world
|
803
|
+
assert_nothing_raised {
|
804
|
+
VOEvent.from_xml(File.new('test/voruby/voevent/1.1/voevent.xml')).to_xml
|
805
|
+
}
|
806
|
+
end
|
807
|
+
end
|
808
|
+
|
809
|
+
end
|
810
|
+
end
|
811
|
+
end
|
812
|
+
end
|