def test_haproxy_action_unexpected_status(self, mock): mock(None, None).status.side_effect = lambda backend, server: { 'status': 'MAINT' } with self.assertRaises(execution.UnexpectedHAproxyServerStatus): execution.haproxy_action( "fr-hq-vip-01", ["BACKEND,SERVER-01", "BACKEND,SERVER-02"], "secret", "UP", execution.HAProxyAction.ENABLE)
def test_haproxy_action_enable(self, mock): mock(None, None).status.side_effect = lambda backend, server: { 'status': 'MAINT' } mock(None, None).enable.side_effect = lambda backend, server: "OK" execution.haproxy_action("fr-hq-vip-01", ["BACKEND,SERVER-01", "BACKEND,SERVER-02"], "secret", "MAINT", execution.HAProxyAction.ENABLE)
def test_haproxy_action_unnormalized_keys(self, mock): with self.assertRaises(execution.InvalidHAProxyKeyFormat): execution.haproxy_action("fr-hq-vip-01", ["BADKEY"], "secret", "UP", execution.HAProxyAction.DISABLE)