1. Eric Larson
  2. Alamode

Commits

Eric Larson  committed 319f7bf

Config tests passing. Avoiding anything clever with dict vs. getattr.

  • Participants
  • Parent commits a74ef8b
  • Branches default

Comments (0)

Files changed (2)

File alamode/config/__init__.py

View file
 
 class ServerConfig(DictConfig):
 
-    def __init__(self, **kw):
-        pass
+    shortnames_map = {
+        'host': 'server.socket_host',
+        'port': 'server.socket_port',
+    }
+
+    def __call__(self):
+        config = self.data.copy()
+        for shortname, cpname in self.shortnames_map.items():
+            if shortname in config:
+                config[cpname] = config[shortname]
+                del config[shortname]
+        return config

File tests/unit/test_config.py

View file
     def test_server_host_and_port_attributes(self):
         conf = ServerConfig(host='localhost', port=8080)
 
-        assert conf.host == 'localhost'
-        assert conf.port == 8080
+        assert conf['host'] == 'localhost'
+        assert conf['port'] == 8080
         assert conf() == {'server.socket_host': 'localhost',
                           'server.socket_port': 8080}