test/embulk/input/test_mixpanel.rb in embulk-input-mixpanel-0.5.1 vs test/embulk/input/test_mixpanel.rb in embulk-input-mixpanel-0.5.2
- old
+ new
@@ -70,16 +70,16 @@
actual = Mixpanel.guess(embulk_config(config))
assert_equal(expected, actual)
end
- def test_from_date_today
+ def test_from_date_future
config = {
type: "mixpanel",
api_key: API_KEY,
api_secret: API_SECRET,
- from_date: Date.today.to_s,
+ from_date: (Date.today + 1).to_s,
}
stub_export_all
mock(Embulk.logger).info(/Guessing.*#{Regexp.escape Mixpanel.default_guess_start_date.to_s}/)
@@ -243,11 +243,11 @@
def dates
(Date.today - 10)..(Date.today + 10)
end
def target_dates
- dates.find_all{|d| d < Date.today}.map {|date| date.to_s}
+ dates.find_all{|d| d <= Date.today}.map {|date| date.to_s}
end
def transaction_config
_config = config.merge(
from_date: dates.first.to_s,
@@ -373,13 +373,13 @@
end
end
def test_resume
today = Date.today
- control = proc { [{to_date: today.to_s}] }
+ control = proc { [{to_date: today.to_s, latest_fetched_time: 999}] }
actual = Mixpanel.resume(transaction_task, columns, 1, &control)
- assert_equal({from_date: today.next.to_s}, actual)
+ assert_equal({from_date: today.to_s, latest_fetched_time: 999}, actual)
end
def control
proc {} # dummy
end
@@ -502,10 +502,11 @@
params: Mixpanel.export_params(embulk_config),
fetch_unknown_columns: false,
fetch_custom_properties: false,
retry_initial_wait_sec: 0,
retry_limit: 3,
+ latest_fetched_time: 0,
}
end
end
class RunTest < self
@@ -562,10 +563,11 @@
custom_property_keys = %w($foobar)
added = [
record["event"],
record["properties"]["$specified"],
+ record["properties"]["time"] - 32400, # timezone adjust
custom_property_keys.map{|k| {k => record["properties"][k] }}.inject(&:merge)
]
mock(@page_builder).add(added).at_least(1)
mock(@page_builder).finish
@@ -581,10 +583,11 @@
def record
{
"event" => "EV",
"properties" => {
+ "time" => 1000000,
"$os" => "Android",
"$specified" => "foo",
"$foobar" => "foobar",
}
}
@@ -592,10 +595,11 @@
def schema
[
{"name" => "event", "type" => "string"},
{"name" => "$specified", "type" => "string"},
+ {"name" => "time", "type" => "integer"},
]
end
end
class UnknownColumnsTest < self
@@ -672,10 +676,11 @@
params: Mixpanel.export_params(embulk_config),
fetch_unknown_columns: false,
fetch_custom_properties: false,
retry_initial_wait_sec: 2,
retry_limit: 3,
+ latest_fetched_time: 0,
}
end
def records
[
@@ -707,9 +712,10 @@
fetch_days: DAYS,
fetch_unknown_columns: false,
fetch_custom_properties: false,
retry_initial_wait_sec: 2,
retry_limit: 3,
+ latest_fetched_time: 0,
}
end
def embulk_config
DataSource[*config.to_a.flatten(1)]