def test_nested(self): with testing.MockConfiguration(a='one', b='two'): with testing.PatchConfiguration(a='three'): assert_equal(staticconf.get('a'), 'three') assert_equal(staticconf.get('b'), 'two') assert_equal(staticconf.get('a'), 'one') assert_equal(staticconf.get('b'), 'two')
def test_mock_configuration_context_manager(self): one = staticconf.get('one') three = staticconf.get_int('three', default=3) with testing.MockConfiguration(dict(one=7)): assert_equal(one, 7) assert_equal(three, 3) assert_raises(errors.ConfigurationError, staticconf.get('one'))
def test_reload_default(self): staticconf.DictConfiguration(dict(one='three', seven='nine')) one, seven = staticconf.get('one'), staticconf.get('seven') staticconf.DictConfiguration(dict(one='ten', seven='el')) staticconf.reload() assert_equal(one, 'ten') assert_equal(seven, 'el')
def test_reload_default(self): staticconf.DictConfiguration(dict(one="three", seven="nine")) one, seven = staticconf.get("one"), staticconf.get("seven") staticconf.DictConfiguration(dict(one="ten", seven="el")) staticconf.reload() assert_equal(one, "ten") assert_equal(seven, "el")
def test_init_nested(self): conf = { 'a': { 'b': 'two', }, 'c': 'three' } with testing.MockConfiguration(conf): assert_equal(staticconf.get('a.b'), 'two') assert_equal(staticconf.get('c'), 'three')
def test_load_and_validate(self): staticconf.DictConfiguration(self.config) some_class = SomeClass() assert_equal(some_class.max, 100) assert_equal(some_class.min, 0) assert_equal(some_class.ratio, 7.7) assert_equal(some_class.alt_ratio, 6.0) assert_equal(staticconf.get("globals"), False) assert_equal(staticconf.get("enable"), "True") assert_equal(staticconf.get_bool("enable"), True)
def test_load_end_to_end(self): loader = staticconf.YamlConfiguration callback = mock.Mock() facade = staticconf.ConfigFacade.load(self.file.name, self.namespace, loader) facade.add_callback('one', callback) assert_equal(staticconf.get('one', namespace=self.namespace), "A") self.write(b"one: B", 10) facade.reload_if_changed() assert_equal(staticconf.get('one', namespace=self.namespace), "B") callback.assert_called_with()
def test_load_end_to_end(self): loader = staticconf.YamlConfiguration callback = mock.Mock() facade = staticconf.ConfigFacade.load(self.file.name, self.namespace, loader) facade.add_callback('one', callback) assert_equal(staticconf.get('one', namespace=self.namespace), "A") self.write("""one: B""") facade.reload_if_changed() assert_equal(staticconf.get('one', namespace=self.namespace), "B") callback.assert_called_with()
def test_reload_single(self): name = "another_one" staticconf.DictConfiguration(dict(one="three")) staticconf.DictConfiguration(dict(two="three"), namespace=name) one, two = staticconf.get("one"), staticconf.get("two", namespace=name) # access the values to set the value_proxy cache one.value, two.value staticconf.DictConfiguration(dict(one="four")) staticconf.DictConfiguration(dict(two="five"), namespace=name) staticconf.reload() assert_equal(one, "four") assert_equal(two, "three")
def test_reload_all(self): name = 'another_one' staticconf.DictConfiguration(dict(one='three')) staticconf.DictConfiguration(dict(two='three'), namespace=name) one, two = staticconf.get('one'), staticconf.get('two', namespace=name) # access the values to set the value_proxy cache _ = bool(one), bool(two) staticconf.DictConfiguration(dict(one='four')) staticconf.DictConfiguration(dict(two='five'), namespace=name) staticconf.reload(all_names=True) assert_equal(one, 'four') assert_equal(two, 'five')
def test_reload_single(self): name = 'another_one' staticconf.DictConfiguration(dict(one='three')) staticconf.DictConfiguration(dict(two='three'), namespace=name) one, two = staticconf.get('one'), staticconf.get('two', namespace=name) # access the values to set the value_proxy cache one.value, two.value staticconf.DictConfiguration(dict(one='four')) staticconf.DictConfiguration(dict(two='five'), namespace=name) staticconf.reload() assert_equal(one, 'four') assert_equal(two, 'three')
def setup_descriptions(self): staticconf.get('one', help="the one") staticconf.get_time('when', default='NOW', help="The time") staticconf.get_bool('you sure', default='No', help='Are you?') staticconf.get('one', help="the one", namespace='Beta') staticconf.get('one', help="the one", namespace='Alpha') staticconf.get('two', help="the two", namespace='Alpha')
def test_load_and_validate(self): staticconf.DictConfiguration(self.config) some_class = SomeClass() assert_equal(some_class.max, 100) assert_equal(some_class.min, 0) assert_equal(some_class.ratio, 7.7) assert_equal(some_class.alt_ratio, 6.0) assert_equal(staticconf.get('globals'), False) assert_equal(staticconf.get('enable'), 'True') assert_equal(staticconf.get_bool('enable'), True) assert_equal(some_class.msg, None) assert staticconf.get_regex('matcher').match('12345') assert not staticconf.get_regex('matcher').match('a') assert_equal(staticconf.get_list_of_int('options'), [1, 7, 3, 9])
def test_mock_configuration(self): two = staticconf.get_string('two') stars = staticconf.get_bool('stars') mock_config = testing.MockConfiguration(dict(two=2, stars=False)) mock_config.setup() assert_equal(two, '2') assert not stars mock_config.teardown() assert_raises(errors.ConfigurationError, staticconf.get('two'))
def rbr_source_cluster_topology_name(self): """Serves as the key to identify the source database in topology.yaml if given. This value should usually not be provided, so the Replication Handler will default to using rbr_source_cluster as both the name of the connection, and the topology key. This option is useful when re-parenting a replication handler, since it can point the rbr_source at a different database in the topology, while still treating it as the same virutal cluster. """ return staticconf.get('rbr_source_cluster_topology_name', default=None).value
def sensu_host(self): """If we're running in Paasta, use the paasta cluster from the environment directly as laid out in PAASTA-1579. This makes it so that local-run and real sensu alerts go to the same cluster, which should prevent false alerts that never resolve when we run locally. """ if os.environ.get('PAASTA_CLUSTER'): return "paasta-{cluster}.yelp".format( cluster=os.environ.get('PAASTA_CLUSTER') ) else: return staticconf.get('sensu_host').value
def zookeeper_discovery_path(self): return staticconf.get('zookeeper_discovery_path').value
def producer_name(self): return staticconf.get('producer_name').value
def test_init(self): with testing.MockConfiguration(a='one', b='two'): assert_equal(staticconf.get('a'), 'one') assert_equal(staticconf.get('b'), 'two')
def changelog_schemaname(self): return staticconf.get('changelog_schemaname').value
def team_name(self): return staticconf.get('team_name').value
def container_env(self): return os.environ.get( 'PAASTA_CLUSTER', staticconf.get('container_env').value )
def pii_yaml_path(self): return staticconf.get('pii_yaml_path').value
def topology_path(self): return staticconf.get('topology_path').value
def changelog_mode(self): return staticconf.get('changelog_mode', False).value
def disable_sensu(self): return staticconf.get('disable_sensu').value
def schema_blacklist(self): return staticconf.get('schema_blacklist').value
def disable_meteorite(self): return staticconf.get('disable_meteorite').value
def recovery_queue_size(self): # The recovery queue size have to be greater than data pipeline producer # buffer size, otherwise we could potentially have stale checkpoint data which # would cause the recovery process to fail. return staticconf.get('recovery_queue_size').value
def container_name(self): return os.environ.get( 'PAASTA_INSTANCE', staticconf.get('container_name').value )
def max_delay_allowed_in_seconds(self): return staticconf.get('max_delay_allowed_in_seconds').value
def table_whitelist(self): return staticconf.get('table_whitelist', default=None).value
def namespace(self): return staticconf.get('namespace').value
def schema_tracker_cluster(self): """serves as the key to identify the tracker database in topology.yaml """ return staticconf.get('schema_tracker_cluster').value
def rbr_source_cluster(self): """serves as the key to identify the source database in topology.yaml if rbr_source_cluster_topology_name isn't given, and is used to identify the cluster in message namespaces and stats. """ return staticconf.get('rbr_source_cluster').value