def test_remote_and_local_settings_are_combined(self, mock_rcfg, mock_lcfg): mock_lcfg.__iter__.return_value = ('foo', 'bar', 'baz') mock_rcfg.__iter__.return_value = ('Foo', 'Bar', 'Baz') cands = candidates.setting_names() self.assertEqual( tuple(cands), ('bar', 'baz', 'foo', 'srv.Bar', 'srv.Baz', 'srv.Foo')) self.assertEqual(cands.label, 'Settings')
def test_default(self, mock_rcfg, mock_lcfg): mock_lcfg.__iter__.return_value = ('foo', 'bar') mock_rcfg.__iter__.return_value = ('Foo', 'Bar') mock_lcfg.default.side_effect = lambda name: list(name) mock_rcfg.default.side_effect = lambda name: (name,) * 2 cands = candidates.setting_names() self.assertEqual(cands[0].default, "['b', 'a', 'r']") self.assertEqual(cands[1].default, "['f', 'o', 'o']") self.assertEqual(cands[2].default, "('Bar', 'Bar')") self.assertEqual(cands[3].default, "('Foo', 'Foo')")
def test_description(self, mock_rcfg, mock_lcfg): mock_lcfg.__iter__.return_value = ('foo', 'bar') mock_rcfg.__iter__.return_value = ('Foo', 'Bar') mock_lcfg.description.side_effect = lambda name: 'mock description for local setting %s' % name mock_rcfg.description.side_effect = lambda name: 'mock description for remote setting %s' % name settings = candidates.setting_names() self.assertEqual(settings[0].description, 'mock description for local setting bar') self.assertEqual(settings[1].description, 'mock description for local setting foo') self.assertEqual(settings[2].description, 'mock description for remote setting Bar') self.assertEqual(settings[3].description, 'mock description for remote setting Foo')
def test_default(self, mock_rcfg, mock_lcfg): mock_lcfg.__iter__.return_value = ('foo', 'bar') mock_lcfg.default.side_effect = lambda name: 'mock default for local setting %s' % name mock_rcfg.__iter__.return_value = ('FOO', 'BAR') mock_rcfg.default.side_effect = lambda name: 'mock default for remote setting %s' % name cats = candidates.setting_names() self.assertEqual(cats[0][0].info['Default'], 'mock default for local setting bar') self.assertEqual(cats[0][1].info['Default'], 'mock default for local setting foo') self.assertEqual(cats[1][0].info['Default'], 'mock default for remote setting BAR') self.assertEqual(cats[1][1].info['Default'], 'mock default for remote setting FOO')