コード例 #1
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')
コード例 #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')
コード例 #4
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')
コード例 #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')
コード例 #6
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")
コード例 #7
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')
コード例 #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')
コード例 #9
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)
コード例 #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()
コード例 #12
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")
コード例 #13
0
    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')
コード例 #15
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')
コード例 #16
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')
コード例 #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
コード例 #24
0
 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