voruby 1.1.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 @@
|
|
1
|
+
SELECT g.fieldID, AVG(g.modelMag_u) AS avg_modelMag_u, AVG(g.modelMag_r) AS avg_modelMag_r FROM Galaxy g WHERE g.run = 1458 AND g.rerun = 40 AND g.camcol = 1 GROUP BY g.fieldID ORDER BY g.fieldID
|
@@ -0,0 +1,51 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<Select xmlns="http://www.ivoa.net/xml/ADQL/v1.0" xmlns:coo="http://www.ivoa.net/xml/STC/STCcoords/v1.10" xmlns:reg="http://www.ivoa.net/xml/STC/STCregion/v1.10" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
3
|
+
<SelectionList>
|
4
|
+
<Item xsi:type="columnReferenceType" Table="g" Name="fieldID"/>
|
5
|
+
<Item xsi:type="aliasSelectionItemType" As="avg_modelMag_u">
|
6
|
+
<Expression xsi:type="aggregateFunctionType" Name="AVG">
|
7
|
+
<Arg xsi:type="columnReferenceType" Table="g" Name="modelMag_u"/>
|
8
|
+
</Expression>
|
9
|
+
</Item>
|
10
|
+
<Item xsi:type="aliasSelectionItemType" As="avg_modelMag_r">
|
11
|
+
<Expression xsi:type="aggregateFunctionType" Name="AVG">
|
12
|
+
<Arg xsi:type="columnReferenceType" Table="g" Name="modelMag_r"/>
|
13
|
+
</Expression>
|
14
|
+
</Item>
|
15
|
+
</SelectionList>
|
16
|
+
<From>
|
17
|
+
<Table xsi:type="tableType" Name="Galaxy" Alias="g"/>
|
18
|
+
</From>
|
19
|
+
<Where>
|
20
|
+
<Condition xsi:type="intersectionSearchType">
|
21
|
+
<Condition xsi:type="intersectionSearchType">
|
22
|
+
<Condition xsi:type="comparisonPredType" Comparison="=">
|
23
|
+
<Arg xsi:type="columnReferenceType" Table="g" Name="run"/>
|
24
|
+
<Arg xsi:type="atomType">
|
25
|
+
<Literal xsi:type="integerType" Value="1458"/>
|
26
|
+
</Arg>
|
27
|
+
</Condition>
|
28
|
+
<Condition xsi:type="comparisonPredType" Comparison="=">
|
29
|
+
<Arg xsi:type="columnReferenceType" Table="g" Name="rerun"/>
|
30
|
+
<Arg xsi:type="atomType">
|
31
|
+
<Literal xsi:type="integerType" Value="40"/>
|
32
|
+
</Arg>
|
33
|
+
</Condition>
|
34
|
+
</Condition>
|
35
|
+
<Condition xsi:type="comparisonPredType" Comparison="=">
|
36
|
+
<Arg xsi:type="columnReferenceType" Table="g" Name="camcol"/>
|
37
|
+
<Arg xsi:type="atomType">
|
38
|
+
<Literal xsi:type="integerType" Value="1"/>
|
39
|
+
</Arg>
|
40
|
+
</Condition>
|
41
|
+
</Condition>
|
42
|
+
</Where>
|
43
|
+
<GroupBy>
|
44
|
+
<Column xsi:type="columnReferenceType" Table="g" Name="fieldID"/>
|
45
|
+
</GroupBy>
|
46
|
+
<OrderBy>
|
47
|
+
<Item xsi:type="orderType">
|
48
|
+
<Expression xsi:type="columnReferenceType" Table="g" Name="fieldID"/>
|
49
|
+
</Item>
|
50
|
+
</OrderBy>
|
51
|
+
</Select>
|
@@ -0,0 +1 @@
|
|
1
|
+
SELECT t.b, b.d FROM Tab t, Tab b GROUP BY t.b, b.d HAVING t.b <> d.b
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<Select xmlns="http://www.ivoa.net/xml/ADQL/v1.0" xmlns:coo="http://www.ivoa.net/xml/STC/STCcoords/v1.10" xmlns:reg="http://www.ivoa.net/xml/STC/STCregion/v1.10" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
3
|
+
|
4
|
+
<SelectionList>
|
5
|
+
<Item xsi:type="columnReferenceType" Table="t" Name="b"/>
|
6
|
+
<Item xsi:type="columnReferenceType" Table="b" Name="d"/>
|
7
|
+
</SelectionList>
|
8
|
+
|
9
|
+
<From>
|
10
|
+
<Table xsi:type="tableType" Name="Tab" Alias="t" />
|
11
|
+
<Table xsi:type="tableType" Name="Tab" Alias="b" />
|
12
|
+
</From>
|
13
|
+
|
14
|
+
<GroupBy>
|
15
|
+
<Column xsi:type="columnReferenceType" Table="t" Name="b"/>
|
16
|
+
<Column xsi:type="columnReferenceType" Table="b" Name="d"/>
|
17
|
+
</GroupBy>
|
18
|
+
|
19
|
+
<Having>
|
20
|
+
<Condition xsi:type="comparisonPredType" Comparison="<>">
|
21
|
+
<Arg xsi:type="columnReferenceType" Table="t" Name="b"/>
|
22
|
+
<Arg xsi:type="columnReferenceType" Table="d" Name="b"/>
|
23
|
+
</Condition>
|
24
|
+
</Having>
|
25
|
+
</Select>
|
@@ -0,0 +1 @@
|
|
1
|
+
SELECT * FROM resources r WHERE r.title LIKE '%quasar%'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<Select xmlns="http://www.ivoa.net/xml/ADQL/v1.0" xmlns:coo="http://www.ivoa.net/xml/STC/STCcoords/v1.10" xmlns:reg="http://www.ivoa.net/xml/STC/STCregion/v1.10" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
3
|
+
<SelectionList>
|
4
|
+
<Item xsi:type="allSelectionItemType"/>
|
5
|
+
</SelectionList>
|
6
|
+
<From>
|
7
|
+
<Table xsi:type="tableType" Name="resources" Alias="r"/>
|
8
|
+
</From>
|
9
|
+
<Where>
|
10
|
+
<Condition xsi:type="likePredType">
|
11
|
+
<Arg xsi:type="columnReferenceType" Table="r" Name="title"/>
|
12
|
+
<Pattern xsi:type="atomType">
|
13
|
+
<Literal xsi:type="stringType" Value="%quasar%"/>
|
14
|
+
</Pattern>
|
15
|
+
</Condition>
|
16
|
+
</Where>
|
17
|
+
</Select>
|
@@ -0,0 +1 @@
|
|
1
|
+
SELECT a.f, d.g FROM Tab a, Bob d WHERE a.d < d.e AND a.f < d.f ORDER BY a.f DESC, d.b
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<Select xmlns="http://www.ivoa.net/xml/ADQL/v1.0" xmlns:coo="http://www.ivoa.net/xml/STC/STCcoords/v1.10" xmlns:reg="http://www.ivoa.net/xml/STC/STCregion/v1.10" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
3
|
+
|
4
|
+
<SelectionList>
|
5
|
+
<Item xsi:type="columnReferenceType" Table="a" Name="f"/>
|
6
|
+
<Item xsi:type="columnReferenceType" Table="d" Name="g"/>
|
7
|
+
</SelectionList>
|
8
|
+
|
9
|
+
<From>
|
10
|
+
<Table xsi:type="tableType" Name="Tab" Alias="a" />
|
11
|
+
<Table xsi:type="tableType" Name="Bob" Alias="d" />
|
12
|
+
</From>
|
13
|
+
|
14
|
+
<Where>
|
15
|
+
<Condition xsi:type="intersectionSearchType">
|
16
|
+
<Condition xsi:type="comparisonPredType" Comparison="<">
|
17
|
+
<Arg xsi:type="columnReferenceType" Table="a" Name="d"/>
|
18
|
+
<Arg xsi:type="columnReferenceType" Table="d" Name="e"/>
|
19
|
+
</Condition>
|
20
|
+
<Condition xsi:type="comparisonPredType" Comparison="<">
|
21
|
+
<Arg xsi:type="columnReferenceType" Table="a" Name="f"/>
|
22
|
+
<Arg xsi:type="columnReferenceType" Table="d" Name="f"/>
|
23
|
+
</Condition>
|
24
|
+
</Condition>
|
25
|
+
</Where>
|
26
|
+
|
27
|
+
<OrderBy>
|
28
|
+
<Item xsi:type="orderType">
|
29
|
+
<Expression xsi:type="columnReferenceType" Table="a" Name="f"/>
|
30
|
+
<Order xsi:type="orderOptionType" Direction="DESC"/>
|
31
|
+
</Item>
|
32
|
+
<Item xsi:type="orderType">
|
33
|
+
<Expression xsi:type="columnReferenceType" Table="d" Name="b"/>
|
34
|
+
</Item>
|
35
|
+
</OrderBy>
|
36
|
+
|
37
|
+
</Select>
|
@@ -0,0 +1 @@
|
|
1
|
+
SELECT * FROM Tab a
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<Select xmlns="http://www.ivoa.net/xml/ADQL/v1.0" xmlns:coo="http://www.ivoa.net/xml/STC/STCcoords/v1.10" xmlns:reg="http://www.ivoa.net/xml/STC/STCregion/v1.10" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
3
|
+
|
4
|
+
<SelectionList>
|
5
|
+
<Item xsi:type="allSelectionItemType" />
|
6
|
+
</SelectionList>
|
7
|
+
|
8
|
+
<From>
|
9
|
+
<Table xsi:type="tableType" Name="Tab" Alias="a" />
|
10
|
+
</From>
|
11
|
+
|
12
|
+
</Select>
|
@@ -0,0 +1 @@
|
|
1
|
+
SELECT TOP 100 a.f, d.g FROM Tab a, Bob d WHERE a.d < d.e AND a.f < d.f ORDER BY a.f DESC, d.b
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<Select xmlns="http://www.ivoa.net/xml/ADQL/v1.0" xmlns:coo="http://www.ivoa.net/xml/STC/STCcoords/v1.10" xmlns:reg="http://www.ivoa.net/xml/STC/STCregion/v1.10" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
3
|
+
<Restrict Top="100"/>
|
4
|
+
<SelectionList>
|
5
|
+
<Item xsi:type="columnReferenceType" Table="a" Name="f"/>
|
6
|
+
<Item xsi:type="columnReferenceType" Table="d" Name="g"/>
|
7
|
+
</SelectionList>
|
8
|
+
<From>
|
9
|
+
<Table xsi:type="tableType" Name="Tab" Alias="a"/>
|
10
|
+
<Table xsi:type="tableType" Name="Bob" Alias="d"/>
|
11
|
+
</From>
|
12
|
+
<Where>
|
13
|
+
<Condition xsi:type="intersectionSearchType">
|
14
|
+
<Condition xsi:type="comparisonPredType" Comparison="<">
|
15
|
+
<Arg xsi:type="columnReferenceType" Table="a" Name="d"/>
|
16
|
+
<Arg xsi:type="columnReferenceType" Table="d" Name="e"/>
|
17
|
+
</Condition>
|
18
|
+
<Condition xsi:type="comparisonPredType" Comparison="<">
|
19
|
+
<Arg xsi:type="columnReferenceType" Table="a" Name="f"/>
|
20
|
+
<Arg xsi:type="columnReferenceType" Table="d" Name="f"/>
|
21
|
+
</Condition>
|
22
|
+
</Condition>
|
23
|
+
</Where>
|
24
|
+
<OrderBy>
|
25
|
+
<Item xsi:type="orderType">
|
26
|
+
<Expression xsi:type="columnReferenceType" Table="a" Name="f"/>
|
27
|
+
<Order xsi:type="orderOptionType" Direction="DESC"/>
|
28
|
+
</Item>
|
29
|
+
<Item xsi:type="orderType">
|
30
|
+
<Expression xsi:type="columnReferenceType" Table="d" Name="b"/>
|
31
|
+
</Item>
|
32
|
+
</OrderBy>
|
33
|
+
</Select>
|
@@ -0,0 +1,2220 @@
|
|
1
|
+
require 'voruby/adql/1.0/adql'
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
include VORuby::ADQL::V1_0
|
5
|
+
|
6
|
+
module VORuby
|
7
|
+
module ADQL
|
8
|
+
module V1_0
|
9
|
+
module Test
|
10
|
+
|
11
|
+
class ClosedExprTest < ::Test::Unit::TestCase
|
12
|
+
def setup
|
13
|
+
@scalar_expression = ColumnReference.new('a', 'ra', 'right_ascension')
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_construction
|
17
|
+
assert_nothing_raised {
|
18
|
+
ClosedExpr.new(@scalar_expression)
|
19
|
+
}
|
20
|
+
|
21
|
+
assert_raises ArgumentError do
|
22
|
+
ClosedExpr.new(nil)
|
23
|
+
end
|
24
|
+
|
25
|
+
assert_raises TypeError do
|
26
|
+
ClosedExpr.new('blah')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_accessors
|
31
|
+
e = ClosedExpr.new(@scalar_expression)
|
32
|
+
|
33
|
+
assert_equal @scalar_expression, e.arg
|
34
|
+
e.arg = ColumnReference.new('b', 'dec')
|
35
|
+
assert_equal ColumnReference.new('b', 'dec'), e.arg
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_relationships
|
39
|
+
assert_kind_of ScalarExpression, ClosedExpr.new(@scalar_expression)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_to_s
|
43
|
+
e = ClosedExpr.new(@scalar_expression)
|
44
|
+
assert_equal '(a.ra)', e.to_s
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_xml
|
48
|
+
e1 = ClosedExpr.new(@scalar_expression)
|
49
|
+
e2 = ClosedExpr.from_xml(e1.to_xml)
|
50
|
+
assert_equal e1, e2
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class BinaryExprTest < ::Test::Unit::TestCase
|
55
|
+
def setup
|
56
|
+
@scalar_expression1 = ColumnReference.new('a', 'ra', 'right_ascension')
|
57
|
+
@scalar_expression2 = ColumnReference.new('a', 'dec', 'declination')
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_construction
|
61
|
+
assert_nothing_raised {
|
62
|
+
BinaryExpr.new(@scalar_expression1, BinaryOperator.new('*'), @scalar_expression2)
|
63
|
+
BinaryExpr.new(@scalar_expression1, '*', @scalar_expression2)
|
64
|
+
}
|
65
|
+
|
66
|
+
assert_raises ArgumentError do
|
67
|
+
BinaryExpr.new(@scalar_expression1, BinaryOperator.new('*'), nil)
|
68
|
+
end
|
69
|
+
assert_raises ArgumentError do
|
70
|
+
BinaryExpr.new(@scalar_expression1, nil, @scalar_expression2)
|
71
|
+
end
|
72
|
+
assert_raises ArgumentError do
|
73
|
+
BinaryExpr.new(nil, BinaryOperator.new('*'), @scalar_expression2)
|
74
|
+
end
|
75
|
+
|
76
|
+
assert_raises TypeError do
|
77
|
+
BinaryExpr.new(@scalar_expression1, BinaryOperator.new('*'), 'blah')
|
78
|
+
end
|
79
|
+
assert_raises TypeError do
|
80
|
+
BinaryExpr.new(@scalar_expression1, UnaryOperator.new('+'), @scalar_expression2)
|
81
|
+
end
|
82
|
+
assert_raises TypeError do
|
83
|
+
BinaryExpr.new('blah', BinaryOperator.new('*'), @scalar_expression2)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_accessors
|
88
|
+
e = BinaryExpr.new(@scalar_expression1, BinaryOperator.new('*'), @scalar_expression2)
|
89
|
+
|
90
|
+
assert_equal @scalar_expression1, e.arg1
|
91
|
+
assert_equal BinaryOperator.new('*'), e.oper
|
92
|
+
assert_equal @scalar_expression2, e.arg2
|
93
|
+
|
94
|
+
e.arg1 = ColumnReference.new('b', 'flux')
|
95
|
+
assert_equal ColumnReference.new('b', 'flux'), e.arg1
|
96
|
+
e.oper = BinaryOperator.new('+')
|
97
|
+
assert_equal BinaryOperator.new('+'), e.oper
|
98
|
+
e.arg2 = ColumnReference.new('b', 'flux_err')
|
99
|
+
assert_equal ColumnReference.new('b', 'flux_err'), e.arg2
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_relationships
|
103
|
+
e = BinaryExpr.new(@scalar_expression1, BinaryOperator.new('*'), @scalar_expression2)
|
104
|
+
assert_kind_of ScalarExpression, e
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_to_s
|
108
|
+
e = BinaryExpr.new(@scalar_expression1, BinaryOperator.new('*'), @scalar_expression2)
|
109
|
+
assert_equal "a.ra * a.dec", e.to_s
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_xml
|
113
|
+
e1 = BinaryExpr.new(@scalar_expression1, BinaryOperator.new('*'), @scalar_expression2)
|
114
|
+
e2 = BinaryExpr.from_xml(e1.to_xml)
|
115
|
+
assert_equal e1, e2
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
class UnaryExprTest < ::Test::Unit::TestCase
|
120
|
+
def setup
|
121
|
+
@scalar_expression = ColumnReference.new('a', 'ra', '/xpath')
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_construction
|
125
|
+
assert_nothing_raised {
|
126
|
+
UnaryExpr.new(UnaryOperator.new('-'), @scalar_expression)
|
127
|
+
UnaryExpr.new('-', @scalar_expression)
|
128
|
+
}
|
129
|
+
|
130
|
+
assert_raises ArgumentError do
|
131
|
+
UnaryExpr.new(nil, @scalar_expression)
|
132
|
+
end
|
133
|
+
assert_raises ArgumentError do
|
134
|
+
UnaryExpr.new('blah', nil)
|
135
|
+
end
|
136
|
+
assert_raises ArgumentError do
|
137
|
+
UnaryExpr.new(nil, nil)
|
138
|
+
end
|
139
|
+
|
140
|
+
assert_raises TypeError do
|
141
|
+
UnaryExpr.new(BinaryOperator.new('*'), @scalar_expression)
|
142
|
+
end
|
143
|
+
assert_raises TypeError do
|
144
|
+
UnaryExpr.new('-', 'blah')
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_accessors
|
149
|
+
e = UnaryExpr.new(UnaryOperator.new('-'), @scalar_expression)
|
150
|
+
|
151
|
+
assert_equal UnaryOperator.new('-'), e.oper
|
152
|
+
assert_equal @scalar_expression, e.arg
|
153
|
+
|
154
|
+
e.oper = UnaryOperator.new('+')
|
155
|
+
assert_equal UnaryOperator.new('+'), e.oper
|
156
|
+
e.arg = ColumnReference.new('a', 'dec')
|
157
|
+
assert_equal ColumnReference.new('a', 'dec'), e.arg
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_relationships
|
161
|
+
assert_kind_of ScalarExpression, UnaryExpr.new(UnaryOperator.new('-'), @scalar_expression)
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_to_s
|
165
|
+
e = UnaryExpr.new(UnaryOperator.new('-'), @scalar_expression)
|
166
|
+
assert_equal '-(a.ra)', e.to_s
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_xml
|
170
|
+
e1 = UnaryExpr.new(UnaryOperator.new('-'), @scalar_expression)
|
171
|
+
e2 = UnaryExpr.from_xml(e1.to_xml)
|
172
|
+
assert_equal e1, e2
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
class ColumnReferenceTest < ::Test::Unit::TestCase
|
177
|
+
def test_construction
|
178
|
+
assert_nothing_raised {
|
179
|
+
ColumnReference.new('Table1', '*', '/xpath')
|
180
|
+
ColumnReference.new('Table1', '*')
|
181
|
+
}
|
182
|
+
|
183
|
+
assert_raises ArgumentError do
|
184
|
+
ColumnReference.new('Table1')
|
185
|
+
end
|
186
|
+
assert_raises ArgumentError do
|
187
|
+
ColumnReference.new(nil)
|
188
|
+
end
|
189
|
+
assert_raises ArgumentError do
|
190
|
+
ColumnReference.new('Table1', nil)
|
191
|
+
end
|
192
|
+
assert_raises ArgumentError do
|
193
|
+
ColumnReference.new(nil, nil)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
def test_accessors
|
198
|
+
r = ColumnReference.new('Table1', '*', '/xpath')
|
199
|
+
|
200
|
+
assert_equal 'Table1', r.table
|
201
|
+
assert_equal '*', r.name
|
202
|
+
assert_equal '/xpath', r.xpath_name
|
203
|
+
|
204
|
+
r.table = 'Table2'
|
205
|
+
assert_equal 'Table2', r.table
|
206
|
+
r.name = 'column1'
|
207
|
+
assert_equal 'column1', r.name
|
208
|
+
r.xpath_name = '/my/path'
|
209
|
+
assert_equal '/my/path', r.xpath_name
|
210
|
+
end
|
211
|
+
|
212
|
+
def test_relationships
|
213
|
+
assert_kind_of ScalarExpression, ColumnReference.new('Table1', '*', '/xpath')
|
214
|
+
end
|
215
|
+
|
216
|
+
def test_to_s
|
217
|
+
r = ColumnReference.new('Table1', '*', '/xpath')
|
218
|
+
assert_equal 'Table1.*', r.to_s
|
219
|
+
end
|
220
|
+
|
221
|
+
def test_xml
|
222
|
+
r1 = ColumnReference.new('Table1', '*', '/xpath')
|
223
|
+
r2 = ColumnReference.from_xml(r1.to_xml)
|
224
|
+
assert_equal r1, r2
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
class RealLiteralTest < ::Test::Unit::TestCase
|
229
|
+
def test_construction
|
230
|
+
assert_nothing_raised {
|
231
|
+
RealLiteral.new(10.1)
|
232
|
+
}
|
233
|
+
|
234
|
+
assert_raises ArgumentError do
|
235
|
+
RealLiteral.new(nil)
|
236
|
+
end
|
237
|
+
assert_raises ArgumentError do
|
238
|
+
RealLiteral.new('blah')
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
def test_accessors
|
243
|
+
r = RealLiteral.new(10.1)
|
244
|
+
|
245
|
+
assert_equal 10.1, r.value
|
246
|
+
r.value = 1.2
|
247
|
+
assert_equal 1.2, r.value
|
248
|
+
end
|
249
|
+
|
250
|
+
def test_relationships
|
251
|
+
assert_kind_of NumberLiteral, RealLiteral.new(10.1)
|
252
|
+
end
|
253
|
+
|
254
|
+
def test_to_s
|
255
|
+
assert_equal "10.1", RealLiteral.new(10.1).to_s
|
256
|
+
end
|
257
|
+
|
258
|
+
def test_xml
|
259
|
+
r1 = RealLiteral.new(10.1)
|
260
|
+
r2 = RealLiteral.from_xml(r1.to_xml)
|
261
|
+
assert_equal r1, r2
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
class IntegerLiteralTest < ::Test::Unit::TestCase
|
266
|
+
def test_construction
|
267
|
+
assert_nothing_raised {
|
268
|
+
IntegerLiteral.new(10)
|
269
|
+
}
|
270
|
+
|
271
|
+
assert_raises ArgumentError do
|
272
|
+
IntegerLiteral.new(nil)
|
273
|
+
end
|
274
|
+
assert_raises ArgumentError do
|
275
|
+
IntegerLiteral.new('blah')
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
def test_accessors
|
280
|
+
r = IntegerLiteral.new(10)
|
281
|
+
|
282
|
+
assert_equal 10, r.value
|
283
|
+
r.value = 1
|
284
|
+
assert_equal 1, r.value
|
285
|
+
end
|
286
|
+
|
287
|
+
def test_relationships
|
288
|
+
assert_kind_of NumberLiteral, IntegerLiteral.new(10)
|
289
|
+
end
|
290
|
+
|
291
|
+
def test_to_s
|
292
|
+
assert_equal "10", IntegerLiteral.new(10.1).to_s
|
293
|
+
end
|
294
|
+
|
295
|
+
def test_xml
|
296
|
+
r1 = IntegerLiteral.new(10)
|
297
|
+
r2 = IntegerLiteral.from_xml(r1.to_xml)
|
298
|
+
assert_equal r1, r2
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
class StringLiteralTest < ::Test::Unit::TestCase
|
303
|
+
def test_construction
|
304
|
+
assert_nothing_raised {
|
305
|
+
StringLiteral.new('test')
|
306
|
+
}
|
307
|
+
|
308
|
+
assert_raises ArgumentError do
|
309
|
+
StringLiteral.new(nil)
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
def test_accessors
|
314
|
+
r = StringLiteral.new('test')
|
315
|
+
|
316
|
+
assert_equal 'test', r.value
|
317
|
+
r.value = 'test2'
|
318
|
+
assert_equal 'test2', r.value
|
319
|
+
end
|
320
|
+
|
321
|
+
def test_relationships
|
322
|
+
assert_kind_of Literal, StringLiteral.new('test')
|
323
|
+
end
|
324
|
+
|
325
|
+
def test_to_s
|
326
|
+
assert_equal "'test'", StringLiteral.new('test').to_s
|
327
|
+
end
|
328
|
+
|
329
|
+
def test_xml
|
330
|
+
r1 = StringLiteral.new('test')
|
331
|
+
r2 = StringLiteral.from_xml(r1.to_xml)
|
332
|
+
assert_equal r1, r2
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
class AtomTest < ::Test::Unit::TestCase
|
337
|
+
def test_construction
|
338
|
+
assert_nothing_raised {
|
339
|
+
Atom.new(RealLiteral.new(10.1), 'm')
|
340
|
+
Atom.new(RealLiteral.new(10.1))
|
341
|
+
Atom.new(IntegerLiteral.new(10))
|
342
|
+
Atom.new(StringLiteral.new('blah'))
|
343
|
+
}
|
344
|
+
|
345
|
+
assert_raises ArgumentError do
|
346
|
+
Atom.new
|
347
|
+
end
|
348
|
+
|
349
|
+
assert_raises TypeError do
|
350
|
+
Atom.new(ColumnReference.new('Table1', '*', '/xpath'))
|
351
|
+
end
|
352
|
+
end
|
353
|
+
|
354
|
+
def test_accessors
|
355
|
+
a = Atom.new(123.4, 's')
|
356
|
+
|
357
|
+
assert_equal RealLiteral.new(123.4), a.literal
|
358
|
+
a.literal = 51.2
|
359
|
+
assert_equal RealLiteral.new(51.2), a.literal
|
360
|
+
assert_equal 's', a.unit
|
361
|
+
a.unit = 'm'
|
362
|
+
assert_equal 'm', a.unit
|
363
|
+
end
|
364
|
+
|
365
|
+
def test_relationships
|
366
|
+
assert_kind_of ScalarExpression, Atom.new(123.4, 's')
|
367
|
+
end
|
368
|
+
|
369
|
+
def test_to_s
|
370
|
+
assert_equal '123.4', Atom.new(123.4, 's').to_s
|
371
|
+
end
|
372
|
+
|
373
|
+
def test_xml
|
374
|
+
a1 = Atom.new(123.4, 's')
|
375
|
+
a2 = Atom.from_xml(a1.to_xml)
|
376
|
+
assert_equal a1, a2
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
380
|
+
class SelectionOptionTest < ::Test::Unit::TestCase
|
381
|
+
def test_construction
|
382
|
+
assert_nothing_raised {
|
383
|
+
SelectionOption.new(AllOrDistinct.new('All'))
|
384
|
+
SelectionOption.new('DISTINCT')
|
385
|
+
}
|
386
|
+
|
387
|
+
assert_raises ArgumentError do
|
388
|
+
SelectionOption.new(nil)
|
389
|
+
end
|
390
|
+
|
391
|
+
assert_raises TypeError do
|
392
|
+
SelectionOption.new(Atom.new(123.4))
|
393
|
+
end
|
394
|
+
end
|
395
|
+
|
396
|
+
def test_accessors
|
397
|
+
o = SelectionOption.new('All')
|
398
|
+
|
399
|
+
assert_equal AllOrDistinct.new('All'), o.option
|
400
|
+
o.option = AllOrDistinct.new('DISTINCT')
|
401
|
+
assert_equal AllOrDistinct.new('DISTINCT'), o.option
|
402
|
+
end
|
403
|
+
|
404
|
+
def test_to_s
|
405
|
+
assert_equal 'DISTINCT', SelectionOption.new('DISTINCT').to_s
|
406
|
+
assert_equal 'All', SelectionOption.new('All').to_s
|
407
|
+
end
|
408
|
+
|
409
|
+
def test_xml
|
410
|
+
o1 = SelectionOption.new('DISTINCT')
|
411
|
+
o2 = SelectionOption.from_xml(o1.to_xml)
|
412
|
+
assert_equal o1, o2
|
413
|
+
end
|
414
|
+
end
|
415
|
+
|
416
|
+
class TrigonometricFunctionTest < ::Test::Unit::TestCase
|
417
|
+
def test_construction
|
418
|
+
assert_nothing_raised {
|
419
|
+
TrigonometricFunction.new('COS', ColumnReference.new('a', 'period'), SelectionOption.new('DISTINCT'))
|
420
|
+
TrigonometricFunction.new('COS', ColumnReference.new('a', 'period'))
|
421
|
+
}
|
422
|
+
|
423
|
+
assert_raises ArgumentError do
|
424
|
+
TrigonometricFunction.new('COS', nil)
|
425
|
+
end
|
426
|
+
assert_raises ArgumentError do
|
427
|
+
TrigonometricFunction.new(nil, ColumnReference.new('a', 'period'))
|
428
|
+
end
|
429
|
+
|
430
|
+
assert_raises TypeError do
|
431
|
+
TrigonometricFunction.new(SelectionOption.new('DISTINCT'), ColumnReference.new('a', 'period'))
|
432
|
+
end
|
433
|
+
assert_raises TypeError do
|
434
|
+
TrigonometricFunction.new('COS', SelectionOption.new('DISTINCT'))
|
435
|
+
end
|
436
|
+
end
|
437
|
+
|
438
|
+
def test_accessors
|
439
|
+
f = TrigonometricFunction.new('COS', ColumnReference.new('a', 'period'), SelectionOption.new('DISTINCT'))
|
440
|
+
|
441
|
+
assert_equal TrigonometricFunctionName.new('COS'), f.name
|
442
|
+
assert_equal ColumnReference.new('a', 'period'), f.arg
|
443
|
+
assert_equal SelectionOption.new('DISTINCT'), f.allow
|
444
|
+
f.name = TrigonometricFunctionName.new('TAN')
|
445
|
+
assert_equal TrigonometricFunctionName.new('TAN'), f.name
|
446
|
+
f.arg = Atom.new(101.2)
|
447
|
+
assert_equal Atom.new(101.2), f.arg
|
448
|
+
f.allow = SelectionOption.new('All')
|
449
|
+
assert_equal SelectionOption.new('All'), f.allow
|
450
|
+
end
|
451
|
+
|
452
|
+
def test_relationships
|
453
|
+
assert_kind_of Function, TrigonometricFunction.new('COS', ColumnReference.new('a', 'period'))
|
454
|
+
end
|
455
|
+
|
456
|
+
def test_to_s
|
457
|
+
f = TrigonometricFunction.new('COS', ColumnReference.new('a', 'period'), SelectionOption.new('All'))
|
458
|
+
assert_equal 'All COS(a.period)', f.to_s
|
459
|
+
|
460
|
+
f = TrigonometricFunction.new('TAN', Atom.new(90.2))
|
461
|
+
assert_equal 'TAN(90.2)', f.to_s
|
462
|
+
end
|
463
|
+
|
464
|
+
def test_xml
|
465
|
+
f1 = TrigonometricFunction.new('COS', ColumnReference.new('a', 'period'), SelectionOption.new('All'))
|
466
|
+
f2 = TrigonometricFunction.from_xml(f1.to_xml)
|
467
|
+
assert_equal f1, f2
|
468
|
+
end
|
469
|
+
end
|
470
|
+
|
471
|
+
class MathFunctionTest < ::Test::Unit::TestCase
|
472
|
+
def test_construction
|
473
|
+
assert_nothing_raised {
|
474
|
+
MathFunction.new('SQRT', ColumnReference.new('a', 'period'), SelectionOption.new('DISTINCT'))
|
475
|
+
MathFunction.new('LOG10', ColumnReference.new('a', 'period'))
|
476
|
+
}
|
477
|
+
|
478
|
+
assert_raises ArgumentError do
|
479
|
+
MathFunction.new('SQRT', nil)
|
480
|
+
end
|
481
|
+
assert_raises ArgumentError do
|
482
|
+
MathFunction.new(nil, ColumnReference.new('a', 'period'))
|
483
|
+
end
|
484
|
+
|
485
|
+
assert_raises TypeError do
|
486
|
+
MathFunction.new(SelectionOption.new('DISTINCT'), ColumnReference.new('a', 'period'))
|
487
|
+
end
|
488
|
+
assert_raises TypeError do
|
489
|
+
MathFunction.new('COS', SelectionOption.new('DISTINCT'))
|
490
|
+
end
|
491
|
+
end
|
492
|
+
|
493
|
+
def test_accessors
|
494
|
+
f = MathFunction.new('SQRT', ColumnReference.new('a', 'period'), SelectionOption.new('DISTINCT'))
|
495
|
+
|
496
|
+
assert_equal MathFunctionName.new('SQRT'), f.name
|
497
|
+
assert_equal ColumnReference.new('a', 'period'), f.arg
|
498
|
+
assert_equal SelectionOption.new('DISTINCT'), f.allow
|
499
|
+
f.name = MathFunctionName.new('EXP')
|
500
|
+
assert_equal MathFunctionName.new('EXP'), f.name
|
501
|
+
f.arg = Atom.new(101.2)
|
502
|
+
assert_equal Atom.new(101.2), f.arg
|
503
|
+
f.allow = SelectionOption.new('All')
|
504
|
+
assert_equal SelectionOption.new('All'), f.allow
|
505
|
+
end
|
506
|
+
|
507
|
+
def test_relationships
|
508
|
+
assert_kind_of Function, MathFunction.new('ABS', ColumnReference.new('a', 'period'))
|
509
|
+
end
|
510
|
+
|
511
|
+
def test_to_s
|
512
|
+
f = MathFunction.new('ABS', ColumnReference.new('a', 'period'), SelectionOption.new('All'))
|
513
|
+
assert_equal 'All ABS(a.period)', f.to_s
|
514
|
+
|
515
|
+
f = MathFunction.new('FLOOR', Atom.new(90.2))
|
516
|
+
assert_equal 'FLOOR(90.2)', f.to_s
|
517
|
+
end
|
518
|
+
|
519
|
+
def test_xml
|
520
|
+
f1 = MathFunction.new('ABS', ColumnReference.new('a', 'period'), SelectionOption.new('All'))
|
521
|
+
f2 = MathFunction.from_xml(f1.to_xml)
|
522
|
+
assert_equal f1, f2
|
523
|
+
end
|
524
|
+
end
|
525
|
+
|
526
|
+
class AggregateFunctionTest < ::Test::Unit::TestCase
|
527
|
+
def test_construction
|
528
|
+
assert_nothing_raised {
|
529
|
+
AggregateFunction.new('AVG', ColumnReference.new('a', 'period'), SelectionOption.new('DISTINCT'))
|
530
|
+
AggregateFunction.new('MIN', ColumnReference.new('a', 'period'))
|
531
|
+
}
|
532
|
+
|
533
|
+
assert_raises ArgumentError do
|
534
|
+
AggregateFunction.new('AVG', nil)
|
535
|
+
end
|
536
|
+
assert_raises ArgumentError do
|
537
|
+
AggregateFunction.new(nil, ColumnReference.new('a', 'period'))
|
538
|
+
end
|
539
|
+
|
540
|
+
assert_raises TypeError do
|
541
|
+
AggregateFunction.new(SelectionOption.new('DISTINCT'), ColumnReference.new('a', 'period'))
|
542
|
+
end
|
543
|
+
assert_raises TypeError do
|
544
|
+
AggregateFunction.new('COS', SelectionOption.new('DISTINCT'))
|
545
|
+
end
|
546
|
+
end
|
547
|
+
|
548
|
+
def test_accessors
|
549
|
+
f = AggregateFunction.new('SUM', ColumnReference.new('a', 'period'), SelectionOption.new('DISTINCT'))
|
550
|
+
|
551
|
+
assert_equal AggregateFunctionName.new('SUM'), f.name
|
552
|
+
assert_equal ColumnReference.new('a', 'period'), f.arg
|
553
|
+
assert_equal SelectionOption.new('DISTINCT'), f.allow
|
554
|
+
f.name = AggregateFunctionName.new('MAX')
|
555
|
+
assert_equal AggregateFunctionName.new('MAX'), f.name
|
556
|
+
f.arg = Atom.new(101.2)
|
557
|
+
assert_equal Atom.new(101.2), f.arg
|
558
|
+
f.allow = SelectionOption.new('All')
|
559
|
+
assert_equal SelectionOption.new('All'), f.allow
|
560
|
+
end
|
561
|
+
|
562
|
+
def test_relationships
|
563
|
+
assert_kind_of Function, AggregateFunction.new('MIN', ColumnReference.new('a', 'period'))
|
564
|
+
end
|
565
|
+
|
566
|
+
def test_to_s
|
567
|
+
f = AggregateFunction.new('AVG', ColumnReference.new('a', 'period'), SelectionOption.new('All'))
|
568
|
+
assert_equal 'All AVG(a.period)', f.to_s
|
569
|
+
|
570
|
+
f = AggregateFunction.new('COUNT', Atom.new(90.2))
|
571
|
+
assert_equal 'COUNT(90.2)', f.to_s
|
572
|
+
end
|
573
|
+
|
574
|
+
def test_xml
|
575
|
+
f1 = AggregateFunction.new('COUNT', ColumnReference.new('a', 'period'), SelectionOption.new('All'))
|
576
|
+
f2 = AggregateFunction.from_xml(f1.to_xml)
|
577
|
+
assert_equal f1, f2
|
578
|
+
end
|
579
|
+
end
|
580
|
+
|
581
|
+
class AliasSelectionItemTest < ::Test::Unit::TestCase
|
582
|
+
def test_construction
|
583
|
+
assert_nothing_raised {
|
584
|
+
AliasSelectionItem.new(ColumnReference.new('a', 'period'), 'frequency')
|
585
|
+
AliasSelectionItem.new(ColumnReference.new('a', 'period'))
|
586
|
+
}
|
587
|
+
|
588
|
+
assert_raises ArgumentError do
|
589
|
+
AliasSelectionItem.new
|
590
|
+
end
|
591
|
+
|
592
|
+
assert_raises TypeError do
|
593
|
+
AliasSelectionItem.new('blah')
|
594
|
+
end
|
595
|
+
end
|
596
|
+
|
597
|
+
def test_accessors
|
598
|
+
a = AliasSelectionItem.new(ColumnReference.new('a', 'period'), 'frequency')
|
599
|
+
|
600
|
+
assert_equal ColumnReference.new('a', 'period'), a.expression
|
601
|
+
assert_equal 'frequency', a.as
|
602
|
+
a.expression = ColumnReference.new('b', 'count')
|
603
|
+
assert_equal ColumnReference.new('b', 'count'), a.expression
|
604
|
+
a.as = 'sum'
|
605
|
+
assert_equal 'sum', a.as
|
606
|
+
end
|
607
|
+
|
608
|
+
def test_relationships
|
609
|
+
assert_kind_of SelectionItem, AliasSelectionItem.new(ColumnReference.new('a', 'period'), 'frequency')
|
610
|
+
end
|
611
|
+
|
612
|
+
def test_to_s
|
613
|
+
a = AliasSelectionItem.new(ColumnReference.new('a', 'period'), 'frequency')
|
614
|
+
assert_equal 'a.period AS frequency', a.to_s
|
615
|
+
end
|
616
|
+
|
617
|
+
def test_xml
|
618
|
+
a1 = AliasSelectionItem.new(ColumnReference.new('a', 'period'), 'frequency')
|
619
|
+
a2 = AliasSelectionItem.from_xml(a1.to_xml)
|
620
|
+
assert_equal a1, a2
|
621
|
+
end
|
622
|
+
end
|
623
|
+
|
624
|
+
class AllSelectionItemTest < ::Test::Unit::TestCase
|
625
|
+
def test_construction
|
626
|
+
assert_nothing_raised { AllSelectionItem.new }
|
627
|
+
end
|
628
|
+
|
629
|
+
def test_relationships
|
630
|
+
assert_kind_of SelectionItem, AllSelectionItem.new
|
631
|
+
end
|
632
|
+
|
633
|
+
def test_to_s
|
634
|
+
assert_equal '*', AllSelectionItem.new.to_s
|
635
|
+
end
|
636
|
+
|
637
|
+
def test_xml
|
638
|
+
a1 = AllSelectionItem.new
|
639
|
+
a2 = AllSelectionItem.from_xml(a1.to_xml)
|
640
|
+
assert_equal a1, a2
|
641
|
+
end
|
642
|
+
end
|
643
|
+
|
644
|
+
class ArchiveTableTest < ::Test::Unit::TestCase
|
645
|
+
def test_construction
|
646
|
+
assert_nothing_raised {
|
647
|
+
ArchiveTable.new('NOAO', 'photometry', 'NOAOPhot')
|
648
|
+
ArchiveTable.new('NOAO', 'photometry')
|
649
|
+
}
|
650
|
+
|
651
|
+
assert_raises ArgumentError do
|
652
|
+
ArchiveTable.new('NOAO')
|
653
|
+
end
|
654
|
+
assert_raises ArgumentError do
|
655
|
+
ArchiveTable.new(nil, 'photometry')
|
656
|
+
end
|
657
|
+
end
|
658
|
+
|
659
|
+
def test_accessors
|
660
|
+
t = ArchiveTable.new('NOAO', 'photometry', 'NOAOPhot')
|
661
|
+
|
662
|
+
assert_equal 'NOAO', t.archive
|
663
|
+
assert_equal 'photometry', t.name
|
664
|
+
assert_equal 'NOAOPhot', t.table_alias
|
665
|
+
t.archive = 'STSCI'
|
666
|
+
assert_equal 'STSCI', t.archive
|
667
|
+
t.name = 'spectra'
|
668
|
+
assert_equal 'spectra', t.name
|
669
|
+
t.table_alias = 'STSCISpec'
|
670
|
+
assert_equal 'STSCISpec', t.table_alias
|
671
|
+
end
|
672
|
+
|
673
|
+
def test_relationships
|
674
|
+
assert_kind_of FromTable, ArchiveTable.new('NOAO', 'photometry', 'NOAOPhot')
|
675
|
+
end
|
676
|
+
|
677
|
+
def test_to_s
|
678
|
+
t = ArchiveTable.new('NOAO', 'photometry', 'NOAOPhot')
|
679
|
+
assert_equal 'NOAO:photometry NOAOPhot', t.to_s
|
680
|
+
|
681
|
+
t = ArchiveTable.new('NOAO', 'photometry')
|
682
|
+
assert_equal 'NOAO:photometry', t.to_s
|
683
|
+
end
|
684
|
+
|
685
|
+
def test_xml
|
686
|
+
t1 = ArchiveTable.new('NOAO', 'photometry', 'NOAOPhot')
|
687
|
+
t2 = ArchiveTable.from_xml(t1.to_xml)
|
688
|
+
assert_equal t1, t2
|
689
|
+
end
|
690
|
+
end
|
691
|
+
|
692
|
+
class TableTest < ::Test::Unit::TestCase
|
693
|
+
def test_construction
|
694
|
+
assert_nothing_raised {
|
695
|
+
Table.new('photometry', 'phot', '/phot')
|
696
|
+
Table.new('photometry', 'phot')
|
697
|
+
Table.new('photometry')
|
698
|
+
}
|
699
|
+
|
700
|
+
assert_raises ArgumentError do
|
701
|
+
Table.new
|
702
|
+
end
|
703
|
+
end
|
704
|
+
|
705
|
+
def test_accessors
|
706
|
+
t = Table.new('photometry', 'phot', '/phot')
|
707
|
+
|
708
|
+
assert_equal 'photometry', t.name
|
709
|
+
assert_equal 'phot', t.table_alias
|
710
|
+
assert_equal '/phot', t.xpath_name
|
711
|
+
t.name = 'spectroscopy'
|
712
|
+
assert_equal 'spectroscopy', t.name
|
713
|
+
t.table_alias = 'spec'
|
714
|
+
assert_equal 'spec', t.table_alias
|
715
|
+
t.xpath_name = '/spec'
|
716
|
+
assert_equal '/spec', t.xpath_name
|
717
|
+
end
|
718
|
+
|
719
|
+
def test_relationships
|
720
|
+
assert_kind_of FromTable, Table.new('photometry', 'phot', '/phot')
|
721
|
+
end
|
722
|
+
|
723
|
+
def test_to_s
|
724
|
+
t = Table.new('photometry', 'phot', '/phot')
|
725
|
+
assert_equal 'photometry phot', t.to_s
|
726
|
+
|
727
|
+
t = Table.new('photometry')
|
728
|
+
assert_equal 'photometry', t.to_s
|
729
|
+
end
|
730
|
+
|
731
|
+
def test_xml
|
732
|
+
t1 = Table.new('photometry', 'phot', '/phot')
|
733
|
+
t2 = Table.from_xml(t1.to_xml)
|
734
|
+
assert_equal t1, t2
|
735
|
+
end
|
736
|
+
end
|
737
|
+
|
738
|
+
class IncludeTableTest < ::Test::Unit::TestCase
|
739
|
+
def test_construction
|
740
|
+
assert_nothing_raised { IncludeTable.new('photometry') }
|
741
|
+
assert_raises ArgumentError do
|
742
|
+
IncludeTable.new
|
743
|
+
end
|
744
|
+
end
|
745
|
+
|
746
|
+
def test_accessors
|
747
|
+
t = IncludeTable.new('photometry')
|
748
|
+
|
749
|
+
assert_equal 'photometry', t.name
|
750
|
+
t.name = 'spectroscopy'
|
751
|
+
assert_equal 'spectroscopy', t.name
|
752
|
+
end
|
753
|
+
|
754
|
+
def test_relationships
|
755
|
+
assert_kind_of XMatchTableAlias, IncludeTable.new('photometry')
|
756
|
+
end
|
757
|
+
|
758
|
+
def test_to_s
|
759
|
+
t = IncludeTable.new('photometry')
|
760
|
+
assert_equal 'photometry', t.to_s
|
761
|
+
end
|
762
|
+
|
763
|
+
def test_xml
|
764
|
+
t1 = IncludeTable.new('photometry')
|
765
|
+
t2 = IncludeTable.from_xml(t1.to_xml)
|
766
|
+
assert_equal t1, t2
|
767
|
+
end
|
768
|
+
end
|
769
|
+
|
770
|
+
class DropTableTest < ::Test::Unit::TestCase
|
771
|
+
def test_construction
|
772
|
+
assert_nothing_raised { DropTable.new('photometry') }
|
773
|
+
assert_raises ArgumentError do
|
774
|
+
DropTable.new
|
775
|
+
end
|
776
|
+
end
|
777
|
+
|
778
|
+
def test_accessors
|
779
|
+
t = DropTable.new('photometry')
|
780
|
+
|
781
|
+
assert_equal 'photometry', t.name
|
782
|
+
t.name = 'spectroscopy'
|
783
|
+
assert_equal 'spectroscopy', t.name
|
784
|
+
end
|
785
|
+
|
786
|
+
def test_relationships
|
787
|
+
assert_kind_of XMatchTableAlias, DropTable.new('photometry')
|
788
|
+
end
|
789
|
+
|
790
|
+
def test_to_s
|
791
|
+
t = DropTable.new('photometry')
|
792
|
+
assert_equal '!photometry', t.to_s
|
793
|
+
end
|
794
|
+
|
795
|
+
def test_xml
|
796
|
+
t1 = DropTable.new('photometry')
|
797
|
+
t2 = DropTable.from_xml(t1.to_xml)
|
798
|
+
assert_equal t1, t2
|
799
|
+
end
|
800
|
+
end
|
801
|
+
|
802
|
+
class IntersectionSearchTest < ::Test::Unit::TestCase
|
803
|
+
def setup
|
804
|
+
@condition1 = XMatch.new(
|
805
|
+
[IncludeTable.new('phot'), IncludeTable.new('spec'), DropTable.new('aux')],
|
806
|
+
'<',
|
807
|
+
3.5
|
808
|
+
)
|
809
|
+
|
810
|
+
@condition2 = XMatch.new(
|
811
|
+
[IncludeTable.new('tbl1'), IncludeTable.new('tbl2'),],
|
812
|
+
'=',
|
813
|
+
1.1
|
814
|
+
)
|
815
|
+
end
|
816
|
+
|
817
|
+
def test_construction
|
818
|
+
assert_nothing_raised {
|
819
|
+
IntersectionSearch.new(@condition1, @condition2)
|
820
|
+
}
|
821
|
+
|
822
|
+
assert_raises ArgumentError do
|
823
|
+
IntersectionSearch.new(@condition1, nil)
|
824
|
+
end
|
825
|
+
assert_raises ArgumentError do
|
826
|
+
IntersectionSearch.new(nil, @condition2)
|
827
|
+
end
|
828
|
+
|
829
|
+
assert_raises TypeError do
|
830
|
+
IntersectionSearch.new(@condition1, 'blah')
|
831
|
+
end
|
832
|
+
assert_raises TypeError do
|
833
|
+
IntersectionSearch.new('blah', @condition2)
|
834
|
+
end
|
835
|
+
end
|
836
|
+
|
837
|
+
def test_accessors
|
838
|
+
s = IntersectionSearch.new(@condition1, @condition2)
|
839
|
+
|
840
|
+
assert_equal @condition1, s.condition1
|
841
|
+
assert_equal @condition2, s.condition2
|
842
|
+
end
|
843
|
+
|
844
|
+
def test_relationships
|
845
|
+
assert_kind_of Search, IntersectionSearch.new(@condition1, @condition2)
|
846
|
+
end
|
847
|
+
|
848
|
+
def test_to_s
|
849
|
+
s = IntersectionSearch.new(@condition1, @condition2)
|
850
|
+
assert_equal 'XMATCH(phot, spec, !aux) < 3.5 AND XMATCH(tbl1, tbl2) = 1.1', s.to_s
|
851
|
+
end
|
852
|
+
|
853
|
+
def test_xml
|
854
|
+
s1 = IntersectionSearch.new(@condition1, @condition2)
|
855
|
+
s2 = IntersectionSearch.from_xml(s1.to_xml)
|
856
|
+
assert_equal s1, s2
|
857
|
+
end
|
858
|
+
end
|
859
|
+
|
860
|
+
class UnionSearchTest < ::Test::Unit::TestCase
|
861
|
+
def setup
|
862
|
+
@condition1 = XMatch.new(
|
863
|
+
[IncludeTable.new('phot'), IncludeTable.new('spec'), DropTable.new('aux')],
|
864
|
+
'<',
|
865
|
+
3.5
|
866
|
+
)
|
867
|
+
|
868
|
+
@condition2 = XMatch.new(
|
869
|
+
[IncludeTable.new('tbl1'), IncludeTable.new('tbl2'),],
|
870
|
+
'=',
|
871
|
+
1.1
|
872
|
+
)
|
873
|
+
end
|
874
|
+
|
875
|
+
def test_construction
|
876
|
+
assert_nothing_raised {
|
877
|
+
UnionSearch.new(@condition1, @condition2)
|
878
|
+
}
|
879
|
+
|
880
|
+
assert_raises ArgumentError do
|
881
|
+
UnionSearch.new(@condition1, nil)
|
882
|
+
end
|
883
|
+
assert_raises ArgumentError do
|
884
|
+
UnionSearch.new(nil, @condition2)
|
885
|
+
end
|
886
|
+
|
887
|
+
assert_raises TypeError do
|
888
|
+
UnionSearch.new(@condition1, 'blah')
|
889
|
+
end
|
890
|
+
assert_raises TypeError do
|
891
|
+
UnionSearch.new('blah', @condition2)
|
892
|
+
end
|
893
|
+
end
|
894
|
+
|
895
|
+
def test_accessors
|
896
|
+
s = UnionSearch.new(@condition1, @condition2)
|
897
|
+
|
898
|
+
assert_equal @condition1, s.condition1
|
899
|
+
assert_equal @condition2, s.condition2
|
900
|
+
end
|
901
|
+
|
902
|
+
def test_relationships
|
903
|
+
assert_kind_of Search, UnionSearch.new(@condition1, @condition2)
|
904
|
+
end
|
905
|
+
|
906
|
+
def test_to_s
|
907
|
+
s = UnionSearch.new(@condition1, @condition2)
|
908
|
+
assert_equal 'XMATCH(phot, spec, !aux) < 3.5 OR XMATCH(tbl1, tbl2) = 1.1', s.to_s
|
909
|
+
end
|
910
|
+
|
911
|
+
def test_xml
|
912
|
+
s1 = UnionSearch.new(@condition1, @condition2)
|
913
|
+
s2 = UnionSearch.from_xml(s1.to_xml)
|
914
|
+
assert_equal s1, s2
|
915
|
+
end
|
916
|
+
end
|
917
|
+
|
918
|
+
class XMatchTest < ::Test::Unit::TestCase
|
919
|
+
def setup
|
920
|
+
@tables = [IncludeTable.new('phot'), IncludeTable.new('spec'), DropTable.new('aux')]
|
921
|
+
@nature = '<'
|
922
|
+
@sigma = 3.5
|
923
|
+
end
|
924
|
+
|
925
|
+
def test_construction
|
926
|
+
assert_nothing_raised {
|
927
|
+
XMatch.new(@tables, @nature, @sigma)
|
928
|
+
}
|
929
|
+
|
930
|
+
assert_raises ArgumentError do
|
931
|
+
XMatch.new(nil, @nature, @sigma)
|
932
|
+
end
|
933
|
+
assert_raises ArgumentError do
|
934
|
+
XMatch.new(@tables, nil, @sigma)
|
935
|
+
end
|
936
|
+
assert_raises ArgumentError do
|
937
|
+
XMatch.new(@tables, @nature, nil)
|
938
|
+
end
|
939
|
+
|
940
|
+
assert_raises TypeError do
|
941
|
+
XMatch.new('blah', @nature, @sigma)
|
942
|
+
end
|
943
|
+
assert_raises TypeError do
|
944
|
+
XMatch.new(@tables, BinaryOperator.new('+'), @sigma)
|
945
|
+
end
|
946
|
+
assert_raises TypeError do
|
947
|
+
XMatch.new(@tables, @nature, StringLiteral.new('blah'))
|
948
|
+
end
|
949
|
+
end
|
950
|
+
|
951
|
+
def test_accessors
|
952
|
+
m = XMatch.new(@tables, @nature, @sigma)
|
953
|
+
|
954
|
+
assert_equal @tables, m.tables
|
955
|
+
assert_equal Comparison.new(@nature), m.nature
|
956
|
+
assert_equal RealLiteral.new(3.5), m.sigma
|
957
|
+
m.tables = [IncludeTable.new('phot'), DropTable.new('spec')]
|
958
|
+
assert_equal [IncludeTable.new('phot'), DropTable.new('spec')], m.tables
|
959
|
+
m.nature = '<>'
|
960
|
+
assert_equal Comparison.new('<>'), m.nature
|
961
|
+
m.sigma = 4
|
962
|
+
assert_equal IntegerLiteral.new(4), m.sigma
|
963
|
+
end
|
964
|
+
|
965
|
+
def test_relationships
|
966
|
+
assert_kind_of Search, XMatch.new(@tables, @nature, @sigma)
|
967
|
+
end
|
968
|
+
|
969
|
+
def test_to_s
|
970
|
+
m = XMatch.new(@tables, @nature, @sigma)
|
971
|
+
assert_equal 'XMATCH(phot, spec, !aux) < 3.5', m.to_s
|
972
|
+
end
|
973
|
+
|
974
|
+
def test_xml
|
975
|
+
m1 = XMatch.new(@tables, @nature, @sigma)
|
976
|
+
m2 = XMatch.from_xml(m1.to_xml)
|
977
|
+
assert_equal m1, m2
|
978
|
+
end
|
979
|
+
end
|
980
|
+
|
981
|
+
class LikePredTest < ::Test::Unit::TestCase
|
982
|
+
def setup
|
983
|
+
@arg = ColumnReference.new('a', 'name')
|
984
|
+
@pattern = Atom.new(StringLiteral.new('m%'))
|
985
|
+
end
|
986
|
+
|
987
|
+
def test_construction
|
988
|
+
assert_nothing_raised {
|
989
|
+
LikePred.new(@arg, @pattern)
|
990
|
+
}
|
991
|
+
|
992
|
+
assert_raises ArgumentError do
|
993
|
+
LikePred.new(@arg, nil)
|
994
|
+
end
|
995
|
+
assert_raises ArgumentError do
|
996
|
+
LikePred.new(nil, @pattern)
|
997
|
+
end
|
998
|
+
|
999
|
+
assert_raises TypeError do
|
1000
|
+
LikePred.new('blah', @pattern)
|
1001
|
+
end
|
1002
|
+
assert_raises TypeError do
|
1003
|
+
LikePred.new(@arg, @arg)
|
1004
|
+
end
|
1005
|
+
end
|
1006
|
+
|
1007
|
+
def test_accessors
|
1008
|
+
p = LikePred.new(@arg, @pattern)
|
1009
|
+
|
1010
|
+
assert_equal @arg, p.arg
|
1011
|
+
assert_equal @pattern, p.pattern
|
1012
|
+
p.arg = Atom.new(10.1)
|
1013
|
+
assert_equal Atom.new(10.1), p.arg
|
1014
|
+
p.pattern = Atom.new(10.1)
|
1015
|
+
assert_equal Atom.new(10.1), p.pattern
|
1016
|
+
end
|
1017
|
+
|
1018
|
+
def test_relationships
|
1019
|
+
assert_kind_of Search, LikePred.new(@arg, @pattern)
|
1020
|
+
end
|
1021
|
+
|
1022
|
+
def test_to_s
|
1023
|
+
p = LikePred.new(@arg, @pattern)
|
1024
|
+
assert_equal "a.name LIKE 'm%'", p.to_s
|
1025
|
+
end
|
1026
|
+
|
1027
|
+
def test_xml
|
1028
|
+
p1 = LikePred.new(@arg, @pattern)
|
1029
|
+
p2 = LikePred.from_xml(p1.to_xml)
|
1030
|
+
assert_equal p1, p2
|
1031
|
+
end
|
1032
|
+
end
|
1033
|
+
|
1034
|
+
class NotLikePredTest < ::Test::Unit::TestCase
|
1035
|
+
def setup
|
1036
|
+
@arg = ColumnReference.new('a', 'name')
|
1037
|
+
@pattern = Atom.new(StringLiteral.new('m%'))
|
1038
|
+
end
|
1039
|
+
|
1040
|
+
def test_construction
|
1041
|
+
assert_nothing_raised {
|
1042
|
+
NotLikePred.new(@arg, @pattern)
|
1043
|
+
}
|
1044
|
+
|
1045
|
+
assert_raises ArgumentError do
|
1046
|
+
NotLikePred.new(@arg, nil)
|
1047
|
+
end
|
1048
|
+
assert_raises ArgumentError do
|
1049
|
+
NotLikePred.new(nil, @pattern)
|
1050
|
+
end
|
1051
|
+
|
1052
|
+
assert_raises TypeError do
|
1053
|
+
NotLikePred.new('blah', @pattern)
|
1054
|
+
end
|
1055
|
+
assert_raises TypeError do
|
1056
|
+
NotLikePred.new(@arg, @arg)
|
1057
|
+
end
|
1058
|
+
end
|
1059
|
+
|
1060
|
+
def test_accessors
|
1061
|
+
p = NotLikePred.new(@arg, @pattern)
|
1062
|
+
|
1063
|
+
assert_equal @arg, p.arg
|
1064
|
+
assert_equal @pattern, p.pattern
|
1065
|
+
p.arg = Atom.new(10.1)
|
1066
|
+
assert_equal Atom.new(10.1), p.arg
|
1067
|
+
p.pattern = Atom.new(10.1)
|
1068
|
+
assert_equal Atom.new(10.1), p.pattern
|
1069
|
+
end
|
1070
|
+
|
1071
|
+
def test_relationships
|
1072
|
+
assert_kind_of LikePred, NotLikePred.new(@arg, @pattern)
|
1073
|
+
end
|
1074
|
+
|
1075
|
+
def test_to_s
|
1076
|
+
p = NotLikePred.new(@arg, @pattern)
|
1077
|
+
assert_equal "a.name NOT LIKE 'm%'", p.to_s
|
1078
|
+
end
|
1079
|
+
|
1080
|
+
def test_xml
|
1081
|
+
p1 = NotLikePred.new(@arg, @pattern)
|
1082
|
+
p2 = NotLikePred.from_xml(p1.to_xml)
|
1083
|
+
assert_equal p1, p2
|
1084
|
+
end
|
1085
|
+
end
|
1086
|
+
|
1087
|
+
class ClosedSearchTest < ::Test::Unit::TestCase
|
1088
|
+
def setup
|
1089
|
+
@condition = UnionSearch.new(
|
1090
|
+
XMatch.new(
|
1091
|
+
[IncludeTable.new('phot'), IncludeTable.new('spec'), DropTable.new('aux')],
|
1092
|
+
'<',
|
1093
|
+
3.5
|
1094
|
+
),
|
1095
|
+
XMatch.new(
|
1096
|
+
[IncludeTable.new('tbl1'), IncludeTable.new('tbl2'),],
|
1097
|
+
'=',
|
1098
|
+
1.1
|
1099
|
+
)
|
1100
|
+
)
|
1101
|
+
end
|
1102
|
+
|
1103
|
+
def test_construction
|
1104
|
+
assert_nothing_raised {
|
1105
|
+
ClosedSearch.new(@condition)
|
1106
|
+
}
|
1107
|
+
|
1108
|
+
assert_raises ArgumentError do
|
1109
|
+
ClosedSearch.new(nil)
|
1110
|
+
end
|
1111
|
+
|
1112
|
+
assert_raises TypeError do
|
1113
|
+
ClosedSearch.new('blah')
|
1114
|
+
end
|
1115
|
+
end
|
1116
|
+
|
1117
|
+
def test_accessors
|
1118
|
+
s = ClosedSearch.new(@condition)
|
1119
|
+
|
1120
|
+
assert_equal @condition, s.condition
|
1121
|
+
end
|
1122
|
+
|
1123
|
+
def test_relationships
|
1124
|
+
assert_kind_of Search, ClosedSearch.new(@condition)
|
1125
|
+
end
|
1126
|
+
|
1127
|
+
def test_to_s
|
1128
|
+
e = ClosedSearch.new(@condition)
|
1129
|
+
assert_equal "(XMATCH(phot, spec, !aux) < 3.5 OR XMATCH(tbl1, tbl2) = 1.1)", e.to_s
|
1130
|
+
end
|
1131
|
+
|
1132
|
+
def test_xml
|
1133
|
+
e1 = ClosedSearch.new(@condition)
|
1134
|
+
e2 = ClosedSearch.from_xml(e1.to_xml)
|
1135
|
+
assert_equal e1, e2
|
1136
|
+
end
|
1137
|
+
end
|
1138
|
+
|
1139
|
+
class ComparisonPredTest < ::Test::Unit::TestCase
|
1140
|
+
def setup
|
1141
|
+
@arg1 = ColumnReference.new('phot', 'mag')
|
1142
|
+
@comparison = Comparison.new('>')
|
1143
|
+
@arg2 = Atom.new(15)
|
1144
|
+
end
|
1145
|
+
|
1146
|
+
def test_construction
|
1147
|
+
assert_nothing_raised {
|
1148
|
+
ComparisonPred.new(@arg1, @comparison, @arg2)
|
1149
|
+
}
|
1150
|
+
|
1151
|
+
assert_raises ArgumentError do
|
1152
|
+
ComparisonPred.new(@arg1, @comparison, nil)
|
1153
|
+
end
|
1154
|
+
assert_raises ArgumentError do
|
1155
|
+
ComparisonPred.new(@arg1, nil, @arg2)
|
1156
|
+
end
|
1157
|
+
assert_raises ArgumentError do
|
1158
|
+
ComparisonPred.new(nil, @comparison, @arg2)
|
1159
|
+
end
|
1160
|
+
|
1161
|
+
assert_raises TypeError do
|
1162
|
+
ComparisonPred.new(@arg1, @comparison, 'blah')
|
1163
|
+
end
|
1164
|
+
assert_raises TypeError do
|
1165
|
+
ComparisonPred.new(@arg1, Atom.new('='), @arg2)
|
1166
|
+
end
|
1167
|
+
assert_raises TypeError do
|
1168
|
+
ComparisonPred.new('blah', @comparison, @arg2)
|
1169
|
+
end
|
1170
|
+
end
|
1171
|
+
|
1172
|
+
def test_accessors
|
1173
|
+
p = ComparisonPred.new(@arg1, @comparison, @arg2)
|
1174
|
+
|
1175
|
+
assert_equal @arg1, p.arg1
|
1176
|
+
assert_equal @comparison, p.comparison
|
1177
|
+
assert_equal @arg2, p.arg2
|
1178
|
+
end
|
1179
|
+
|
1180
|
+
def test_relationships
|
1181
|
+
assert_kind_of Search, ComparisonPred.new(@arg1, @comparison, @arg2)
|
1182
|
+
end
|
1183
|
+
|
1184
|
+
def test_to_s
|
1185
|
+
p = ComparisonPred.new(@arg1, @comparison, @arg2)
|
1186
|
+
assert_equal 'phot.mag > 15', p.to_s
|
1187
|
+
end
|
1188
|
+
|
1189
|
+
def test_xml
|
1190
|
+
p1 = ComparisonPred.new(@arg1, @comparison, @arg2)
|
1191
|
+
p2 = ComparisonPred.from_xml(p1.to_xml)
|
1192
|
+
assert_equal p1, p2
|
1193
|
+
end
|
1194
|
+
end
|
1195
|
+
|
1196
|
+
class BetweenPredTest < ::Test::Unit::TestCase
|
1197
|
+
def setup
|
1198
|
+
@arg1 = ColumnReference.new('phot', 'mag')
|
1199
|
+
@arg2 = Atom.new(15)
|
1200
|
+
@arg3 = Atom.new(20)
|
1201
|
+
end
|
1202
|
+
|
1203
|
+
def test_construction
|
1204
|
+
assert_nothing_raised {
|
1205
|
+
BetweenPred.new(@arg1, @arg2, @arg3)
|
1206
|
+
}
|
1207
|
+
|
1208
|
+
assert_raises ArgumentError do
|
1209
|
+
BetweenPred.new(@arg1, @arg2, nil)
|
1210
|
+
end
|
1211
|
+
assert_raises ArgumentError do
|
1212
|
+
BetweenPred.new(@arg1, nil, @arg3)
|
1213
|
+
end
|
1214
|
+
assert_raises ArgumentError do
|
1215
|
+
BetweenPred.new(nil, @arg2, @arg3)
|
1216
|
+
end
|
1217
|
+
|
1218
|
+
assert_raises TypeError do
|
1219
|
+
BetweenPred.new(@arg1, @arg2, 'blah')
|
1220
|
+
end
|
1221
|
+
assert_raises TypeError do
|
1222
|
+
BetweenPred.new(@arg1, 'blah', @arg3)
|
1223
|
+
end
|
1224
|
+
assert_raises TypeError do
|
1225
|
+
BetweenPred.new('blah', @arg2, @arg3)
|
1226
|
+
end
|
1227
|
+
end
|
1228
|
+
|
1229
|
+
def test_accessors
|
1230
|
+
p = BetweenPred.new(@arg1, @arg2, @arg3)
|
1231
|
+
|
1232
|
+
assert_equal @arg1, p.arg1
|
1233
|
+
assert_equal @arg2, p.arg2
|
1234
|
+
assert_equal @arg3, p.arg3
|
1235
|
+
end
|
1236
|
+
|
1237
|
+
def test_relationships
|
1238
|
+
assert_kind_of Search, BetweenPred.new(@arg1, @arg2, @arg3)
|
1239
|
+
end
|
1240
|
+
|
1241
|
+
def test_to_s
|
1242
|
+
p = BetweenPred.new(@arg1, @arg2, @arg3)
|
1243
|
+
assert_equal 'phot.mag BETWEEN 15 AND 20', p.to_s
|
1244
|
+
end
|
1245
|
+
|
1246
|
+
def test_xml
|
1247
|
+
p1 = BetweenPred.new(@arg1, @arg2, @arg3)
|
1248
|
+
p2 = BetweenPred.from_xml(p1.to_xml)
|
1249
|
+
assert_equal p1, p2
|
1250
|
+
end
|
1251
|
+
end
|
1252
|
+
|
1253
|
+
class NotBetweenPredTest < ::Test::Unit::TestCase
|
1254
|
+
def setup
|
1255
|
+
@arg1 = ColumnReference.new('phot', 'mag')
|
1256
|
+
@arg2 = Atom.new(15)
|
1257
|
+
@arg3 = Atom.new(20)
|
1258
|
+
end
|
1259
|
+
|
1260
|
+
def test_construction
|
1261
|
+
assert_nothing_raised {
|
1262
|
+
NotBetweenPred.new(@arg1, @arg2, @arg3)
|
1263
|
+
}
|
1264
|
+
|
1265
|
+
assert_raises ArgumentError do
|
1266
|
+
NotBetweenPred.new(@arg1, @arg2, nil)
|
1267
|
+
end
|
1268
|
+
assert_raises ArgumentError do
|
1269
|
+
NotBetweenPred.new(@arg1, nil, @arg3)
|
1270
|
+
end
|
1271
|
+
assert_raises ArgumentError do
|
1272
|
+
NotBetweenPred.new(nil, @arg2, @arg3)
|
1273
|
+
end
|
1274
|
+
|
1275
|
+
assert_raises TypeError do
|
1276
|
+
NotBetweenPred.new(@arg1, @arg2, 'blah')
|
1277
|
+
end
|
1278
|
+
assert_raises TypeError do
|
1279
|
+
NotBetweenPred.new(@arg1, 'blah', @arg3)
|
1280
|
+
end
|
1281
|
+
assert_raises TypeError do
|
1282
|
+
NotBetweenPred.new('blah', @arg2, @arg3)
|
1283
|
+
end
|
1284
|
+
end
|
1285
|
+
|
1286
|
+
def test_accessors
|
1287
|
+
p = NotBetweenPred.new(@arg1, @arg2, @arg3)
|
1288
|
+
|
1289
|
+
assert_equal @arg1, p.arg1
|
1290
|
+
assert_equal @arg2, p.arg2
|
1291
|
+
assert_equal @arg3, p.arg3
|
1292
|
+
end
|
1293
|
+
|
1294
|
+
def test_relationships
|
1295
|
+
assert_kind_of Search, NotBetweenPred.new(@arg1, @arg2, @arg3)
|
1296
|
+
end
|
1297
|
+
|
1298
|
+
def test_to_s
|
1299
|
+
p = NotBetweenPred.new(@arg1, @arg2, @arg3)
|
1300
|
+
assert_equal 'phot.mag NOT BETWEEN 15 AND 20', p.to_s
|
1301
|
+
end
|
1302
|
+
|
1303
|
+
def test_xml
|
1304
|
+
p1 = NotBetweenPred.new(@arg1, @arg2, @arg3)
|
1305
|
+
p2 = NotBetweenPred.from_xml(p1.to_xml)
|
1306
|
+
assert_equal p1, p2
|
1307
|
+
end
|
1308
|
+
end
|
1309
|
+
|
1310
|
+
class InverseSearchTest < ::Test::Unit::TestCase
|
1311
|
+
def setup
|
1312
|
+
@condition = ComparisonPred.new(
|
1313
|
+
ColumnReference.new('phot', 'mag'),
|
1314
|
+
Comparison.new('>'),
|
1315
|
+
Atom.new(15)
|
1316
|
+
)
|
1317
|
+
end
|
1318
|
+
|
1319
|
+
def test_construction
|
1320
|
+
assert_nothing_raised {
|
1321
|
+
InverseSearch.new(@condition)
|
1322
|
+
}
|
1323
|
+
|
1324
|
+
assert_raises ArgumentError do
|
1325
|
+
InverseSearch.new(nil)
|
1326
|
+
end
|
1327
|
+
|
1328
|
+
assert_raises TypeError do
|
1329
|
+
InverseSearch.new('blah')
|
1330
|
+
end
|
1331
|
+
end
|
1332
|
+
|
1333
|
+
def test_accessors
|
1334
|
+
s = InverseSearch.new(@condition)
|
1335
|
+
assert_equal @condition, s.condition
|
1336
|
+
end
|
1337
|
+
|
1338
|
+
def test_relationships
|
1339
|
+
s = InverseSearch.new(@condition)
|
1340
|
+
assert_kind_of Search, s
|
1341
|
+
end
|
1342
|
+
|
1343
|
+
def test_to_s
|
1344
|
+
s = InverseSearch.new(@condition)
|
1345
|
+
assert_equal 'NOT phot.mag > 15', s.to_s
|
1346
|
+
end
|
1347
|
+
|
1348
|
+
def test_xml
|
1349
|
+
s1 = InverseSearch.new(@condition)
|
1350
|
+
s2 = InverseSearch.from_xml(s1.to_xml)
|
1351
|
+
assert_equal s1, s2
|
1352
|
+
end
|
1353
|
+
end
|
1354
|
+
|
1355
|
+
class RegionSearchTest < ::Test::Unit::TestCase
|
1356
|
+
def setup
|
1357
|
+
@region = Circle.new(:center => [12.5, 23.0], :radius => 5.0, :unit => 'deg', :coord_system_id => 'J2000')
|
1358
|
+
end
|
1359
|
+
|
1360
|
+
def test_construction
|
1361
|
+
assert_nothing_raised {
|
1362
|
+
RegionSearch.new(@region)
|
1363
|
+
}
|
1364
|
+
|
1365
|
+
assert_raises ArgumentError do
|
1366
|
+
RegionSearch.new(nil)
|
1367
|
+
end
|
1368
|
+
|
1369
|
+
assert_raises TypeError do
|
1370
|
+
RegionSearch.new('blah')
|
1371
|
+
end
|
1372
|
+
end
|
1373
|
+
|
1374
|
+
def test_accessors
|
1375
|
+
s = RegionSearch.new(@region)
|
1376
|
+
assert_equal @region, s.region
|
1377
|
+
end
|
1378
|
+
|
1379
|
+
def test_relationships
|
1380
|
+
assert_kind_of Search, RegionSearch.new(@region)
|
1381
|
+
end
|
1382
|
+
|
1383
|
+
def test_to_s
|
1384
|
+
s = RegionSearch.new(@region)
|
1385
|
+
assert_equal 'REGION(CIRCLE J2000 12.5 23.0 5.0)', s.to_s
|
1386
|
+
end
|
1387
|
+
|
1388
|
+
def test_xml
|
1389
|
+
s1 = RegionSearch.new(@region)
|
1390
|
+
s2 = RegionSearch.from_xml(s1.to_xml)
|
1391
|
+
|
1392
|
+
assert_equal s1, s2
|
1393
|
+
end
|
1394
|
+
end
|
1395
|
+
|
1396
|
+
class HavingTest < ::Test::Unit::TestCase
|
1397
|
+
def setup
|
1398
|
+
@condition = RegionSearch.new(
|
1399
|
+
Circle.new(:center => [12.5, 23.0], :radius => 5.0, :unit => 'deg', :coord_system_id => 'J2000')
|
1400
|
+
)
|
1401
|
+
end
|
1402
|
+
|
1403
|
+
def test_construction
|
1404
|
+
assert_nothing_raised {
|
1405
|
+
Having.new(@condition)
|
1406
|
+
}
|
1407
|
+
|
1408
|
+
assert_raises ArgumentError do
|
1409
|
+
Having.new(nil)
|
1410
|
+
end
|
1411
|
+
|
1412
|
+
assert_raises TypeError do
|
1413
|
+
Having.new('blah')
|
1414
|
+
end
|
1415
|
+
end
|
1416
|
+
|
1417
|
+
def test_accessors
|
1418
|
+
h = Having.new(@condition)
|
1419
|
+
assert_equal @condition, h.condition
|
1420
|
+
end
|
1421
|
+
|
1422
|
+
def test_to_s
|
1423
|
+
h = Having.new(@condition)
|
1424
|
+
assert_equal 'HAVING REGION(CIRCLE J2000 12.5 23.0 5.0)', h.to_s
|
1425
|
+
end
|
1426
|
+
|
1427
|
+
def test_xml
|
1428
|
+
h1 = Having.new(@condition)
|
1429
|
+
h2 = Having.from_xml(h1.to_xml)
|
1430
|
+
assert_equal h1, h2
|
1431
|
+
end
|
1432
|
+
end
|
1433
|
+
|
1434
|
+
class GroupByTest < ::Test::Unit::TestCase
|
1435
|
+
def setup
|
1436
|
+
@columns = [
|
1437
|
+
ColumnReference.new('Phot', 'vmag'),
|
1438
|
+
ColumnReference.new('Phot', 'imag')
|
1439
|
+
]
|
1440
|
+
end
|
1441
|
+
|
1442
|
+
def test_construction
|
1443
|
+
assert_nothing_raised {
|
1444
|
+
GroupBy.new(@columns)
|
1445
|
+
}
|
1446
|
+
|
1447
|
+
assert_raises ArgumentError do
|
1448
|
+
GroupBy.new(nil)
|
1449
|
+
end
|
1450
|
+
|
1451
|
+
assert_raises RuntimeError do
|
1452
|
+
GroupBy.new([])
|
1453
|
+
end
|
1454
|
+
|
1455
|
+
assert_raises TypeError do
|
1456
|
+
GroupBy.new('blah')
|
1457
|
+
end
|
1458
|
+
end
|
1459
|
+
|
1460
|
+
def test_accessors
|
1461
|
+
g = GroupBy.new(@columns)
|
1462
|
+
assert_equal @columns, g.columns
|
1463
|
+
end
|
1464
|
+
|
1465
|
+
def test_to_s
|
1466
|
+
g = GroupBy.new(@columns)
|
1467
|
+
assert_equal 'GROUP BY Phot.vmag, Phot.imag', g.to_s
|
1468
|
+
end
|
1469
|
+
|
1470
|
+
def test_xml
|
1471
|
+
g1 = GroupBy.new(@columns)
|
1472
|
+
g2 = GroupBy.from_xml(g1.to_xml)
|
1473
|
+
assert_equal g1, g2
|
1474
|
+
end
|
1475
|
+
end
|
1476
|
+
|
1477
|
+
class WhereTest < ::Test::Unit::TestCase
|
1478
|
+
def setup
|
1479
|
+
@condition = ComparisonPred.new(
|
1480
|
+
ColumnReference.new('phot', 'mag'),
|
1481
|
+
Comparison.new('>'),
|
1482
|
+
Atom.new(15)
|
1483
|
+
)
|
1484
|
+
end
|
1485
|
+
|
1486
|
+
def test_construction
|
1487
|
+
assert_nothing_raised {
|
1488
|
+
Where.new(@condition)
|
1489
|
+
}
|
1490
|
+
|
1491
|
+
assert_raises ArgumentError do
|
1492
|
+
Where.new(nil)
|
1493
|
+
end
|
1494
|
+
|
1495
|
+
assert_raises TypeError do
|
1496
|
+
Where.new('blah')
|
1497
|
+
end
|
1498
|
+
end
|
1499
|
+
|
1500
|
+
def test_accessors
|
1501
|
+
w = Where.new(@condition)
|
1502
|
+
assert_equal @condition, w.condition
|
1503
|
+
end
|
1504
|
+
|
1505
|
+
def test_to_s
|
1506
|
+
w = Where.new(@condition)
|
1507
|
+
assert_equal 'WHERE phot.mag > 15', w.to_s
|
1508
|
+
end
|
1509
|
+
|
1510
|
+
def test_xml
|
1511
|
+
w1 = Where.new(@condition)
|
1512
|
+
w2 = Where.from_xml(w1.to_xml)
|
1513
|
+
assert_equal w1, w2
|
1514
|
+
end
|
1515
|
+
end
|
1516
|
+
|
1517
|
+
class FromTest < ::Test::Unit::TestCase
|
1518
|
+
def setup
|
1519
|
+
@tables = [
|
1520
|
+
Table.new('phot', 'p'),
|
1521
|
+
Table.new('spec', 's')
|
1522
|
+
]
|
1523
|
+
end
|
1524
|
+
|
1525
|
+
def test_construction
|
1526
|
+
assert_nothing_raised {
|
1527
|
+
From.new(@tables)
|
1528
|
+
}
|
1529
|
+
|
1530
|
+
assert_raises ArgumentError do
|
1531
|
+
From.new(nil)
|
1532
|
+
end
|
1533
|
+
|
1534
|
+
assert_raises RuntimeError do
|
1535
|
+
From.new([])
|
1536
|
+
end
|
1537
|
+
|
1538
|
+
assert_raises TypeError do
|
1539
|
+
From.new('blah')
|
1540
|
+
end
|
1541
|
+
end
|
1542
|
+
|
1543
|
+
def test_accessors
|
1544
|
+
f = From.new(@tables)
|
1545
|
+
assert_equal @tables, f.tables
|
1546
|
+
end
|
1547
|
+
|
1548
|
+
def test_to_s
|
1549
|
+
f = From.new(@tables)
|
1550
|
+
assert_equal 'FROM phot p, spec s', f.to_s
|
1551
|
+
end
|
1552
|
+
|
1553
|
+
def test_xml
|
1554
|
+
f1 = From.new(@tables)
|
1555
|
+
f2 = From.from_xml(f1.to_xml)
|
1556
|
+
assert_equal f1, f2
|
1557
|
+
end
|
1558
|
+
end
|
1559
|
+
|
1560
|
+
class SelectionListTest < ::Test::Unit::TestCase
|
1561
|
+
def setup
|
1562
|
+
@items = [
|
1563
|
+
ColumnReference.new('images', 'xdim'),
|
1564
|
+
TrigonometricFunction.new('SIN', ColumnReference.new('images', 'period'))
|
1565
|
+
]
|
1566
|
+
end
|
1567
|
+
|
1568
|
+
def test_construction
|
1569
|
+
assert_nothing_raised {
|
1570
|
+
SelectionList.new(@items)
|
1571
|
+
}
|
1572
|
+
|
1573
|
+
assert_raises ArgumentError do
|
1574
|
+
SelectionList.new(nil)
|
1575
|
+
end
|
1576
|
+
|
1577
|
+
assert_raises RuntimeError do
|
1578
|
+
SelectionList.new([])
|
1579
|
+
end
|
1580
|
+
|
1581
|
+
assert_raises TypeError do
|
1582
|
+
SelectionList.new('blah')
|
1583
|
+
end
|
1584
|
+
end
|
1585
|
+
|
1586
|
+
def test_accessors
|
1587
|
+
l = SelectionList.new(@items)
|
1588
|
+
assert_equal @items, l.items
|
1589
|
+
end
|
1590
|
+
|
1591
|
+
def test_to_s
|
1592
|
+
l = SelectionList.new(@items)
|
1593
|
+
assert_equal 'images.xdim, SIN(images.period)', l.to_s
|
1594
|
+
end
|
1595
|
+
|
1596
|
+
def test_xml
|
1597
|
+
l1 = SelectionList.new(@items)
|
1598
|
+
l2 = SelectionList.from_xml(l1.to_xml)
|
1599
|
+
assert_equal l1, l2
|
1600
|
+
end
|
1601
|
+
end
|
1602
|
+
|
1603
|
+
class SelectionLimitTest < ::Test::Unit::TestCase
|
1604
|
+
def test_construction
|
1605
|
+
assert_nothing_raised {
|
1606
|
+
SelectionLimit.new(10)
|
1607
|
+
}
|
1608
|
+
|
1609
|
+
assert_raises ArgumentError do
|
1610
|
+
SelectionLimit.new(nil)
|
1611
|
+
end
|
1612
|
+
assert_raises ArgumentError do
|
1613
|
+
SelectionLimit.new('blah')
|
1614
|
+
end
|
1615
|
+
end
|
1616
|
+
|
1617
|
+
def test_accessors
|
1618
|
+
l = SelectionLimit.new(10)
|
1619
|
+
|
1620
|
+
assert_equal 10, l.top
|
1621
|
+
l.top = 5
|
1622
|
+
assert_equal 5, l.top
|
1623
|
+
end
|
1624
|
+
|
1625
|
+
def test_to_s
|
1626
|
+
assert_equal 'TOP 10', SelectionLimit.new(10).to_s
|
1627
|
+
end
|
1628
|
+
|
1629
|
+
def test_xml
|
1630
|
+
l1 = SelectionLimit.new(10)
|
1631
|
+
l2 = SelectionLimit.from_xml(l1.to_xml)
|
1632
|
+
assert_equal l1, l2
|
1633
|
+
end
|
1634
|
+
end
|
1635
|
+
|
1636
|
+
class IntoTest < ::Test::Unit::TestCase
|
1637
|
+
def test_construction
|
1638
|
+
assert_nothing_raised {
|
1639
|
+
Into.new('phot')
|
1640
|
+
}
|
1641
|
+
|
1642
|
+
assert_raises ArgumentError do
|
1643
|
+
Into.new(nil)
|
1644
|
+
end
|
1645
|
+
end
|
1646
|
+
|
1647
|
+
def test_accessors
|
1648
|
+
i = Into.new('phot')
|
1649
|
+
|
1650
|
+
assert_equal 'phot', i.table_name
|
1651
|
+
i.table_name = 'spec'
|
1652
|
+
assert_equal 'spec', i.table_name
|
1653
|
+
end
|
1654
|
+
|
1655
|
+
def test_to_s
|
1656
|
+
assert_equal 'INTO phot', Into.new('phot').to_s
|
1657
|
+
end
|
1658
|
+
|
1659
|
+
def test_xml
|
1660
|
+
i1 = Into.new('phot')
|
1661
|
+
i2 = Into.from_xml(i1.to_xml)
|
1662
|
+
assert_equal i1, i2
|
1663
|
+
end
|
1664
|
+
end
|
1665
|
+
|
1666
|
+
class OrderOptionTest < ::Test::Unit::TestCase
|
1667
|
+
def test_construction
|
1668
|
+
assert_nothing_raised {
|
1669
|
+
OrderOption.new('ASC')
|
1670
|
+
OrderOption.new(OrderDirection.new('DESC'))
|
1671
|
+
}
|
1672
|
+
|
1673
|
+
assert_raises ArgumentError do
|
1674
|
+
OrderOption.new(nil)
|
1675
|
+
end
|
1676
|
+
|
1677
|
+
assert_raises TypeError do
|
1678
|
+
OrderOption.new(Into.new('phot'))
|
1679
|
+
end
|
1680
|
+
end
|
1681
|
+
|
1682
|
+
def test_accessors
|
1683
|
+
o = OrderOption.new('DESC')
|
1684
|
+
|
1685
|
+
assert_equal OrderDirection.new('DESC'), o.direction
|
1686
|
+
o.direction = 'ASC'
|
1687
|
+
assert_equal OrderDirection.new('ASC'), o.direction
|
1688
|
+
end
|
1689
|
+
|
1690
|
+
def test_to_s
|
1691
|
+
assert_equal 'ASC', OrderOption.new('ASC').to_s
|
1692
|
+
end
|
1693
|
+
|
1694
|
+
def test_xml
|
1695
|
+
o1 = OrderOption.new('DESC')
|
1696
|
+
o2 = OrderOption.from_xml(o1.to_xml)
|
1697
|
+
assert_equal o1, o2
|
1698
|
+
end
|
1699
|
+
end
|
1700
|
+
|
1701
|
+
class OrderTest < ::Test::Unit::TestCase
|
1702
|
+
def setup
|
1703
|
+
@expression = ColumnReference.new('phot', 'mag')
|
1704
|
+
@order = OrderOption.new('DESC')
|
1705
|
+
end
|
1706
|
+
|
1707
|
+
def test_construction
|
1708
|
+
assert_nothing_raised {
|
1709
|
+
Order.new(@expression, @order)
|
1710
|
+
Order.new(@expression, nil)
|
1711
|
+
Order.new(@expression)
|
1712
|
+
}
|
1713
|
+
|
1714
|
+
assert_raises ArgumentError do
|
1715
|
+
Order.new(nil, @order)
|
1716
|
+
end
|
1717
|
+
|
1718
|
+
assert_raises TypeError do
|
1719
|
+
Order.new('blah', @order)
|
1720
|
+
end
|
1721
|
+
assert_raises TypeError do
|
1722
|
+
Order.new(@expression, @expression)
|
1723
|
+
end
|
1724
|
+
end
|
1725
|
+
|
1726
|
+
def test_accessors
|
1727
|
+
o = Order.new(@expression, @order)
|
1728
|
+
|
1729
|
+
assert_equal @expression, o.expression
|
1730
|
+
assert_equal @order, o.order
|
1731
|
+
end
|
1732
|
+
|
1733
|
+
def test_to_s
|
1734
|
+
assert_equal 'phot.mag DESC', Order.new(@expression, @order).to_s
|
1735
|
+
assert_equal 'phot.mag', Order.new(@expression).to_s
|
1736
|
+
end
|
1737
|
+
|
1738
|
+
def test_xml
|
1739
|
+
o1 = Order.new(@expression, @order)
|
1740
|
+
o2 = Order.from_xml(o1.to_xml)
|
1741
|
+
assert_equal o1, o2
|
1742
|
+
end
|
1743
|
+
end
|
1744
|
+
|
1745
|
+
class OrderExpressionTest < ::Test::Unit::TestCase
|
1746
|
+
def setup
|
1747
|
+
@items = [
|
1748
|
+
Order.new(ColumnReference.new('phot', 'mag'), OrderOption.new('DESC')),
|
1749
|
+
Order.new(ColumnReference.new('spec', 'flux'), OrderOption.new('ASC'))
|
1750
|
+
]
|
1751
|
+
end
|
1752
|
+
|
1753
|
+
def test_construction
|
1754
|
+
assert_nothing_raised {
|
1755
|
+
OrderExpression.new(@items)
|
1756
|
+
}
|
1757
|
+
|
1758
|
+
assert_raises ArgumentError do
|
1759
|
+
OrderExpression.new(nil)
|
1760
|
+
end
|
1761
|
+
|
1762
|
+
assert_raises RuntimeError do
|
1763
|
+
OrderExpression.new([])
|
1764
|
+
end
|
1765
|
+
|
1766
|
+
assert_raises TypeError do
|
1767
|
+
OrderExpression.new('blah')
|
1768
|
+
end
|
1769
|
+
end
|
1770
|
+
|
1771
|
+
def test_accessors
|
1772
|
+
e = OrderExpression.new(@items)
|
1773
|
+
assert_equal @items, e.items
|
1774
|
+
end
|
1775
|
+
|
1776
|
+
def test_to_s
|
1777
|
+
e = OrderExpression.new(@items)
|
1778
|
+
assert_equal 'ORDER BY phot.mag DESC, spec.flux ASC', e.to_s
|
1779
|
+
end
|
1780
|
+
|
1781
|
+
def test_xml
|
1782
|
+
e1 = OrderExpression.new(@items)
|
1783
|
+
e2 = OrderExpression.from_xml(e1.to_xml)
|
1784
|
+
assert_equal e1, e2
|
1785
|
+
end
|
1786
|
+
end
|
1787
|
+
|
1788
|
+
class ConstantListSetTest < ::Test::Unit::TestCase
|
1789
|
+
def setup
|
1790
|
+
@items = [
|
1791
|
+
RealLiteral.new(10.2),
|
1792
|
+
RealLiteral.new(5.4),
|
1793
|
+
RealLiteral.new(7.2)
|
1794
|
+
]
|
1795
|
+
end
|
1796
|
+
|
1797
|
+
def test_construction
|
1798
|
+
assert_nothing_raised {
|
1799
|
+
ConstantListSet.new(@items)
|
1800
|
+
}
|
1801
|
+
|
1802
|
+
assert_raises ArgumentError do
|
1803
|
+
ConstantListSet.new(nil)
|
1804
|
+
end
|
1805
|
+
|
1806
|
+
assert_raises RuntimeError do
|
1807
|
+
ConstantListSet.new([])
|
1808
|
+
end
|
1809
|
+
|
1810
|
+
assert_raises TypeError do
|
1811
|
+
ConstantListSet.new('blah')
|
1812
|
+
end
|
1813
|
+
end
|
1814
|
+
|
1815
|
+
def test_accessors
|
1816
|
+
s = ConstantListSet.new(@items)
|
1817
|
+
assert_equal @items, s.items
|
1818
|
+
end
|
1819
|
+
|
1820
|
+
def test_relationships
|
1821
|
+
assert_kind_of InclusionSet, ConstantListSet.new(@items)
|
1822
|
+
end
|
1823
|
+
|
1824
|
+
def test_to_s
|
1825
|
+
assert_equal '(10.2, 5.4, 7.2)', ConstantListSet.new(@items).to_s
|
1826
|
+
end
|
1827
|
+
|
1828
|
+
def test_xml
|
1829
|
+
s1 = ConstantListSet.new(@items)
|
1830
|
+
s2 = ConstantListSet.from_xml(s1.to_xml)
|
1831
|
+
assert_equal s1, s2
|
1832
|
+
end
|
1833
|
+
end
|
1834
|
+
|
1835
|
+
class InclusiveSearchTest < ::Test::Unit::TestCase
|
1836
|
+
def setup
|
1837
|
+
@expression = ColumnReference.new('phot', 'flag')
|
1838
|
+
@set = ConstantListSet.new([IntegerLiteral.new(1), IntegerLiteral.new(2), IntegerLiteral.new(3)])
|
1839
|
+
end
|
1840
|
+
|
1841
|
+
def test_construction
|
1842
|
+
assert_nothing_raised {
|
1843
|
+
InclusiveSearch.new(@expression, @set)
|
1844
|
+
}
|
1845
|
+
|
1846
|
+
assert_raises ArgumentError do
|
1847
|
+
InclusiveSearch.new(@expression, nil)
|
1848
|
+
end
|
1849
|
+
assert_raises ArgumentError do
|
1850
|
+
InclusiveSearch.new(nil, @set)
|
1851
|
+
end
|
1852
|
+
|
1853
|
+
assert_raises TypeError do
|
1854
|
+
InclusiveSearch.new(@expression, 'blah')
|
1855
|
+
end
|
1856
|
+
assert_raises TypeError do
|
1857
|
+
InclusiveSearch.new('blah', @set)
|
1858
|
+
end
|
1859
|
+
end
|
1860
|
+
|
1861
|
+
def test_accessors
|
1862
|
+
s = InclusiveSearch.new(@expression, @set)
|
1863
|
+
|
1864
|
+
assert_equal @expression, s.expression
|
1865
|
+
assert_equal @set, s.set
|
1866
|
+
end
|
1867
|
+
|
1868
|
+
def test_relationships
|
1869
|
+
assert_kind_of Search, InclusiveSearch.new(@expression, @set)
|
1870
|
+
end
|
1871
|
+
|
1872
|
+
def test_to_s
|
1873
|
+
s = InclusiveSearch.new(@expression, @set)
|
1874
|
+
assert_equal 'phot.flag IN (1, 2, 3)', s.to_s
|
1875
|
+
end
|
1876
|
+
|
1877
|
+
def test_xml
|
1878
|
+
s1 = InclusiveSearch.new(@expression, @set)
|
1879
|
+
s2 = InclusiveSearch.from_xml(s1.to_xml)
|
1880
|
+
assert_equal s1, s2
|
1881
|
+
end
|
1882
|
+
end
|
1883
|
+
|
1884
|
+
class ExclusiveSearchTest < ::Test::Unit::TestCase
|
1885
|
+
def setup
|
1886
|
+
@expression = ColumnReference.new('phot', 'flag')
|
1887
|
+
@set = ConstantListSet.new([IntegerLiteral.new(1), IntegerLiteral.new(2), IntegerLiteral.new(3)])
|
1888
|
+
end
|
1889
|
+
|
1890
|
+
def test_construction
|
1891
|
+
assert_nothing_raised {
|
1892
|
+
ExclusiveSearch.new(@expression, @set)
|
1893
|
+
}
|
1894
|
+
|
1895
|
+
assert_raises ArgumentError do
|
1896
|
+
ExclusiveSearch.new(@expression, nil)
|
1897
|
+
end
|
1898
|
+
assert_raises ArgumentError do
|
1899
|
+
ExclusiveSearch.new(nil, @set)
|
1900
|
+
end
|
1901
|
+
|
1902
|
+
assert_raises TypeError do
|
1903
|
+
ExclusiveSearch.new(@expression, 'blah')
|
1904
|
+
end
|
1905
|
+
assert_raises TypeError do
|
1906
|
+
ExclusiveSearch.new('blah', @set)
|
1907
|
+
end
|
1908
|
+
end
|
1909
|
+
|
1910
|
+
def test_accessors
|
1911
|
+
s = ExclusiveSearch.new(@expression, @set)
|
1912
|
+
|
1913
|
+
assert_equal @expression, s.expression
|
1914
|
+
assert_equal @set, s.set
|
1915
|
+
end
|
1916
|
+
|
1917
|
+
def test_relationships
|
1918
|
+
assert_kind_of Search, ExclusiveSearch.new(@expression, @set)
|
1919
|
+
end
|
1920
|
+
|
1921
|
+
def test_to_s
|
1922
|
+
s = ExclusiveSearch.new(@expression, @set)
|
1923
|
+
assert_equal 'phot.flag NOT IN (1, 2, 3)', s.to_s
|
1924
|
+
end
|
1925
|
+
|
1926
|
+
def test_xml
|
1927
|
+
s1 = ExclusiveSearch.new(@expression, @set)
|
1928
|
+
s2 = ExclusiveSearch.from_xml(s1.to_xml)
|
1929
|
+
assert_equal s1, s2
|
1930
|
+
end
|
1931
|
+
end
|
1932
|
+
|
1933
|
+
class SelectTest < ::Test::Unit::TestCase
|
1934
|
+
def setup
|
1935
|
+
@allow = SelectionOption.new('DISTINCT')
|
1936
|
+
@restrict = SelectionLimit.new(10)
|
1937
|
+
@selection_list = SelectionList.new([
|
1938
|
+
ColumnReference.new('phot', 'xdim'),
|
1939
|
+
TrigonometricFunction.new('SIN', ColumnReference.new('phot', 'period'))
|
1940
|
+
])
|
1941
|
+
@into = Into.new('phot')
|
1942
|
+
@from = From.new([Table.new('phot', 'p'), Table.new('spec', 's')])
|
1943
|
+
@where = Where.new(
|
1944
|
+
ComparisonPred.new(
|
1945
|
+
ColumnReference.new('phot', 'mag'),
|
1946
|
+
Comparison.new('>'),
|
1947
|
+
Atom.new(15)
|
1948
|
+
)
|
1949
|
+
)
|
1950
|
+
@group_by = GroupBy.new([
|
1951
|
+
ColumnReference.new('phot', 'vmag'),
|
1952
|
+
ColumnReference.new('phot', 'imag')
|
1953
|
+
])
|
1954
|
+
@having = Having.new(
|
1955
|
+
RegionSearch.new(
|
1956
|
+
Circle.new(:center => [12.5, 23.0], :radius => 5.0, :unit => 'deg', :coord_system_id => 'J2000')
|
1957
|
+
)
|
1958
|
+
)
|
1959
|
+
@order_by = OrderExpression.new([
|
1960
|
+
Order.new(ColumnReference.new('phot', 'mag'), OrderOption.new('DESC')),
|
1961
|
+
Order.new(ColumnReference.new('spec', 'flux'), OrderOption.new('ASC'))
|
1962
|
+
])
|
1963
|
+
@start_comment = 'The Start'
|
1964
|
+
@end_comment = 'The End'
|
1965
|
+
|
1966
|
+
@options = {
|
1967
|
+
:allow => @allow,
|
1968
|
+
:restrict => @restrict,
|
1969
|
+
:into => @into,
|
1970
|
+
:from => @from,
|
1971
|
+
:where => @where,
|
1972
|
+
:group_by => @group_by,
|
1973
|
+
:having => @having,
|
1974
|
+
:order_by => @order_by,
|
1975
|
+
:start_comment => @start_comment,
|
1976
|
+
:end_comment => @end_comment
|
1977
|
+
}
|
1978
|
+
end
|
1979
|
+
|
1980
|
+
def test_construction
|
1981
|
+
assert_nothing_raised {
|
1982
|
+
Select.new(@selection_list)
|
1983
|
+
Select.new(@selection_list, @options)
|
1984
|
+
}
|
1985
|
+
|
1986
|
+
assert_raises ArgumentError do
|
1987
|
+
Select.new(nil)
|
1988
|
+
end
|
1989
|
+
|
1990
|
+
@options.each do |key, value|
|
1991
|
+
next if key == 'start_comment' or key == 'end_comment'
|
1992
|
+
@options[key] = 'blah'
|
1993
|
+
assert_raises TypeError do
|
1994
|
+
Select.new(@selection_list, @options)
|
1995
|
+
end
|
1996
|
+
end
|
1997
|
+
end
|
1998
|
+
|
1999
|
+
def test_accessors
|
2000
|
+
s = Select.new(@selection_list, @options)
|
2001
|
+
|
2002
|
+
assert_equal @selection_list, s.selection_list
|
2003
|
+
@options.each do |key, value|
|
2004
|
+
assert_equal value, s.send(key)
|
2005
|
+
end
|
2006
|
+
end
|
2007
|
+
|
2008
|
+
def test_to_s
|
2009
|
+
s = Select.new(@selection_list, @options)
|
2010
|
+
assert_equal(
|
2011
|
+
'SELECT DISTINCT TOP 10 phot.xdim, SIN(phot.period) ' +
|
2012
|
+
'INTO phot ' +
|
2013
|
+
'FROM phot p, spec s ' +
|
2014
|
+
'WHERE phot.mag > 15 ' +
|
2015
|
+
'GROUP BY phot.vmag, phot.imag ' +
|
2016
|
+
'HAVING REGION(CIRCLE J2000 12.5 23.0 5.0) ' +
|
2017
|
+
'ORDER BY phot.mag DESC, spec.flux ASC',
|
2018
|
+
s.to_s
|
2019
|
+
)
|
2020
|
+
|
2021
|
+
s = Select.new(@selection_list)
|
2022
|
+
assert_equal 'SELECT phot.xdim, SIN(phot.period)', s.to_s
|
2023
|
+
|
2024
|
+
s = Select.new(@selection_list, :allow => @allow)
|
2025
|
+
assert_equal 'SELECT DISTINCT phot.xdim, SIN(phot.period)', s.to_s
|
2026
|
+
|
2027
|
+
s = Select.new(@selection_list, :restrict => @restrict)
|
2028
|
+
assert_equal 'SELECT TOP 10 phot.xdim, SIN(phot.period)', s.to_s
|
2029
|
+
|
2030
|
+
s = Select.new(@selection_list, :into => @into)
|
2031
|
+
assert_equal 'SELECT phot.xdim, SIN(phot.period) INTO phot', s.to_s
|
2032
|
+
|
2033
|
+
s = Select.new(@selection_list, :from => @from)
|
2034
|
+
assert_equal 'SELECT phot.xdim, SIN(phot.period) FROM phot p, spec s', s.to_s
|
2035
|
+
|
2036
|
+
s = Select.new(@selection_list, :where => @where)
|
2037
|
+
assert_equal 'SELECT phot.xdim, SIN(phot.period) WHERE phot.mag > 15', s.to_s
|
2038
|
+
|
2039
|
+
s = Select.new(@selection_list, :group_by => @group_by)
|
2040
|
+
assert_equal 'SELECT phot.xdim, SIN(phot.period) GROUP BY phot.vmag, phot.imag', s.to_s
|
2041
|
+
|
2042
|
+
s = Select.new(@selection_list, :having => @having)
|
2043
|
+
assert_equal 'SELECT phot.xdim, SIN(phot.period) HAVING REGION(CIRCLE J2000 12.5 23.0 5.0)', s.to_s
|
2044
|
+
|
2045
|
+
s = Select.new(@selection_list, :order_by => @order_by)
|
2046
|
+
assert_equal 'SELECT phot.xdim, SIN(phot.period) ORDER BY phot.mag DESC, spec.flux ASC', s.to_s
|
2047
|
+
end
|
2048
|
+
|
2049
|
+
def test_xml
|
2050
|
+
s1 = Select.new(@selection_list, @options)
|
2051
|
+
s2 = Select.from_xml(s1.to_xml)
|
2052
|
+
assert_equal s1, s2
|
2053
|
+
end
|
2054
|
+
end
|
2055
|
+
|
2056
|
+
class UserDefinedFunctionTest < ::Test::Unit::TestCase
|
2057
|
+
def setup
|
2058
|
+
@name = 'MyErrorFunc'
|
2059
|
+
@params = [
|
2060
|
+
ColumnReference.new('phot', 'mag'),
|
2061
|
+
ColumnReference.new('phot', 'error')
|
2062
|
+
]
|
2063
|
+
end
|
2064
|
+
|
2065
|
+
def test_construction
|
2066
|
+
assert_nothing_raised {
|
2067
|
+
UserDefinedFunction.new(@name, @params)
|
2068
|
+
UserDefinedFunction.new(@name)
|
2069
|
+
}
|
2070
|
+
|
2071
|
+
assert_raises ArgumentError do
|
2072
|
+
UserDefinedFunction.new(nil)
|
2073
|
+
end
|
2074
|
+
|
2075
|
+
assert_raises TypeError do
|
2076
|
+
UserDefinedFunction.new(@name, 'blah')
|
2077
|
+
end
|
2078
|
+
end
|
2079
|
+
|
2080
|
+
def test_accessors
|
2081
|
+
f = UserDefinedFunction.new(@name, @params)
|
2082
|
+
assert_equal @name, f.name
|
2083
|
+
assert_equal @params, f.params
|
2084
|
+
end
|
2085
|
+
|
2086
|
+
def test_relationships
|
2087
|
+
assert_kind_of ScalarExpression, UserDefinedFunction.new(@name, @params)
|
2088
|
+
end
|
2089
|
+
|
2090
|
+
def test_to_s
|
2091
|
+
f = UserDefinedFunction.new(@name, @params)
|
2092
|
+
assert_equal 'MyErrorFunc(phot.mag, phot.error)', f.to_s
|
2093
|
+
|
2094
|
+
f = UserDefinedFunction.new(@name)
|
2095
|
+
assert_equal 'MyErrorFunc()', f.to_s
|
2096
|
+
end
|
2097
|
+
|
2098
|
+
def test_xml
|
2099
|
+
f1 = UserDefinedFunction.new(@name, @params)
|
2100
|
+
f2 = UserDefinedFunction.from_xml(f1.to_xml)
|
2101
|
+
assert_equal f1, f2
|
2102
|
+
end
|
2103
|
+
end
|
2104
|
+
|
2105
|
+
class JoinTableTest < ::Test::Unit::TestCase
|
2106
|
+
def setup
|
2107
|
+
@qualifier = JointTableQualifier.new('LEFT_OUTER')
|
2108
|
+
@tables = [
|
2109
|
+
Table.new('table1', 't1'),
|
2110
|
+
Table.new('table2', 't2')
|
2111
|
+
]
|
2112
|
+
@condition = ComparisonPred.new(
|
2113
|
+
ColumnReference.new('t1', 'id'),
|
2114
|
+
Comparison.new('='),
|
2115
|
+
ColumnReference.new('t2', 'table1_id')
|
2116
|
+
)
|
2117
|
+
end
|
2118
|
+
|
2119
|
+
def test_construction
|
2120
|
+
assert_nothing_raised {
|
2121
|
+
JoinTable.new(@qualifier, @tables, @condition)
|
2122
|
+
}
|
2123
|
+
|
2124
|
+
assert_raises ArgumentError do
|
2125
|
+
JoinTable.new(@qualifier, @tables, nil)
|
2126
|
+
end
|
2127
|
+
assert_raises ArgumentError do
|
2128
|
+
JoinTable.new(@qualifier, nil, @condition)
|
2129
|
+
end
|
2130
|
+
assert_raises ArgumentError do
|
2131
|
+
JoinTable.new(nil, @tables, @condition)
|
2132
|
+
end
|
2133
|
+
|
2134
|
+
assert_raises RuntimeError do
|
2135
|
+
JoinTable.new(@qualifier, [], @condition)
|
2136
|
+
end
|
2137
|
+
|
2138
|
+
assert_raises TypeError do
|
2139
|
+
JoinTable.new(@qualifier, @tables, 'blah')
|
2140
|
+
end
|
2141
|
+
assert_raises TypeError do
|
2142
|
+
JoinTable.new(@qualifier, 'blah', @condition)
|
2143
|
+
end
|
2144
|
+
assert_raises TypeError do
|
2145
|
+
JoinTable.new(@condition, @tables, @condition)
|
2146
|
+
end
|
2147
|
+
end
|
2148
|
+
|
2149
|
+
def test_accessors
|
2150
|
+
t = JoinTable.new(@qualifier, @tables, @condition)
|
2151
|
+
assert_equal @qualifier, t.qualifier
|
2152
|
+
assert_equal @tables, t.tables
|
2153
|
+
assert_equal @condition, t.condition
|
2154
|
+
end
|
2155
|
+
|
2156
|
+
def test_relationships
|
2157
|
+
assert_kind_of FromTable, JoinTable.new(@qualifier, @tables, @condition)
|
2158
|
+
end
|
2159
|
+
|
2160
|
+
def test_to_s
|
2161
|
+
t = JoinTable.new(@qualifier, @tables, @condition)
|
2162
|
+
assert_equal 'LEFT_OUTER table1 t1, table2 t2 ON t1.id = t2.table1_id', t.to_s
|
2163
|
+
end
|
2164
|
+
|
2165
|
+
def test_xml
|
2166
|
+
t1 = JoinTable.new(@qualifier, @tables, @condition)
|
2167
|
+
t2 = JoinTable.from_xml(t1.to_xml)
|
2168
|
+
assert_equal t1, t2
|
2169
|
+
end
|
2170
|
+
end
|
2171
|
+
end
|
2172
|
+
|
2173
|
+
class SubQuerySetTest < ::Test::Unit::TestCase
|
2174
|
+
def setup
|
2175
|
+
@select = Select.new(
|
2176
|
+
SelectionList.new([
|
2177
|
+
ColumnReference.new('phot', 'xdim'),
|
2178
|
+
TrigonometricFunction.new('SIN', ColumnReference.new('phot', 'period'))
|
2179
|
+
])
|
2180
|
+
)
|
2181
|
+
end
|
2182
|
+
|
2183
|
+
def test_construction
|
2184
|
+
assert_nothing_raised {
|
2185
|
+
SubQuerySet.new(@select)
|
2186
|
+
}
|
2187
|
+
|
2188
|
+
assert_raises ArgumentError do
|
2189
|
+
SubQuerySet.new(nil)
|
2190
|
+
end
|
2191
|
+
|
2192
|
+
assert_raises TypeError do
|
2193
|
+
SubQuerySet.new('blah')
|
2194
|
+
end
|
2195
|
+
end
|
2196
|
+
|
2197
|
+
def test_accessors
|
2198
|
+
s = SubQuerySet.new(@select)
|
2199
|
+
assert_equal @select, s.selection
|
2200
|
+
end
|
2201
|
+
|
2202
|
+
def test_relationships
|
2203
|
+
assert_kind_of InclusionSet, SubQuerySet.new(@select)
|
2204
|
+
end
|
2205
|
+
|
2206
|
+
def test_to_s
|
2207
|
+
q = SubQuerySet.new(@select)
|
2208
|
+
assert_equal '(SELECT phot.xdim, SIN(phot.period))', q.to_s
|
2209
|
+
end
|
2210
|
+
|
2211
|
+
def test_xml
|
2212
|
+
q1 = SubQuerySet.new(@select)
|
2213
|
+
q2 = SubQuerySet.from_xml(q1.to_xml)
|
2214
|
+
assert_equal q1, q2
|
2215
|
+
end
|
2216
|
+
end
|
2217
|
+
|
2218
|
+
end
|
2219
|
+
end
|
2220
|
+
end
|