0

Changed "worldname" to "world" in configfile

Also brought tests up to date. All tests pass now.
This commit is contained in:
Andrew Brown
2012-02-14 20:39:05 -05:00
parent f3b434a327
commit aaf8e1d7cb
10 changed files with 81 additions and 57 deletions

View File

@@ -1,15 +1,15 @@
world['test'] = "test/data/settings/test_world"
worlds['test'] = "test/data/settings/test_world"
render["myworld"] = {
renders["myworld"] = {
"title": "myworld title",
"worldname": "test",
"world": "test",
"rendermode": normal,
"northdirection": "upper-left",
}
render["otherworld"] = {
renders["otherworld"] = {
"title": "otherworld title",
"worldname": "test",
"world": "test",
"rendermode": normal,
"bgcolor": "#ffffff"
}

View File

@@ -1,7 +1,7 @@
world['test'] = "test/data/settings/test_world"
worlds['test'] = "test/data/settings/test_world"
render["world"] = {
"worldname": "test",
renders["world"] = {
"world": "test",
"title": "myworld title",
"rendermode": "bad_rendermode",
"northdirection": "upper-left",

View File

@@ -12,5 +12,23 @@ from test_rendertileset import RendertileSetTest
from test_settings import SettingsTest
from test_tileset import TilesetTest
# DISABLE THIS BLOCK TO GET LOG OUTPUT FROM TILESET FOR DEBUGGING
if 0:
import logging
root = logging.getLogger()
class NullHandler(logging.Handler):
def handle(self, record):
pass
def emit(self, record):
pass
def createLock(self):
self.lock = None
root.addHandler(NullHandler())
else:
import overviewer
import logging
overviewer.configure_logger(logging.DEBUG, True)
if __name__ == "__main__":
unittest.main()

View File

@@ -21,12 +21,12 @@ class SettingsTest(unittest.TestCase):
# no exceptions so far. that's a good thing
# Test the default
self.assertEquals(things['render']['myworld']['bgcolor'], (26,26,26,0))
self.assertEquals(things['renders']['myworld']['bgcolor'], (26,26,26,0))
# Test a non-default
self.assertEquals(things['render']['otherworld']['bgcolor'], (255,255,255,0))
self.assertEquals(things['renders']['otherworld']['bgcolor'], (255,255,255,0))
self.assertEquals(things['render']['myworld']['northdirection'],
self.assertEquals(things['renders']['myworld']['northdirection'],
world.UPPER_LEFT)
def test_rendermode_validation(self):
@@ -42,20 +42,20 @@ class SettingsTest(unittest.TestCase):
fromfile = configParser.MultiWorldParser()
fromfile.parse("test/data/settings/settings_test_1.py")
self.s.set_config_item("world", {
self.s.set_config_item("worlds", {
'test': "test/data/settings/test_world",
})
self.s.set_config_item("render", {
self.s.set_config_item("renders", {
"myworld": {
"title": "myworld title",
"worldname": "test",
"world": "test",
"rendermode": rendermodes.normal,
"northdirection": "upper-left",
},
"otherworld": {
"title": "otherworld title",
"worldname": "test",
"world": "test",
"rendermode": rendermodes.normal,
"bgcolor": "#ffffff"
},
@@ -64,20 +64,20 @@ class SettingsTest(unittest.TestCase):
self.assertEquals(fromfile.get_validated_config(), self.s.get_validated_config())
def test_rendermode_string(self):
self.s.set_config_item("world", {
self.s.set_config_item("worlds", {
'test': "test/data/settings/test_world",
})
self.s.set_config_item("outputdir", "/tmp/fictional/outputdir")
self.s.set_config_item("render", {
self.s.set_config_item("renders", {
"myworld": {
"title": "myworld title",
"worldname": "test",
"world": "test",
"rendermode": "normal",
"northdirection": "upper-left",
},
})
p = self.s.get_validated_config()
self.assertEquals(p['render']['myworld']['rendermode'], rendermodes.normal)
self.assertEquals(p['renders']['myworld']['rendermode'], rendermodes.normal)
if __name__ == "__main__":
unittest.main()

View File

@@ -8,23 +8,6 @@ import random
from overviewer_core import tileset, util
# DISABLE THIS BLOCK TO GET LOG OUTPUT FROM TILESET FOR DEBUGGING
if 1:
import logging
root = logging.getLogger()
class NullHandler(logging.Handler):
def handle(self, record):
pass
def emit(self, record):
pass
def createLock(self):
self.lock = None
root.addHandler(NullHandler())
else:
import overviewer
import logging
overviewer.configure_logger(logging.DEBUG, True)
# Supporing data
# chunks list: chunkx, chunkz mapping to chunkmtime
# In comments: col, row
@@ -121,6 +104,13 @@ class FakeRegionset(object):
except KeyError:
return None
class FakeAssetmanager(object):
def __init__(self, lastrendertime):
self.lrm = lastrendertime
def get_tileset_config(self, _):
return {'lastrendertime': self.lrm}
def get_tile_set(chunks):
"""Given the dictionary mapping chunk coordinates their mtimes, returns a
dict mapping the tiles that are to be rendered to their mtimes that are
@@ -201,7 +191,7 @@ class TilesetTest(unittest.TestCase):
'rerenderprob': 0
}
defoptions.update(options)
ts = tileset.TileSet(self.rs, None, None, defoptions, outputdir)
ts = tileset.TileSet(self.rs, FakeAssetmanager(0), None, defoptions, outputdir)
if preprocess:
preprocess(ts)
ts.do_preprocessing()