예제 #1
0
    def test___margin(self):
        cm = glue.ConfigManager(priority={'retina': True},
                                defaults=glue.DEFAULT_SETTINGS)
        self.assertEqual(cm.margin, 2)

        cm = glue.ConfigManager(priority={'ratios': '1,2'},
                                defaults=glue.DEFAULT_SETTINGS)
        self.assertEqual(cm.margin, 2)

        cm = glue.ConfigManager(priority={
            'retina': True,
            'margin': 10
        },
                                defaults=glue.DEFAULT_SETTINGS)
        self.assertEqual(cm.margin, 10)
예제 #2
0
 def test_extend(self):
     cm = glue.ConfigManager(self.conf_a, self.conf_b)
     cm2 = cm.extend(self.conf_c)
     self.assertEqual(cm2.sources[0], self.conf_c)
     self.assertEqual(cm2.sources[1:], cm.sources)
     self.assertEqual(cm2.defaults, cm.defaults)
     self.assertEqual(cm2.priority, cm.priority)
예제 #3
0
    def generate_manager(self, manager_cls, path, config=None):
        config = config or {}
        config = glue.ConfigManager(config, defaults=TEST_DEFAULT_SETTINGS)
        simple_path = os.path.join(self.base_path, 'tests_resources/%s' % path)
        output_path = os.path.join(self.base_path, 'tests_tmp/')

        return manager_cls(path=simple_path, config=config, output=output_path)
예제 #4
0
 def test_constructor(self):
     cm = glue.ConfigManager(self.conf_a,
                             self.conf_b,
                             defaults=self.conf_c,
                             priority=self.conf_d)
     self.assertEqual(cm.sources, [self.conf_a, self.conf_b])
     self.assertEqual(cm.defaults, self.conf_c)
     self.assertEqual(cm.priority, self.conf_d)
예제 #5
0
    def test___getattr__(self):
        cm = glue.ConfigManager(self.conf_a,
                                self.conf_b,
                                defaults=self.conf_c,
                                priority=self.conf_d)
        self.assertEqual(cm.a, 'a')
        self.assertEqual(cm.b, 'b')
        self.assertEqual(cm.c, 'c')
        self.assertEqual(cm.d, 'd')

        cm = glue.ConfigManager(self.conf_a, {'a': 'aa'},
                                defaults={'a': 'aaa'},
                                priority={'a': 'aaaa'})
        self.assertEqual(cm.a, 'aaaa')

        cm = glue.ConfigManager(self.conf_a, {'a': 'aa'},
                                defaults={'a': 'aaa'})
        self.assertEqual(cm.a, 'a')

        cm = glue.ConfigManager(self.conf_b, defaults={'a': 'aaa'})
        self.assertEqual(cm.a, 'aaa')