test/test_roo.rb in roo-1.2.2 vs test/test_roo.rb in roo-1.2.3
- old
+ new
@@ -111,11 +111,11 @@
GOOGLE = true # do Google-Spreadsheet Tests?
GNUMERIC_ODS = false # do gnumeric with ods files Tests?
EXCELX = true # do Excel-X Tests? (.xlsx-files)
OPENOFFICEWRITE = false # experimental: write access with OO-Documents
- ONLINE = false
+ ONLINE = true
LONG_RUN = false
GLOBAL_TIMEOUT = 48.minutes #*60 # 2*12*60 # seconds
def setup
#if DISPLAY_LOG
@@ -1970,11 +1970,11 @@
end
end
end
def test_excel_zipped
- after Date.new(2008,12,31) do
+ after Date.new(2009,1,10) do
if EXCEL
$log.level = Logger::DEBUG
excel = Excel.new(File.join("test","bode-v1.xls.zip"), :zip)
assert excel
# muss Fehler bringen, weil kein default_sheet gesetzt wurde
@@ -3396,35 +3396,35 @@
assert_equal Openoffice.letter_to_number('E'), oo.last_column
end
end
def test_should_raise_file_not_found_error
- after Date.new(2008,12,31) do
- if OPENOFFICE
+ if OPENOFFICE
+ assert_raise(IOError) {
+ oo = Openoffice.new(File.join('testnichtvorhanden','Bibelbund.ods'))
+ }
+ end
+ if EXCEL
+ assert_raise(IOError) {
+ oo = Excel.new(File.join('testnichtvorhanden','Bibelbund.xls'))
+ }
+ end
+ if EXCELX
+ assert_raise(IOError) {
+ oo = Excelx.new(File.join('testnichtvorhanden','Bibelbund.xlsx'))
+ }
+ end
+ if GOOGLE
+ after Date.new(2009,1,15) do
assert_raise(IOError) {
- oo = Openoffice.new(File.join('testnichtvorhanden','Bibelbund.ods'))
- }
- end
- if EXCEL
- assert_raise(IOError) {
- oo = Excel.new(File.join('testnichtvorhanden','Bibelbund.xls'))
- }
- end
- if EXCELX
- assert_raise(IOError) {
- oo = Excelx.new(File.join('testnichtvorhanden','Bibelbund.xlsx'))
- }
- end
- if GOOGLE
- assert_raise(IOError) {
# oo = Google.new(key_of('testnichtvorhanden'+'Bibelbund.ods'))
oo = Google.new('testnichtvorhanden')
}
end
end
end
-
+
def test_bug_cell_no_default_sheet
if GOOGLE
oo = Google.new(key_of("numbers1"))
assert_raise(ArgumentError) {
# should complain about not set default-sheet
@@ -3874,24 +3874,24 @@
}
end
end
def test_bug_row_column_fixnum_float
- if EXCEL
- ex = Excel.new(File.join('test','bug-row-column-fixnum-float.xls'))
- ex.default_sheet = ex.sheets.first
- assert_equal 42.5, ex.cell('b',2)
- assert_equal 43 , ex.cell('c',2)
- assert_equal ['hij',42.5, 43], ex.row(2)
- assert_equal ['def',42.5, 'nop'], ex.column(2)
- end
+ if EXCEL
+ ex = Excel.new(File.join('test','bug-row-column-fixnum-float.xls'))
+ ex.default_sheet = ex.sheets.first
+ assert_equal 42.5, ex.cell('b',2)
+ assert_equal 43 , ex.cell('c',2)
+ assert_equal ['hij',42.5, 43], ex.row(2)
+ assert_equal ['def',42.5, 'nop'], ex.column(2)
+ end
end
def test_bug_c2
if EXCEL
- after Date.new(2008,12,25) do
+ after Date.new(2009,1,6) do
local_only do
expected = ['Supermodel X','T6','Shaun White','Jeremy','Custom',
'Warhol','Twin','Malolo','Supermodel','Air','Elite',
'King','Dominant','Dominant Slick','Blunt','Clash',
'Bullet','Tadashi Fuse','Jussi','Royale','S-Series',
@@ -3912,11 +3912,11 @@
end
end
end
def test_bug_c2_parseexcel
- after Date.new(2008,12,11) do
+ after Date.new(2009,1,10) do
local_only do
#-- this is OK
@workbook = Spreadsheet::ParseExcel.parse(File.join('test',"problem.xls"))
worksheet = @workbook.worksheet(11)
skip = 0
@@ -3991,11 +3991,11 @@
end
end
def test_compare_csv_excelx_excel
if EXCELX
- after Date.new(2008,12,10) do
+ after Date.new(2008,12,30) do
# parseexcel bug
local_only do
s1 = Excel.new(File.join("test","problem.xls"))
s2 = Excelx.new(File.join("test","problem.xlsx"))
s1.sheets.each {|sh| #TODO:
@@ -4013,11 +4013,11 @@
end
end
end
def test_problemx_csv_imported
- after Date.new(2008,12,26) do
+ after Date.new(2009,1,6) do
if EXCEL
local_only do
# wieder eingelesene CSV-Datei aus obigem Test
# muss identisch mit problem.xls sein
# Importieren aus csv-Datei muss manuell gemacht werden
@@ -4162,28 +4162,28 @@
assert_equal [], Dir.glob("oo_*")
end
end
def test_open_from_uri
- if ONLINE
- if OPENOFFICE
- assert_raises(RuntimeError) {
- oo = Openoffice.new("http://gibbsnichtdomainxxxxx.com/file.ods")
- }
- end
- if EXCEL
- assert_raises(RuntimeError) {
- oo = Excel.new("http://gibbsnichtdomainxxxxx.com/file.xls")
- }
- end
- if EXCELX
- assert_raises(RuntimeError) {
- oo = Excelx.new("http://gibbsnichtdomainxxxxx.com/file.xlsx")
- }
- end
+ if ONLINE
+ if OPENOFFICE
+ assert_raises(RuntimeError) {
+ oo = Openoffice.new("http://gibbsnichtdomainxxxxx.com/file.ods")
+ }
end
+ if EXCEL
+ assert_raises(RuntimeError) {
+ oo = Excel.new("http://gibbsnichtdomainxxxxx.com/file.xls")
+ }
end
+ if EXCELX
+ assert_raises(RuntimeError) {
+ oo = Excelx.new("http://gibbsnichtdomainxxxxx.com/file.xlsx")
+ }
+ end
+ end
+ end
def test_bug_last_row_excel
if EXCEL
oo = Excel.new(File.join("test","time-test.xls"))
oo.default_sheet = oo.sheets.first
@@ -4367,11 +4367,11 @@
assert_equal "168W", ss.cell(13,'o'), ss.class
end
def test_possible_bug_snowboard_cells
local_only do
- after Date.new(2008,12,26) do
+ after Date.new(2009,1,6) do
# warten auf Bugfix in parseexcel
if EXCEL
ex = Excel.new(File.join('test','problem.xls'))
ex.default_sheet = 'Custom X'
common_possible_bug_snowboard_cells(ex)
@@ -4695,103 +4695,139 @@
#-- bei diesen Test bekomme ich seltsamerweise einen Fehler can't allocate
#-- memory innerhalb der zip-Routinen => erstmal deaktiviert
def test_huge_table_timing_10_000_openoffice
after Date.new(2009,1,1) do
if OPENOFFICE
- assert_nothing_raised(Timeout::Error) {
- Timeout::timeout(3.minutes) do |timeout_length|
- oo = Openoffice.new("/home/tp/ruby-test/too-testing/speedtest_10000.ods")
- # process every cell
- sum = 0
- oo.sheets.each {|sheet|
- oo.default_sheet = sheet
- for row in oo.first_row..oo.last_row do
- for col in oo.first_column..oo.last_column do
- c = oo.cell(row,col)
- sum += c.length if c
+ if LONG_RUN
+ assert_nothing_raised(Timeout::Error) {
+ Timeout::timeout(3.minutes) do |timeout_length|
+ oo = Openoffice.new("/home/tp/ruby-test/too-testing/speedtest_10000.ods")
+ # process every cell
+ sum = 0
+ oo.sheets.each {|sheet|
+ oo.default_sheet = sheet
+ for row in oo.first_row..oo.last_row do
+ for col in oo.first_column..oo.last_column do
+ c = oo.cell(row,col)
+ sum += c.length if c
+ end
end
- end
- p sum
- assert sum > 0
- }
- end
- }
+ p sum
+ assert sum > 0
+ }
+ end
+ }
+ end
end
end
end
def test_huge_table_timing_10_000_excel
after Date.new(2009,1,1) do
if EXCEL
- assert_nothing_raised(Timeout::Error) {
- Timeout::timeout(3.minutes) do |timeout_length|
- oo = Excel.new("/home/tp/ruby-test/too-testing/speedtest_10000.xls")
- # process every cell
- sum = 0
- oo.sheets.each {|sheet|
- oo.default_sheet = sheet
- for row in oo.first_row..oo.last_row do
- for col in oo.first_column..oo.last_column do
- c = oo.cell(row,col)
- sum += c.length if c
+ if LONG_RUN
+ assert_nothing_raised(Timeout::Error) {
+ Timeout::timeout(3.minutes) do |timeout_length|
+ oo = Excel.new("/home/tp/ruby-test/too-testing/speedtest_10000.xls")
+ # process every cell
+ sum = 0
+ oo.sheets.each {|sheet|
+ oo.default_sheet = sheet
+ for row in oo.first_row..oo.last_row do
+ for col in oo.first_column..oo.last_column do
+ c = oo.cell(row,col)
+ sum += c.length if c
+ end
end
- end
- p sum
- assert sum > 0
- }
- end
- }
+ p sum
+ assert sum > 0
+ }
+ end
+ }
+ end
end
end
end
def test_huge_table_timing_10_000_google
after Date.new(2009,1,1) do
if GOOGLE
- assert_nothing_raised(Timeout::Error) {
- Timeout::timeout(3.minutes) do |timeout_length|
- oo = Excel.new(key_of("/home/tp/ruby-test/too-testing/speedtest_10000.xls"))
- # process every cell
- sum = 0
- oo.sheets.each {|sheet|
- oo.default_sheet = sheet
- for row in oo.first_row..oo.last_row do
- for col in oo.first_column..oo.last_column do
- c = oo.cell(row,col)
- sum += c.length if c
+ if LONG_RUN
+ assert_nothing_raised(Timeout::Error) {
+ Timeout::timeout(3.minutes) do |timeout_length|
+ oo = Excel.new(key_of("/home/tp/ruby-test/too-testing/speedtest_10000.xls"))
+ # process every cell
+ sum = 0
+ oo.sheets.each {|sheet|
+ oo.default_sheet = sheet
+ for row in oo.first_row..oo.last_row do
+ for col in oo.first_column..oo.last_column do
+ c = oo.cell(row,col)
+ sum += c.length if c
+ end
end
- end
- p sum
- assert sum > 0
- }
- end
- }
+ p sum
+ assert sum > 0
+ }
+ end
+ }
+ end
end
end
end
def test_huge_table_timing_10_000_excelx
after Date.new(2009,1,1) do
if EXCELX
- assert_nothing_raised(Timeout::Error) {
- Timeout::timeout(3.minutes) do |timeout_length|
- oo = Excelx.new("/home/tp/ruby-test/too-testing/speedtest_10000.xlsx")
- # process every cell
- sum = 0
- oo.sheets.each {|sheet|
- oo.default_sheet = sheet
- for row in oo.first_row..oo.last_row do
- for col in oo.first_column..oo.last_column do
- c = oo.cell(row,col)
- sum += c.length if c
+ if LONG_RUN
+ assert_nothing_raised(Timeout::Error) {
+ Timeout::timeout(3.minutes) do |timeout_length|
+ oo = Excelx.new("/home/tp/ruby-test/too-testing/speedtest_10000.xlsx")
+ # process every cell
+ sum = 0
+ oo.sheets.each {|sheet|
+ oo.default_sheet = sheet
+ for row in oo.first_row..oo.last_row do
+ for col in oo.first_column..oo.last_column do
+ c = oo.cell(row,col)
+ sum += c.length if c
+ end
end
- end
- p sum
- assert sum > 0
- }
- end
- }
+ p sum
+ assert sum > 0
+ }
+ end
+ }
+ end
end
end
end
+ # Eine Spreadsheetdatei wird nicht als Dateiname sondern direkt als Dokument
+ # geoeffnettest_problemx_csv_imported
+ def test_from_stream_openoffice
+ after Date.new(2009,1,6) do
+ if OPENOFFICE
+ filecontent = nil
+ File.open(File.join("test","numbers1.ods")) do |f|
+ filecontent = f.read
+ p filecontent.class
+ p filecontent.size
+ #p filecontent
+ assert filecontent.size > 0
+ # #stream macht das gleiche wie #new liest abe aus Stream anstatt Datei
+ oo = Openoffice.stream(filecontent)
+ end
+ #oo = Openoffice.open()
+ end
+ end
+ end
+
+
+ def test_bug_encoding_exported_from_google
+ if EXCEL
+ xl = Excel.new(File.join("test","numbers1_from_google.xls"))
+ xl.default_sheet = xl.sheets.first
+ assert_equal 'test', xl.cell(2,'F')
+ end
+ end
end # class