Example #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')
Example #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')
Example #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')
Example #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')
Example #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)
Example #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)
Example #7
0
 def test_noop(self, config_proxy, global_state):
     set_cloud(None)
     assert global_state.__getitem__.call_count == 0
Example #8
0
 def test_noop(self, config_proxy, global_state):
     set_cloud(None)
     assert global_state.__getitem__.call_count == 0