# Copyright 2013 Big Switch Networks Inc.
# All Rights Reserved
#
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
#    not use this file except in compliance with the License. You may obtain
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.
#
# @author: KC Wang, Big Switch Networks Inc.
#
# vim: tabstop=4 shiftwidth=4 softtabstop=4

import sys

import mox

from neutronclient.neutron.v2_0.fw import firewallpolicy
from neutronclient import shell
from neutronclient.tests.unit import test_cli20


class CLITestV20FirewallPolicyJSON(test_cli20.CLITestV20Base):
    def setUp(self):
        super(CLITestV20FirewallPolicyJSON, self).setUp()

    def test_create_firewall_policy_with_mandatory_params(self):
        """firewall-policy-create with mandatory (none) params only."""
        resource = 'firewall_policy'
        cmd = firewallpolicy.CreateFirewallPolicy(test_cli20.MyApp(sys.stdout),
                                                  None)
        tenant_id = 'my-tenant'
        name = 'my-name'
        my_id = 'myid'
        args = ['--tenant-id', tenant_id,
                '--admin-state_up',
                name, ]
        position_names = ['name', ]
        position_values = [name, ]
        self._test_create_resource(resource, cmd, name, my_id, args,
                                   position_names, position_values,
                                   admin_state_up=True, tenant_id=tenant_id)

    def test_create_firewall_policy_with_all_params(self):
        """firewall-policy-create with all params set."""
        resource = 'firewall_policy'
        cmd = firewallpolicy.CreateFirewallPolicy(test_cli20.MyApp(sys.stdout),
                                                  None)
        name = 'my-name'
        description = 'my-desc'
        firewall_rules_arg = 'rule_id1 rule_id2'
        firewall_rules_res = ['rule_id1', 'rule_id2']
        tenant_id = 'my-tenant'
        my_id = 'myid'
        args = ['--description', description,
                '--shared',
                '--firewall-rules', firewall_rules_arg,
                '--audited',