linkage 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,10 +24,12 @@ module IntegrationTests
24
24
  end
25
25
 
26
26
  ds = Linkage::Dataset.new(@tmpuri, "foo", :single_threaded => true)
27
+ tmpuri = @tmpuri
27
28
  conf = ds.link_with(ds) do
28
29
  lhs[:foo].must == rhs[:bar]
30
+ save_results_in(tmpuri, :single_threaded => true)
29
31
  end
30
- runner = Linkage::SingleThreadedRunner.new(conf, @tmpuri, :single_threaded => true)
32
+ runner = Linkage::SingleThreadedRunner.new(conf)
31
33
  runner.execute
32
34
 
33
35
  database do |db|
@@ -52,12 +54,14 @@ module IntegrationTests
52
54
  end
53
55
 
54
56
  ds = Linkage::Dataset.new(@tmpuri, "foo", :single_threaded => true)
57
+ tmpuri = @tmpuri
55
58
  conf = ds.link_with(ds) do
56
59
  lhs[:foo].must == rhs[:foo]
57
60
  lhs[:bar].must == 0
58
61
  rhs[:bar].must == 10
62
+ save_results_in(tmpuri)
59
63
  end
60
- runner = Linkage::SingleThreadedRunner.new(conf, @tmpuri)
64
+ runner = Linkage::SingleThreadedRunner.new(conf)
61
65
  runner.execute
62
66
 
63
67
  database do |db|
@@ -0,0 +1,30 @@
1
+ require 'helper'
2
+
3
+ class IntegrationTests::TestDataset < Test::Unit::TestCase
4
+ def setup
5
+ @tmpdir = Dir.mktmpdir('linkage')
6
+ @tmpuri = "sqlite://" + File.join(@tmpdir, "foo")
7
+ end
8
+
9
+ def database(&block)
10
+ Sequel.connect(@tmpuri, &block)
11
+ end
12
+
13
+ def teardown
14
+ FileUtils.remove_entry_secure(@tmpdir)
15
+ end
16
+
17
+ test "methods that clone the dataset" do
18
+ database do |db|
19
+ db.create_table(:foo) do
20
+ primary_key :id
21
+ String :bar
22
+ end
23
+ end
24
+ ds_1 = Linkage::Dataset.new(@tmpuri, "foo")
25
+ ds_2 = ds_1.filter(:foo => 'bar')
26
+ assert_instance_of Linkage::Dataset, ds_2
27
+ assert_equal ds_2.field_set, ds_1.field_set
28
+ assert_match /`foo` = 'bar'/, ds_2.sql
29
+ end
30
+ end
@@ -29,10 +29,12 @@ module IntegrationTests
29
29
 
30
30
  ds_1 = Linkage::Dataset.new(@tmpuri, "foo", :single_threaded => true)
31
31
  ds_2 = Linkage::Dataset.new(@tmpuri, "bar", :single_threaded => true)
32
+ tmpuri = @tmpuri
32
33
  conf = ds_1.link_with(ds_2) do
33
34
  lhs[:ssn].must == rhs[:ssn]
35
+ save_results_in(tmpuri)
34
36
  end
35
- runner = Linkage::SingleThreadedRunner.new(conf, @tmpuri)
37
+ runner = Linkage::SingleThreadedRunner.new(conf)
36
38
  runner.execute
37
39
 
38
40
  database do |db|
@@ -68,10 +70,12 @@ module IntegrationTests
68
70
 
69
71
  ds_1 = Linkage::Dataset.new(@tmpuri, "foo", :single_threaded => true)
70
72
  ds_2 = Linkage::Dataset.new(@tmpuri, "bar", :single_threaded => true)
73
+ tmpuri = @tmpuri
71
74
  conf = ds_1.link_with(ds_2) do
72
75
  lhs[:ssn].must == rhs[:ssn]
76
+ save_results_in(tmpuri)
73
77
  end
74
- runner = Linkage::SingleThreadedRunner.new(conf, @tmpuri)
78
+ runner = Linkage::SingleThreadedRunner.new(conf)
75
79
  runner.execute
76
80
 
77
81
  database do |db|
@@ -101,13 +105,14 @@ module IntegrationTests
101
105
 
102
106
  ds_1 = Linkage::Dataset.new(uri, "foo", :single_threaded => true)
103
107
  ds_2 = Linkage::Dataset.new(uri, "bar", :single_threaded => true)
108
+ logger = Logger.new(STDERR)
104
109
  conf = ds_1.link_with(ds_2) do
105
110
  lhs[:one].must == rhs[:one]
106
111
  lhs[:two].must == rhs[:two]
112
+ save_results_in(uri, :logger => logger)
107
113
  end
108
114
 
109
- logger = Logger.new(STDERR)
110
- runner = Linkage::SingleThreadedRunner.new(conf, @tmpuri, :logger => logger)
115
+ runner = Linkage::SingleThreadedRunner.new(conf)
111
116
  runner.execute
112
117
 
113
118
  Sequel.connect(@tmpuri) do |db|
@@ -24,11 +24,14 @@ module IntegrationTests
24
24
  end
25
25
 
26
26
  ds = Linkage::Dataset.new(@tmpuri, "foo", :single_threaded => true)
27
+ tmpuri = @tmpuri
27
28
  conf = ds.link_with(ds) do
28
29
  lhs[:ssn].must == rhs[:ssn]
30
+ save_results_in(tmpuri)
29
31
  end
30
- runner = Linkage::SingleThreadedRunner.new(conf, @tmpuri)
31
- runner.execute
32
+ runner = Linkage::SingleThreadedRunner.new(conf)
33
+ result_set = runner.execute
34
+ assert_kind_of Linkage::ResultSet, result_set
32
35
 
33
36
  database do |db|
34
37
  assert_equal 10, db[:groups].count
@@ -54,11 +57,13 @@ module IntegrationTests
54
57
  end
55
58
 
56
59
  ds = Linkage::Dataset.new(@tmpuri, "foo", :single_threaded => true)
60
+ tmpuri = @tmpuri
57
61
  conf = ds.link_with(ds) do
58
62
  lhs[:ssn].must == rhs[:ssn]
59
63
  lhs[:dob].must == rhs[:dob]
64
+ save_results_in(tmpuri)
60
65
  end
61
- runner = Linkage::SingleThreadedRunner.new(conf, @tmpuri)
66
+ runner = Linkage::SingleThreadedRunner.new(conf)
62
67
  runner.execute
63
68
 
64
69
  database do |db|
@@ -87,11 +92,13 @@ module IntegrationTests
87
92
  end
88
93
 
89
94
  ds = Linkage::Dataset.new(@tmpuri, "foo", :single_threaded => true)
95
+ tmpuri = @tmpuri
90
96
  conf = ds.link_with(ds) do
91
97
  lhs[:ssn].must == rhs[:ssn]
92
98
  lhs[:mod_5].must == 3
99
+ save_results_in(tmpuri)
93
100
  end
94
- runner = Linkage::SingleThreadedRunner.new(conf, @tmpuri)
101
+ runner = Linkage::SingleThreadedRunner.new(conf)
95
102
  runner.execute
96
103
 
97
104
  database do |db|
@@ -118,12 +125,14 @@ module IntegrationTests
118
125
  end
119
126
 
120
127
  ds = Linkage::Dataset.new(@tmpuri, "foo", :single_threaded => true)
128
+ tmpuri = @tmpuri
121
129
  conf = ds.link_with(ds) do
122
130
  lhs[:ssn].must == rhs[:ssn]
123
131
  lhs[:mod_5].must > 2
124
132
  lhs[:mod_5].must <= 3
133
+ save_results_in(tmpuri)
125
134
  end
126
- runner = Linkage::SingleThreadedRunner.new(conf, @tmpuri)
135
+ runner = Linkage::SingleThreadedRunner.new(conf)
127
136
  runner.execute
128
137
 
129
138
  database do |db|
@@ -150,12 +159,14 @@ module IntegrationTests
150
159
  end
151
160
 
152
161
  ds = Linkage::Dataset.new(@tmpuri, "foo", :single_threaded => true)
162
+ tmpuri = @tmpuri
153
163
  conf = ds.link_with(ds) do
154
164
  lhs[:ssn].must == rhs[:ssn]
155
165
  lhs[:mod_5].must == lhs[:mod_20]
166
+ save_results_in(tmpuri)
156
167
  end
157
168
  assert_equal :self, conf.linkage_type
158
- runner = Linkage::SingleThreadedRunner.new(conf, @tmpuri)
169
+ runner = Linkage::SingleThreadedRunner.new(conf)
159
170
  runner.execute
160
171
 
161
172
  database do |db|
@@ -182,13 +193,15 @@ module IntegrationTests
182
193
  end
183
194
 
184
195
  ds = Linkage::Dataset.new(@tmpuri, "foo", :single_threaded => true)
196
+ tmpuri = @tmpuri
185
197
  conf = ds.link_with(ds) do
186
198
  lhs[:ssn].must == rhs[:ssn]
187
199
  lhs[:mod_5].must == lhs[:mod_20]
188
200
  rhs[:mod_5].must == rhs[:mod_20]
201
+ save_results_in(tmpuri)
189
202
  end
190
203
  assert_equal :self, conf.linkage_type
191
- runner = Linkage::SingleThreadedRunner.new(conf, @tmpuri)
204
+ runner = Linkage::SingleThreadedRunner.new(conf)
192
205
  runner.execute
193
206
 
194
207
  database do |db|
@@ -215,11 +228,13 @@ module IntegrationTests
215
228
  end
216
229
 
217
230
  ds = Linkage::Dataset.new(@tmpuri, "foo", :single_threaded => true)
231
+ tmpuri = @tmpuri
218
232
  conf = ds.link_with(ds) do
219
233
  trim(lhs[:bar]).must == trim(rhs[:bar])
234
+ save_results_in(tmpuri)
220
235
  end
221
236
  assert_equal :self, conf.linkage_type
222
- runner = Linkage::SingleThreadedRunner.new(conf, @tmpuri)
237
+ runner = Linkage::SingleThreadedRunner.new(conf)
223
238
  runner.execute
224
239
 
225
240
  database do |db|
@@ -15,23 +15,22 @@ class UnitTests::TestConfiguration < Test::Unit::TestCase
15
15
  end
16
16
 
17
17
  test "linkage_type is cross when there's a 'cross-join'" do
18
- dataset = mock('dataset', :set_new_id => nil)
18
+ field_1 = stub('field_1', :to_expr => :foo)
19
+ field_2 = stub('field_2', :to_expr => :bar)
20
+ dataset = stub('dataset', :field_set => {:foo => field_1, :bar => :field_2})
19
21
  c = Linkage::Configuration.new(dataset, dataset)
20
- exp = stub('expectation', :kind => :cross)
21
- c.add_expectation(exp)
22
+ c.configure do
23
+ lhs[:foo].must == rhs[:bar]
24
+ end
22
25
  assert_equal :cross, c.linkage_type
23
26
  end
24
27
 
25
28
  test "linkage_type is cross when there's different filters on both sides" do
26
- field = stub_field('field')
27
- dataset = stub('dataset', :set_new_id => nil)
28
- dataset.stubs(:fields).returns({:foo => field})
29
+ field = stub('field', :to_expr => :foo)
30
+ dataset = stub('dataset')
31
+ dataset.stubs(:field_set).returns({:foo => field})
29
32
  c = Linkage::Configuration.new(dataset, dataset)
30
- exp_1 = stub('expectation', :kind => :filter)
31
- Linkage::MustExpectation.expects(:new).with(:==, field, 123, nil).returns(exp_1)
32
- exp_2 = stub('expectation', :kind => :filter)
33
- Linkage::MustExpectation.expects(:new).with(:==, field, 456, nil).returns(exp_2)
34
- c.send(:instance_eval) do
33
+ c.configure do
35
34
  lhs[:foo].must == 123
36
35
  rhs[:foo].must == 456
37
36
  end
@@ -39,13 +38,12 @@ class UnitTests::TestConfiguration < Test::Unit::TestCase
39
38
  end
40
39
 
41
40
  test "linkage_type is self when there's identical static filters on each side" do
42
- field = stub_field('field')
43
- dataset = stub('dataset', :set_new_id => nil)
44
- dataset.stubs(:fields).returns({:foo => field})
41
+ field = stub('field', :to_expr => :foo)
42
+ dataset = stub('dataset')
43
+ dataset.stubs(:field_set).returns({:foo => field})
45
44
  c = Linkage::Configuration.new(dataset, dataset)
46
45
  exp_1 = stub('expectation', :kind => :filter)
47
- Linkage::MustExpectation.expects(:new).twice.with(:==, field, 123, nil).returns(exp_1)
48
- c.send(:instance_eval) do
46
+ c.configure do
49
47
  lhs[:foo].must == 123
50
48
  rhs[:foo].must == 123
51
49
  end
@@ -53,16 +51,12 @@ class UnitTests::TestConfiguration < Test::Unit::TestCase
53
51
  end
54
52
 
55
53
  test "linkage_type is self when there's a two-field filter on one side" do
56
- field_1 = stub_field('field 1')
57
- field_2 = stub_field('field 2')
58
- dataset = stub('dataset', :set_new_id => nil)
59
- dataset.stubs(:fields).returns({:foo => field_1, :bar => field_2})
54
+ field_1 = stub('field 1', :to_expr => :foo)
55
+ field_2 = stub('field 2', :to_expr => :bar)
56
+ dataset = stub('dataset')
57
+ dataset.stubs(:field_set).returns({:foo => field_1, :bar => field_2})
60
58
  c = Linkage::Configuration.new(dataset, dataset)
61
- exp_1 = stub('expectation', :kind => :filter)
62
- Linkage::MustExpectation.expects(:new).with(:==, field_1, field_2, :filter).returns(exp_1)
63
- exp_2 = stub('expectation', :kind => :self)
64
- Linkage::MustExpectation.expects(:new).with(:==, field_1, field_1, nil).returns(exp_2)
65
- c.send(:instance_eval) do
59
+ c.configure do
66
60
  lhs[:foo].must == lhs[:bar]
67
61
  lhs[:foo].must == rhs[:foo]
68
62
  end
@@ -71,111 +65,135 @@ class UnitTests::TestConfiguration < Test::Unit::TestCase
71
65
 
72
66
  test "static expectation" do
73
67
  dataset_1 = stub('dataset')
74
- field = stub_field('field')
75
- dataset_1.stubs(:fields).returns({:foo => field})
68
+ field = stub('field', :to_expr => :foo)
69
+ dataset_1.stubs(:field_set).returns({:foo => field})
76
70
  dataset_2 = stub('dataset')
77
71
  c = Linkage::Configuration.new(dataset_1, dataset_2)
78
- Linkage::MustExpectation.expects(:new).with(:==, field, 123, nil)
79
- c.send(:instance_eval) do
72
+ c.configure do
80
73
  lhs[:foo].must == 123
81
74
  end
75
+ dataset_1.expects(:filter).with({:foo => 123}).returns(dataset_1)
76
+ c.expectations[0].apply_to(dataset_1, :lhs)
82
77
  end
83
78
 
84
- ## Maybe in the future
85
- #test "static expectation, flopped" do
86
- #dataset_1 = stub('dataset')
87
- #field = stub_field('field')
88
- #dataset_1.stubs(:fields).returns({:foo => field})
89
- #dataset_2 = stub('dataset')
90
- #c = Linkage::Configuration.new(dataset_1, dataset_2)
91
- #Linkage::MustExpectation.expects(:new).with(:==, 123, field)
92
- #c.send(:instance_eval) do
93
- #123.must == lhs[:foo]
94
- #end
95
- #end
96
-
97
79
  test "complain if an invalid field is accessed" do
98
80
  dataset_1 = stub('dataset')
99
- field_1 = stub_field('field 1')
100
- dataset_1.stubs(:fields).returns({:foo => field_1})
81
+ field_1 = stub('field 1')
82
+ dataset_1.stubs(:field_set).returns({:foo => field_1})
101
83
 
102
84
  dataset_2 = stub('dataset')
103
- field_2 = stub_field('field 2')
104
- dataset_2.stubs(:fields).returns({:bar => field_2})
85
+ field_2 = stub('field 2')
86
+ dataset_2.stubs(:field_set).returns({:bar => field_2})
105
87
 
106
88
  c = Linkage::Configuration.new(dataset_1, dataset_2)
107
89
  assert_raises(ArgumentError) do
108
- c.send(:instance_eval) do
90
+ c.configure do
109
91
  lhs[:foo].must == rhs[:non_existant_field]
110
92
  end
111
93
  end
112
94
  end
113
95
 
114
96
  operators = [:>, :<, :>=, :<=]
115
- operators << :'!=' if current_ruby_version >= ruby19
116
97
  operators.each do |operator|
117
98
  test "DSL #{operator} filter operator" do
118
99
  dataset_1 = stub('dataset 1')
119
- field_1 = stub_field('field 1')
120
- dataset_1.stubs(:fields).returns({:foo => field_1})
100
+ field_1 = stub('field 1', :to_expr => :foo)
101
+ dataset_1.stubs(:field_set).returns({:foo => field_1})
121
102
 
122
103
  dataset_2 = stub('dataset 2')
123
- field_2 = stub_field('field 2')
124
- dataset_2.stubs(:fields).returns({:bar => field_2})
125
104
 
126
105
  c = Linkage::Configuration.new(dataset_1, dataset_2)
127
- Linkage::MustExpectation.expects(:new).with(operator, field_1, field_2, nil)
128
106
  block = eval("Proc.new { lhs[:foo].must #{operator} rhs[:bar] }")
129
- c.send(:instance_eval, &block)
107
+ c.configure do
108
+ lhs[:foo].must.send(operator, 123)
109
+ end
110
+ expr = Sequel::SQL::BooleanExpression.new(operator, Sequel::SQL::Identifier.new(:foo), 123)
111
+ dataset_1.expects(:filter).with(expr).returns(dataset_1)
112
+ c.expectations[0].apply_to(dataset_1, :lhs)
130
113
  end
131
114
  end
132
115
 
133
116
  test "must_not expectation" do
134
117
  dataset_1 = stub('dataset 1')
135
- field_1 = stub_field('field 1')
136
- dataset_1.stubs(:fields).returns({:foo => field_1})
118
+ field_1 = stub('field 1', :to_expr => :foo)
119
+ dataset_1.stubs(:field_set).returns({:foo => field_1})
137
120
  dataset_2 = stub('dataset 2')
138
121
 
139
122
  c = Linkage::Configuration.new(dataset_1, dataset_2)
140
- Linkage::MustNotExpectation.expects(:new).with(:==, field_1, 123, nil)
141
- c.send(:instance_eval) do
123
+ c.configure do
142
124
  lhs[:foo].must_not == 123
143
125
  end
126
+ dataset_1.expects(:filter).with(~{:foo => 123}).returns(dataset_1)
127
+ c.expectations[0].apply_to(dataset_1, :lhs)
144
128
  end
145
129
 
146
130
  test "dynamic database function" do
147
131
  dataset_1 = stub('dataset')
148
- field_1 = stub_field('field 1')
149
- dataset_1.stubs(:fields).returns({:foo => field_1})
132
+ field_1 = stub('field 1')
133
+ dataset_1.stubs(:field_set).returns({:foo => field_1})
150
134
  dataset_2 = stub('dataset')
151
- field_2 = stub_field('field 2')
152
- dataset_2.stubs(:fields).returns({:foo => field_2})
135
+ field_2 = stub('field 2', :to_expr => :foo)
136
+ dataset_2.stubs(:field_set).returns({:foo => field_2})
153
137
 
154
- func = stub_function('function', :static? => false)
138
+ func_expr = stub('function expression') do
139
+ expects(:as).with(:trim_foo_foo).returns(self)
140
+ end
141
+ func = stub('function', :static? => false, :to_expr => func_expr)
155
142
  Linkage::Functions::Trim.expects(:new).with(field_1).returns(func)
143
+ merged_field = stub('merged field', :name => :trim_foo_foo)
144
+ func.expects(:merge).with(field_2).returns(merged_field)
156
145
 
157
146
  c = Linkage::Configuration.new(dataset_1, dataset_2)
158
- Linkage::MustExpectation.expects(:new).with(:==, func, field_2, nil)
159
- c.send(:instance_eval) do
147
+ c.configure do
160
148
  trim(lhs[:foo]).must == rhs[:foo]
161
149
  end
150
+ dataset_1.expects(:select_more).with(func_expr).returns(dataset_1)
151
+ dataset_1.expects(:order_more).with(func_expr).returns(dataset_1)
152
+ c.expectations[0].apply_to(dataset_1, :lhs)
153
+
154
+ dataset_2.expects(:select_more).with(:foo.as(:trim_foo_foo)).returns(dataset_2)
155
+ dataset_2.expects(:order_more).with(:foo).returns(dataset_2)
156
+ c.expectations[0].apply_to(dataset_2, :rhs)
162
157
  end
163
158
 
164
159
  test "static database function" do
165
160
  dataset_1 = stub('dataset')
166
- field_1 = stub_field('field 1')
167
- dataset_1.stubs(:fields).returns({:foo => field_1})
161
+ field_1 = stub('field 1', :to_expr => :foo)
162
+ dataset_1.stubs(:field_set).returns({:foo => field_1})
168
163
  dataset_2 = stub('dataset')
169
- field_2 = stub_field('field 2')
170
- dataset_2.stubs(:fields).returns({:foo => field_2})
164
+ field_2 = stub('field 2')
165
+ dataset_2.stubs(:field_set).returns({:foo => field_2})
171
166
 
172
- func = stub_function('function', :static? => true)
167
+ func_expr = stub('function expression')
168
+ func = stub('function', :static? => true, :to_expr => func_expr)
173
169
  Linkage::Functions::Trim.expects(:new).with("foo").returns(func)
174
170
 
175
171
  c = Linkage::Configuration.new(dataset_1, dataset_2)
176
- Linkage::MustExpectation.expects(:new).with(:==, field_1, func, :filter)
177
- c.send(:instance_eval) do
172
+ c.configure do
178
173
  lhs[:foo].must == trim("foo")
179
174
  end
175
+ dataset_1.expects(:filter).with({:foo => func_expr}).returns(dataset_1)
176
+ c.expectations[0].apply_to(dataset_1, :lhs)
177
+ end
178
+
179
+ test "save_results_in" do
180
+ dataset_1 = stub('dataset')
181
+ dataset_2 = stub('dataset')
182
+ c = Linkage::Configuration.new(dataset_1, dataset_2)
183
+ c.configure do
184
+ save_results_in("mysql://localhost/results", {:foo => 'bar'})
185
+ end
186
+ assert_equal "mysql://localhost/results", c.results_uri
187
+ assert_equal({:foo => 'bar'}, c.results_uri_options)
188
+ end
189
+
190
+ test "result_set" do
191
+ dataset_1 = stub('dataset')
192
+ dataset_2 = stub('dataset')
193
+ c = Linkage::Configuration.new(dataset_1, dataset_2)
194
+
195
+ result_set = stub('result set')
196
+ Linkage::ResultSet.expects(:new).with(c).returns(result_set)
197
+ assert_equal result_set, c.result_set
180
198
  end
181
199
  end
@@ -19,11 +19,6 @@ class UnitTests::TestData < Test::Unit::TestCase
19
19
  assert_raises(NotImplementedError) { d.ruby_type }
20
20
  end
21
21
 
22
- test "dataset raises NotImplementedError" do
23
- d = Linkage::Data.new(:foo)
24
- assert_raises(NotImplementedError) { d.dataset }
25
- end
26
-
27
22
  test "to_expr raises NotImplementedError" do
28
23
  d = Linkage::Data.new(:foo)
29
24
  assert_raises(NotImplementedError) { d.to_expr }
@@ -397,60 +392,4 @@ class UnitTests::TestData < Test::Unit::TestCase
397
392
  result_data = data_2.merge(data_1, 'foo')
398
393
  assert_equal :foo, result_data.name
399
394
  end
400
-
401
- test "== returns true when data have the same name and are from the same dataset" do
402
- dataset_1 = stub('dataset')
403
- data_1 = new_data(:foo, {:type => Integer}, dataset_1)
404
- dataset_2 = stub('dataset clone')
405
- data_2 = new_data(:foo, {:type => Integer}, dataset_2)
406
-
407
- dataset_1.expects(:==).with(dataset_2).returns(true)
408
- assert_equal data_1, data_2
409
- end
410
-
411
- test "== returns false when data have different classes" do
412
- dataset_1 = stub('dataset')
413
- data_1 = new_data(:foo, {:type => Integer}, dataset_1, DataSubclass)
414
- dataset_2 = stub('dataset clone')
415
- data_2 = new_data(:foo, {:type => Integer}, dataset_2, DataSubclass.clone)
416
- assert_not_equal data_1, data_2
417
- end
418
-
419
- test "== returns false when data have the same name but are from different datasets" do
420
- dataset_1 = stub('dataset')
421
- data_1 = new_data(:foo, {:type => Integer}, dataset_1)
422
- dataset_2 = stub('dataset clone')
423
- data_2 = new_data(:foo, {:type => Integer}, dataset_2)
424
-
425
- dataset_1.expects(:==).with(dataset_2).returns(false)
426
- assert_not_equal data_1, data_2
427
- end
428
-
429
- test "== returns true for identical static functions" do
430
- klass = new_function('foo', {:type => String})
431
- func_1 = klass.new(123)
432
- func_2 = klass.new(123)
433
-
434
- assert_equal func_1, func_2
435
- end
436
-
437
- test "belongs_to? dataset" do
438
- dataset = stub('dataset 1', :id => 1)
439
- data = new_data(:foo, {:type => Integer}, dataset)
440
- assert data.belongs_to?(dataset)
441
- end
442
-
443
- test "belongs_to? dataset with same id" do
444
- dataset_1 = stub('dataset 1', :id => 1)
445
- dataset_2 = stub('dataset 2', :id => 1)
446
- data = new_data(:foo, {:type => Integer}, dataset_1)
447
- assert data.belongs_to?(dataset_2)
448
- end
449
-
450
- test "belongs_to? dataset with different id" do
451
- dataset_1 = stub('dataset 1', :id => 1)
452
- dataset_2 = stub('dataset 2', :id => 2)
453
- data = new_data(:foo, {:type => Integer}, dataset_1)
454
- assert !data.belongs_to?(dataset_2)
455
- end
456
395
  end