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')
예제 #2
0
    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'))
예제 #3
0
    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_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')
예제 #5
0
    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')
예제 #8
0
 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)
예제 #10
0
    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()
예제 #11
0
    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')
예제 #14
0
    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_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')
예제 #17
0
 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')
예제 #18
0
 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])
예제 #19
0
    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'))
예제 #20
0
    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
예제 #21
0
 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
예제 #22
0
 def zookeeper_discovery_path(self):
     return staticconf.get('zookeeper_discovery_path').value
예제 #23
0
 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')
예제 #25
0
 def changelog_schemaname(self):
     return staticconf.get('changelog_schemaname').value
예제 #26
0
 def team_name(self):
     return staticconf.get('team_name').value
예제 #27
0
 def container_env(self):
     return os.environ.get(
         'PAASTA_CLUSTER',
         staticconf.get('container_env').value
     )
예제 #28
0
 def pii_yaml_path(self):
     return staticconf.get('pii_yaml_path').value
예제 #29
0
 def topology_path(self):
     return staticconf.get('topology_path').value
예제 #30
0
 def changelog_mode(self):
     return staticconf.get('changelog_mode', False).value
예제 #31
0
 def disable_sensu(self):
     return staticconf.get('disable_sensu').value
예제 #32
0
 def schema_blacklist(self):
     return staticconf.get('schema_blacklist').value
예제 #33
0
 def disable_meteorite(self):
     return staticconf.get('disable_meteorite').value
예제 #34
0
 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
예제 #35
0
 def container_name(self):
     return os.environ.get(
         'PAASTA_INSTANCE',
         staticconf.get('container_name').value
     )
예제 #36
0
 def test_init(self):
     with testing.MockConfiguration(a='one', b='two'):
         assert_equal(staticconf.get('a'), 'one')
         assert_equal(staticconf.get('b'), 'two')
예제 #37
0
 def max_delay_allowed_in_seconds(self):
     return staticconf.get('max_delay_allowed_in_seconds').value
예제 #38
0
 def table_whitelist(self):
     return staticconf.get('table_whitelist', default=None).value
예제 #39
0
 def namespace(self):
     return staticconf.get('namespace').value
예제 #40
0
 def schema_tracker_cluster(self):
     """serves as the key to identify the tracker database in topology.yaml
     """
     return staticconf.get('schema_tracker_cluster').value
예제 #41
0
 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