Exemplo n.º 1
0
 def test_set_no_regions(self, config_proxy, global_state):
     config_proxy.get_cloud.return_value = {}
     state = {
         'cloud': 'foo',
     }
     global_state.__getitem__ = state.__getitem__
     with pytest.raises(ConfigurationError):
         set_cloud('foo')
Exemplo n.º 2
0
 def test_set_no_regions(self, config_proxy, global_state):
     config_proxy.CLOUD = {}
     state = {
         'cloud': 'foo',
     }
     global_state.__getitem__ = state.__getitem__
     with pytest.raises(ConfigurationError):
         set_cloud('foo')
Exemplo n.º 3
0
 def test_set_regions_not_iterable(self, config_proxy, global_state):
     config_proxy.CLOUD = {
         'REGIONS': 0,
     }
     state = {
         'cloud': 'foo',
     }
     global_state.__getitem__ = state.__getitem__
     with pytest.raises(ConfigurationError):
         set_cloud('foo')
Exemplo n.º 4
0
 def test_set_empty_regions(self, config_proxy, global_state):
     config_proxy.get_cloud.return_value = {
         'REGIONS': [],
     }
     state = {
         'cloud': 'foo',
     }
     global_state.__getitem__ = state.__getitem__
     with pytest.raises(ConfigurationError):
         set_cloud('foo')
Exemplo n.º 5
0
    def test_set(self, config_proxy, global_state):
        config_proxy.CLOUD = {
            'REGIONS': ['region1', 'region2'],
        }
        state = {
            'cloud': 'foo',
        }
        global_state.__getitem__ = state.__getitem__
        set_cloud('foo')

        calls = [
            call('cloud', 'foo'),
            call('region', 'region1'),
        ]
        assert_has_calls(global_state.__setitem__, calls)
Exemplo n.º 6
0
    def test_set(self, config_proxy, global_state):
        config_proxy.get_cloud.return_value = {
            'REGIONS': ['region1', 'region2'],
        }
        state = {
            'cloud': 'foo',
        }

        global_state.__getitem__ = state.__getitem__

        set_cloud('foo')

        calls = [
            call('cloud', 'foo'),
            call('region', 'region1'),
        ]
        assert_has_calls(global_state.__setitem__, calls)
Exemplo n.º 7
0
 def test_noop(self, config_proxy, global_state):
     set_cloud(None)
     assert global_state.__getitem__.call_count == 0
Exemplo n.º 8
0
 def test_noop(self, config_proxy, global_state):
     set_cloud(None)
     assert global_state.__getitem__.call_count == 0