test/embulk/input/test_mixpanel.rb in embulk-input-mixpanel-0.5.5 vs test/embulk/input/test_mixpanel.rb in embulk-input-mixpanel-0.5.6
- old
+ new
@@ -569,20 +569,20 @@
@plugin.run
end
def test_run
stub(@plugin).preview? { false }
- mock(@page_builder).add(anything).times(records.length * 2)
+ mock(@page_builder).add(anything).times(records.length)
mock(@page_builder).finish
@plugin.run
end
def test_timezone
stub(@plugin).preview? { false }
adjusted = record_epoch - timezone_offset_seconds
- mock(@page_builder).add(["FOO", adjusted, "event"]).times(records.length * 2)
+ mock(@page_builder).add(["FOO", adjusted, "event"]).times(records.length)
mock(@page_builder).finish
@plugin.run
end
@@ -590,13 +590,13 @@
def test_default_slice_range
plugin = Mixpanel.new(task.merge(slice_range: 2), nil, nil, @page_builder)
stub(plugin).preview? {false}
stub(plugin).fetch(["2015-02-22", "2015-02-23"],0){[]}
- stub(plugin).fetch(["2015-02-24", "2015-02-25"],0){[]}
- stub(plugin).fetch(["2015-02-26", "2015-02-27"],0){[]}
- stub(plugin).fetch(["2015-02-28", "2015-03-01"],0){[]}
+ stub(plugin).fetch(["2015-02-22", "2015-02-25"],0){[]}
+ stub(plugin).fetch(["2015-02-22", "2015-02-27"],0){[]}
+ stub(plugin).fetch(["2015-02-22", "2015-03-01"],0){[]}
mock(@page_builder).finish
plugin.run
end
end
@@ -642,14 +642,20 @@
stub(plugin).preview? {false}
adjusted = record_epoch - timezone_offset_seconds
mock(page_builder).add(["FOO", adjusted, "event"]).times(records.length * 2)
mock(page_builder).finish
any_instance_of(MixpanelApi::Client) do |klass|
- stub(klass).export() do |params, block|
- assert_equal('(abc==def) and properties["mp_processing_time_ms"] > 1',params["where"])
+ stub(klass).export(satisfy{|params|
+ '(abc==def) and properties["mp_processing_time_ms"] > 1'==params["where"]
+ }).once do |params, block|
records.each{|record| block.call(record) }
end
+ stub(klass).export(satisfy{|params|
+ '(abc==def) and properties["mp_processing_time_ms"] > 1234567919'==params["where"]
+ }).once do |params, block|
+ records.each{|record| block.call(record) }
+ end
end
task_report = plugin.run
assert_equal(1234567919, task_report[:latest_fetched_time])
end
@@ -659,14 +665,20 @@
stub(plugin).preview? {false}
adjusted = record_epoch - timezone_offset_seconds
mock(page_builder).add(["FOO", adjusted, "event"]).times(records.length * 2)
mock(page_builder).finish
any_instance_of(MixpanelApi::Client) do |klass|
- stub(klass).export() do |params, block|
- assert_equal('properties["mp_processing_time_ms"] > 1',params["where"])
+ stub(klass).export(satisfy {|params|
+ 'properties["mp_processing_time_ms"] > 1'==params["where"]
+ }).once() do |params,block|
records.each{|record| block.call(record) }
end
+ stub(klass).export(satisfy {|params|
+ 'properties["mp_processing_time_ms"] > 1234567919' == params["where"]
+ }).once() do |params,block|
+ records.each{|record| block.call(record) }
+ end
end
task_report = plugin.run
assert_equal(1234567919, task_report[:latest_fetched_time])
end
@@ -768,10 +780,10 @@
properties["foo"],
adjusted_time,
{"int" => properties["int"], "event" => record["event"]}.to_json
]
- mock(@page_builder).add(added).times(records.length * 2)
+ mock(@page_builder).add(added).times(records.length)
mock(@page_builder).finish
@plugin.run
end