# Path: armada/api/controller/armada.py
# CONF = cfg.CONF
# class Apply(api.BaseResource):
#     def on_post(self, req, resp):
# 
# Path: armada/common/policies/base.py
# ARMADA = 'armada:%s'
# TILLER = 'tiller:%s'
# RULE_ADMIN_REQUIRED = 'rule:admin_required'
# RULE_ADMIN_OR_TARGET_PROJECT = (
#     'rule:admin_required or project_id:%(target.project.id)s')
# RULE_SERVICE_OR_ADMIN = 'rule:service_or_admin'
# def list_rules():
# 
# Path: armada/tests/test_utils.py
# def rand_uuid_hex():
# def rand_name(name='', prefix='armada'):
# def rand_bool():
# def rand_int(min, max):
# def rand_password(length=15):
# def attr(**kwargs):
#     def decorator(f):
# 
# Path: armada/tests/unit/api/base.py
# class BaseControllerTest(test_base.ArmadaTestCase):
#     def setUp(self):


import json
import mock
from oslo_config import cfg
from armada.api.controller import armada as armada_api
from armada.common.policies import base as policy_base
from armada.tests import test_utils
from armada.tests.unit.api import base
        mock_resolver.resolve_reference.assert_called_with([payload_url])
        mock_armada.assert_called_with([{'foo': 'bar'}],
                                       **expected_armada_options)
        mock_armada.return_value.sync.assert_called()

    def test_armada_apply_no_href(self):
        """Tests /api/v1.0/apply returns 400 when hrefs list is empty."""
        rules = {'armada:create_endpoints': '@'}
        self.policy.set_rules(rules)

        options = {'debug': 'true',
                   'disable_update_pre': 'false',
                   'disable_update_post': 'false',
                   'enable_chart_cleanup': 'false',
                   'skip_pre_flight': 'false',
                   'dry_run': 'false',
                   'wait': 'false',
                   'timeout': '100'}
        payload = {'hrefs': []}
        body = json.dumps(payload)

        result = self.app.simulate_post(path='/api/v1.0/apply',
                                        body=body,
                                        headers={
                                            'Content-Type': 'application/json'
                                        },
                                        params=options)
        self.assertEqual(result.status_code, 400)



# Path: armada/api/controller/armada.py
# CONF = cfg.CONF
# class Apply(api.BaseResource):
#     def on_post(self, req, resp):
# 
# Path: armada/common/policies/base.py
# ARMADA = 'armada:%s'
# TILLER = 'tiller:%s'
# RULE_ADMIN_REQUIRED = 'rule:admin_required'
# RULE_ADMIN_OR_TARGET_PROJECT = (
#     'rule:admin_required or project_id:%(target.project.id)s')
# RULE_SERVICE_OR_ADMIN = 'rule:service_or_admin'
# def list_rules():
# 
# Path: armada/tests/test_utils.py
# def rand_uuid_hex():
# def rand_name(name='', prefix='armada'):
# def rand_bool():
# def rand_int(min, max):
# def rand_password(length=15):
# def attr(**kwargs):
#     def decorator(f):
# 
# Path: armada/tests/unit/api/base.py
# class BaseControllerTest(test_base.ArmadaTestCase):
#     def setUp(self):


# Path: armada/tests/unit/api/test_armada_controller.py
import json
import mock
from oslo_config import cfg
from armada.api.controller import armada as armada_api
from armada.common.policies import base as policy_base
from armada.tests import test_utils
from armada.tests.unit.api import base

        mock_resolver.resolve_reference.assert_called_with([payload_url])
        mock_armada.assert_called_with([{'foo': 'bar'}],
                                       **expected_armada_options)
        mock_armada.return_value.sync.assert_called()

    def test_armada_apply_no_href(self):
        """Tests /api/v1.0/apply returns 400 when hrefs list is empty."""
        rules = {'armada:create_endpoints': '@'}
        self.policy.set_rules(rules)

        options = {'debug': 'true',
                   'disable_update_pre': 'false',
                   'disable_update_post': 'false',
                   'enable_chart_cleanup': 'false',
                   'skip_pre_flight': 'false',
                   'dry_run': 'false',
                   'wait': 'false',
                   'timeout': '100'}
        payload = {'hrefs': []}
        body = json.dumps(payload)

        result = self.app.simulate_post(path='/api/v1.0/apply',
                                        body=body,
                                        headers={
                                            'Content-Type': 'application/json'
                                        },
                                        params=options)
        self.assertEqual(result.status_code, 400)



class ArmadaControllerNegativeTest(base.BaseControllerTest):