integration test fixes

This commit is contained in:
John Bintz 2010-01-10 21:54:20 -05:00
parent e0f4c6935e
commit e69c9dcd9a
8 changed files with 48 additions and 13 deletions

View File

@ -54,7 +54,7 @@ class ConfigLoader
if matches = re.match(filename)
filename
end
end
end.compact
end
end

View File

@ -46,6 +46,26 @@ class Scheduler
breaks = parameters['breaks'] || []
all_strings = true
parameters['interval'].each do |i|
if !i.is_a? String
all_strings = false
break
end
end
if all_strings
parameters['interval'].each_index do |i|
interval = parameters['interval'].shift
if current == skip_to_dow(current, interval)
parameters['interval'].unshift(interval)
break
else
parameters['interval'].push(interval)
end
end
end
index = 0
while dates.length < to_produce
interval = parameters['interval'].shift

View File

@ -35,7 +35,7 @@ class TestConfigLoader < Test::Unit::TestCase
[
{
'Global' => {
'path' => '*.svg',
'path' => '.',
'match' => '.*\.svg',
'page_index_format' => '%02d'
},
@ -45,7 +45,7 @@ class TestConfigLoader < Test::Unit::TestCase
},
{
'Global' => {
'path' => '*.svg',
'path' => '.',
'match' => '.*\.svg',
'page_index_format' => '%02d',
'files' => [ Dir.pwd + '/test1.svg', Dir.pwd + '/test2.svg' ],
@ -178,6 +178,10 @@ class TestConfigLoader < Test::Unit::TestCase
end
assert_equal expected_result, @config_loader.load('file')
if files
files.each { |f| FileUtils.rm f }
end
end
end
end
@ -189,6 +193,8 @@ class TestConfigLoader < Test::Unit::TestCase
end
assert_equal %w(one two three), @config_loader.load_yaml('test')
FileUtils.rm 'test'
end
end
@ -196,6 +202,7 @@ class TestConfigLoader < Test::Unit::TestCase
FakeFS do
FileUtils.touch [ 'test', 'test2', 'test3' ]
assert_equal '%01d', @config_loader.count_pattern('*')
[ 'test', 'test2', 'test3' ].each { |f| FileUtils.rm f }
end
end
end

View File

@ -143,6 +143,7 @@ class TestFileProcessor < Test::Unit::TestCase
FakeFS do
FileUtils.touch [ 'r-test', 'r-test2', 'source' ]
assert_equal expected_return, file_processor.determine_rebuild(targets, filename)
[ 'r-test', 'r-test2', 'source' ].each { |f| FileUtils.rm f }
end
end
end

View File

@ -65,6 +65,8 @@ class TestFilter < Test::Unit::TestCase
[ 'test4' ].each do |file|
assert File.exists? file
end
[ 'test', 'test3', 'test4' ].each { |f| FileUtils.rm f }
end
end

View File

@ -71,7 +71,7 @@ class TestSVGToTempBitmap < Test::Unit::TestCase
def test_single_no_spread
@filter.output_filename = 'test'
@filter.expects(:inkscape).with('file', Dir.pwd + '/test')
@filter.expects(:inkscape).with(Dir.pwd + '/file', Dir.pwd + '/test')
assert_equal Dir.pwd + '/test', @filter.single('file')
assert_equal [ Dir.pwd + '/test' ], @filter.cleanup
end
@ -83,7 +83,7 @@ class TestSVGToTempBitmap < Test::Unit::TestCase
'spread' => true
}
@filter.expects(:inkscape).with('file', Dir.pwd + '/test')
@filter.expects(:inkscape).with(Dir.pwd + '/file', Dir.pwd + '/test')
@filter.expects(:build_spread).with(Dir.pwd + '/test').returns(['target1', 'target2'])
@filter.single('file')

View File

@ -38,7 +38,7 @@ class TestScheduler < Test::Unit::TestCase
],
[
{
'start' => DateTime.parse('2010-01-01'),
'start' => DateTime.parse('2010-01-02'),
'interval' => [ 'monday', 'wednesday', 'friday' ],
'breaks' => [
{ 'at_index' => 3, 'for_days' => 7 }
@ -50,6 +50,16 @@ class TestScheduler < Test::Unit::TestCase
DateTime.parse('2010-01-18'), DateTime.parse('2010-01-20'), DateTime.parse('2010-01-22')
]
],
[
{
'start' => DateTime.parse('2010-01-06'),
'interval' => [ 'monday', 'wednesday', 'friday' ],
},
3,
[
DateTime.parse('2010-01-06'), DateTime.parse('2010-01-08'), DateTime.parse('2010-01-11'),
]
],
].each do |parameters, to_produce, expected_results|
assert_equal expected_results, @scheduler.schedule(parameters, to_produce)
end

View File

@ -22,16 +22,11 @@ class TestTempBitmapToWeb < Test::Unit::TestCase
end
end
def test_requires_schedule
@filter.requires_schedule('test')
assert_equal 'test', @filter.schedule
end
def test_filename
@filter.schedule = [ Date.parse('2010-01-01') ]
@filter.config = {
'target' => 'test{date}',
'date_format' => '%Y-%m-%d'
'date_format' => '%Y-%m-%d',
'publish_dates' => [ Date.parse('2010-01-01') ]
}
assert_equal 'test2010-01-01', @filter.filename({'index' => 0})
end