test/test_roo.rb in roo-0.9.1 vs test/test_roo.rb in roo-0.9.2
- old
+ new
@@ -54,10 +54,11 @@
'simple_spreadsheet' => "ptu6bbahNZpYe-L1vEBmgGA",
'testnichtvorhandenBibelbund.ods' => "invalidkeyforanyspreadsheet", # !!! intentionally false key
"only_one_sheet" => "o10837434939102457526.762705759906130135",
"write.me" => 'ptu6bbahNZpY0N0RrxQbWdw&hl',
'formula' => 'o10837434939102457526.3022866619437760118',
+ 'time-test' => 'ptu6bbahNZpYBMhk01UfXSg',
}[spreadsheetname]
rescue
raise "unknown spreadsheetname: #{spreadsheetname}"
end
end
@@ -116,13 +117,13 @@
OPENOFFICE = true # do Openoffice-Spreadsheet Tests?
EXCEL = true # do Excel Tests?
GOOGLE = true # do Google-Spreadsheet Tests?
GNUMERIC_ODS = false # do gnumeric with ods files Tests?
-
+
OPENOFFICEWRITE = false # experimental: write access with OO-Documents
- ONLINE = true
+ ONLINE = false
LONG_RUN = false
GLOBAL_TIMEOUT = 2*12*60 # seconds
# helper method
@@ -461,11 +462,11 @@
assert_equal "thisisc8", oo.cell('c',8)
assert_equal "thisisd9", oo.cell('d',9)
assert_equal "thisisa11", oo.cell('a',11)
end
-
+
if GNUMERIC_ODS
oo = Openoffice.new(File.join("test","gnumeric_numbers1.ods"))
oo.default_sheet = oo.sheets.first
assert_equal "tata", oo.cell(6,1)
assert_equal "tata", oo.cell(6,'A')
@@ -1293,11 +1294,11 @@
# [7, 2, "=SUM([.$A$1:.B6])"],
# [7, 3, "=[Sheet2.A1]"],
# [8, 2, "=SUM([.$A$1:.B7])"],
# ], oo.formulas(oo.sheets.first)
# different format than in openoffice spreadsheets:
- #was:
+ #was:
# assert_equal [[7, 1, "=SUM(R[-6]C[0]:R[-1]C[0])"],
# [7, 2, "=SUM(R1C1:R[-1]C[0])"],
# [7, 3, "=sheet2!R[-6]C[-2]"],
# [8, 2, "=SUM(R1C1:R[-1]C[0])"]],
# oo.formulas(oo.sheets.first)
@@ -1795,12 +1796,12 @@
#assert_nothing_raised(Timeout::Error) {
Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
File.delete_if_exist("/tmp/numbers1.csv")
oo = Openoffice.new(File.join("test","numbers1.ods"))
-
- # bug?, 2008-01-15 from Troy Davis
+
+ # bug?, 2008-01-15 from Troy Davis
assert oo.to_csv("/tmp/numbers1.csv",oo.sheets.first)
assert File.exists?("/tmp/numbers1.csv")
assert_equal "", `diff test/numbers1.csv /tmp/numbers1.csv`
oo.default_sheet = oo.sheets.first
@@ -1818,11 +1819,11 @@
#assert_nothing_raised(Timeout::Error) {
Timeout::timeout(GLOBAL_TIMEOUT) do |timeout_length|
File.delete_if_exist("/tmp/numbers1_excel.csv")
oo = Excel.new(File.join("test","numbers1.xls"))
- # bug?, 2008-01-15 from Troy Davis
+ # bug?, 2008-01-15 from Troy Davis
assert oo.to_csv("/tmp/numbers1_excel.csv",oo.sheets.first)
assert File.exists?("/tmp/numbers1_excel.csv")
assert_equal "", `diff test/numbers1_excel.csv /tmp/numbers1_excel.csv`
oo.default_sheet = oo.sheets.first
assert oo.to_csv("/tmp/numbers1_excel.csv")
@@ -1846,11 +1847,11 @@
oo.default_sheet = oo.sheets.first
assert oo.to_csv("/tmp/numbers1.csv")
assert File.exists?("/tmp/numbers1.csv")
assert_equal "", `diff test/numbers1.csv /tmp/numbers1.csv`
- # bug?, 2008-01-15 from Troy Davis
+ # bug?, 2008-01-15 from Troy Davis
assert oo.to_csv("/tmp/numbers1.csv",oo.sheets.first)
assert File.exists?("/tmp/numbers1.csv")
assert_equal "", `diff test/numbers1.csv /tmp/numbers1.csv`
end # Timeout
@@ -2735,11 +2736,11 @@
oo.set_value(1,1,"hello from the tests")
#oo.set_value(1,1,"sin(1)")
assert_equal "hello from the tests", oo.cell(1,1)
end
end
-
+
def test_bug_set_value_with_more_than_one_sheet_google
# write.me: http://spreadsheets.google.com/ccc?key=ptu6bbahNZpY0N0RrxQbWdw&hl=en_GB
if GOOGLE
content1 = 'AAA'
content2 = 'BBB'
@@ -2752,11 +2753,11 @@
assert_equal content1, oo.cell(1,1)
oo.default_sheet = oo.sheets[1]
assert_equal content2, oo.cell(1,1)
end
end
-
+
def test_set_value_with_sheet_argument_google
if GOOGLE
random_row = rand(10)+1
random_column = rand(10)+1
oo = Google.new('ptu6bbahNZpY0N0RrxQbWdw')
@@ -2765,13 +2766,13 @@
content2 = 'DEF'
oo.set_value(random_row,random_column,content1,oo.sheets.first)
oo.set_value(random_row,random_column,content2,oo.sheets[1])
assert_equal content1, oo.cell(random_row,random_column,oo.sheets.first)
assert_equal content2, oo.cell(random_row,random_column,oo.sheets[1])
- end
+ end
end
-
+
def test_set_value_for_non_existing_sheet_google
if GOOGLE
oo = Google.new('ptu6bbahNZpY0N0RrxQbWdw')
assert_raise(RangeError) {
#oo.default_sheet = "no_sheet"
@@ -2859,7 +2860,116 @@
# puts "Options:"
# puts "OPENOFFICE = #{OPENOFFICE}"
# puts "EXCEL = #{EXCEL}"
# puts "GOOGLE = #{GOOGLE}"
# end
+
+ def test_bug_time_nil_openoffice
+ if OPENOFFICE
+ oo = Openoffice.new(File.join("test","time-test.ods"))
+ oo.default_sheet = oo.sheets.first
+ assert_equal 12*3600+13*60+14, oo.cell('B',1) # 12:13:14 (secs since midnight)
+ assert_equal :time, oo.celltype('B',1)
+ assert_equal 15*3600+16*60, oo.cell('C',1) # 15:16 (secs since midnight)
+ assert_equal :time, oo.celltype('C',1)
+
+ assert_equal 23*3600, oo.cell('D',1) # 23:00 (secs since midnight)
+ assert_equal :time, oo.celltype('D',1)
+ end
+ end
+
+ def test_bug_time_nil_excel
+ if EXCEL
+ oo = Excel.new(File.join("test","time-test.xls"))
+ oo.default_sheet = oo.sheets.first
+ assert_equal 12*3600+13*60+14, oo.cell('B',1) # 12:13:14 (secs since midnight)
+ assert_equal :time, oo.celltype('B',1)
+ assert_equal 15*3600+16*60, oo.cell('C',1) # 15:16 (secs since midnight)
+ assert_equal :time, oo.celltype('C',1)
+
+ assert_equal 23*3600, oo.cell('D',1) # 23:00 (secs since midnight)
+ assert_equal :time, oo.celltype('D',1)
+ end
+ end
+
+ def test_bug_time_nil_google
+ if GOOGLE
+ oo = Google.new(key_of("time-test"))
+ oo.default_sheet = oo.sheets.first
+ assert_equal 12*3600+13*60+14, oo.cell('B',1) # 12:13:14 (secs since midnight)
+ assert_equal :time, oo.celltype('B',1)
+ assert_equal 15*3600+16*60, oo.cell('C',1) # 15:16 (secs since midnight)
+ assert_equal :time, oo.celltype('C',1)
+
+ assert_equal 23*3600, oo.cell('D',1) # 23:00 (secs since midnight)
+ assert_equal :time, oo.celltype('D',1)
+ end
+ end
+
+ def test_date_time_to_csv_openoffice
+ if OPENOFFICE
+ File.delete_if_exist("/tmp/time-test.csv")
+ oo = Openoffice.new(File.join("test","time-test.ods"))
+ oo.default_sheet = oo.sheets.first
+ assert oo.to_csv("/tmp/time-test.csv")
+ assert File.exists?("/tmp/time-test.csv")
+ assert_equal "", `diff test/time-test.csv /tmp/time-test.csv`
+ end # OPENOFFICE
+ end
+
+ def test_date_time_to_csv_excel
+ if EXCEL
+ after Date.new(2008,3,30) do
+ #ueberfluessige leere Zeilen werden am Ende noch angehaengt
+ # last_row fehlerhaft?
+ File.delete_if_exist("/tmp/time-test.csv")
+ oo = Excel.new(File.join("test","time-test.xls"))
+ oo.default_sheet = oo.sheets.first
+ assert oo.to_csv("/tmp/time-test.csv")
+ assert File.exists?("/tmp/time-test.csv")
+ assert_equal "", `diff test/time-test.csv /tmp/time-test.csv`
+ end
+ end # EXCEL
+ end
+
+ def test_date_time_to_csv_google
+ if GOOGLE
+ File.delete_if_exist("/tmp/time-test.csv")
+ oo = Google.new(key_of("time-test"))
+ oo.default_sheet = oo.sheets.first
+ assert oo.to_csv("/tmp/time-test.csv")
+ assert File.exists?("/tmp/time-test.csv")
+ assert_equal "", `diff test/time-test.csv /tmp/time-test.csv`
+ end # GOOGLE
+ end
+
+ def test_date_time_yaml_openoffice
+ if OPENOFFICE
+ expected =
+ "--- \ncell_1_1: \n row: 1 \n col: 1 \n celltype: string \n value: Mittags: \ncell_1_2: \n row: 1 \n col: 2 \n celltype: time \n value: 12:13:14 \ncell_1_3: \n row: 1 \n col: 3 \n celltype: time \n value: 15:16:00 \ncell_1_4: \n row: 1 \n col: 4 \n celltype: time \n value: 23:00:00 \ncell_2_1: \n row: 2 \n col: 1 \n celltype: date \n value: 2007-11-21 \n"
+ oo = Openoffice.new(File.join("test","time-test.ods"))
+ oo.default_sheet = oo.sheets.first
+ assert_equal expected, oo.to_yaml
+ end
+ end
+
+ def test_date_time_yaml_excel
+ if EXCEL
+ expected =
+ "--- \ncell_1_1: \n row: 1 \n col: 1 \n celltype: string \n value: Mittags: \ncell_1_2: \n row: 1 \n col: 2 \n celltype: time \n value: 12:13:14 \ncell_1_3: \n row: 1 \n col: 3 \n celltype: time \n value: 15:16:00 \ncell_1_4: \n row: 1 \n col: 4 \n celltype: time \n value: 23:00:00 \ncell_2_1: \n row: 2 \n col: 1 \n celltype: date \n value: 2007-11-21 \n"
+ oo = Excel.new(File.join("test","time-test.xls"))
+ oo.default_sheet = oo.sheets.first
+ assert_equal expected, oo.to_yaml
+ end
+ end
+
+ def test_date_time_yaml_google
+ if GOOGLE
+ expected =
+ "--- \ncell_1_1: \n row: 1 \n col: 1 \n celltype: string \n value: Mittags: \ncell_1_2: \n row: 1 \n col: 2 \n celltype: time \n value: 12:13:14 \ncell_1_3: \n row: 1 \n col: 3 \n celltype: time \n value: 15:16:00 \ncell_1_4: \n row: 1 \n col: 4 \n celltype: time \n value: 23:00:00 \ncell_2_1: \n row: 2 \n col: 1 \n celltype: date \n value: 2007-11-21 \n"
+ oo = Google.new(key_of("time-test"))
+ oo.default_sheet = oo.sheets.first
+ assert_equal expected, oo.to_yaml
+ end
+ end
end # class