31
31
"""Return a manually made list of blocks and their status
33
33
:param client: The client whose rules will be used.
34
:param disabled_commands: list of client.disable_command_* elements to
34
:param disabled_commands: list of client.command_set_* elements to
35
35
include in simulated output.
37
if client.is_juju1x():
37
if isinstance(client, EnvJujuClient1X):
40
EnvJujuClient1X.disable_command_destroy_model,
41
EnvJujuClient1X.disable_command_remove_object,
42
EnvJujuClient1X.disable_command_all]
40
client.command_set_destroy_model,
41
client.command_set_remove_object,
42
client.command_set_all]
43
43
for command in commands:
44
44
if command in disabled_commands:
84
84
client.disable_command(client.destroy_model_command)
85
85
block_list = client.list_disabled_commands()
86
86
if block_list != make_block_list(
87
client, [client.disable_command_destroy_model]):
87
client, [client.command_set_destroy_model]):
88
88
raise JujuAssertionError(block_list)
90
90
client, client.destroy_model_command,
100
100
objects can be added and related, but they
101
101
cannot be removed or the model/environment deleted.
103
client.disable_command(client.disable_command_remove_object)
103
client.disable_command(client.command_set_remove_object)
104
104
block_list = client.list_disabled_commands()
105
105
if block_list != make_block_list(
106
client, [client.disable_command_remove_object]):
106
client, [client.command_set_remove_object]):
107
107
raise JujuAssertionError(block_list)
109
109
client, client.destroy_model_command,
118
118
def assess_block_all_changes(client, charm_series):
119
119
"""Test Block Functionality: block all-changes"""
120
120
client.juju('remove-relation', ('dummy-source', 'dummy-sink'))
121
client.disable_command(client.disable_command_all)
121
client.disable_command(client.command_set_all)
122
122
block_list = client.list_disabled_commands()
123
if block_list != make_block_list(client, [client.disable_command_all]):
123
if block_list != make_block_list(client, [client.command_set_all]):
124
124
raise JujuAssertionError(block_list)
125
125
test_disabled(client, 'add-relation', ('dummy-source', 'dummy-sink'))
126
126
test_disabled(client, 'unexpose', ('dummy-sink',))
127
127
test_disabled(client, 'remove-service', 'dummy-sink')
128
client.enable_command(client.disable_command_all)
128
client.enable_command(client.command_set_all)
129
129
client.juju('unexpose', ('dummy-sink',))
130
client.disable_command(client.disable_command_all)
130
client.disable_command(client.command_set_all)
131
131
test_disabled(client, 'expose', ('dummy-sink',))
132
client.enable_command(client.disable_command_all)
132
client.enable_command(client.command_set_all)
133
133
client.remove_service('dummy-sink')
134
134
client.wait_for_started()
135
client.disable_command(client.disable_command_all)
135
client.disable_command(client.command_set_all)
136
136
test_disabled(client, 'deploy', ('dummy-sink',))
138
138
client, client.destroy_model_command,
168
168
assess_block_destroy_model(client, charm_series)
169
169
assess_unblock(client, client.destroy_model_command)
170
170
assess_block_remove_object(client, charm_series)
171
assess_unblock(client, client.disable_command_remove_object)
171
assess_unblock(client, client.command_set_remove_object)
172
172
assess_block_all_changes(client, charm_series)
173
assess_unblock(client, client.disable_command_all)
173
assess_unblock(client, client.command_set_all)
174
174
log.info('Test PASS')