Exemple #1
0
class SpecAvailableActions(Spec):
    """ Get Available Actions Dictionary"""

    def setup(self):
        self.plugins = [NovaSoftReboot()]
        self.resource = AvailableActionsResource()

    def _check_for_one_element(self, body):
        available_actions = body.get('available_actions')

        assert available_actions is not None
        assert len(available_actions) == 1
        assert available_actions[0] == 'nova-soft-reboot'

    def it_should_handle_a_list_with_a_valid_plugin(self):
        body = self.resource.get_available_actions_dict(self.plugins)
        self._check_for_one_element(body)

    def it_should_not_contain_duplicates(self):
        bad_list = [NovaSoftReboot(), NovaSoftReboot()]
        body = self.resource.get_available_actions_dict(bad_list)

        self._check_for_one_element(body)

    def it_should_not_contain_non_plugin_types(self):
        bad_list = [NovaSoftReboot(), 'bam']
        body = self.resource.get_available_actions_dict(bad_list)

        self._check_for_one_element(body)
Exemple #2
0
class SpecAvailableActions(Spec):
    """ Get Available Actions Dictionary"""
    def setup(self):
        self.plugins = [NovaSoftReboot()]
        self.resource = AvailableActionsResource()

    def _check_for_one_element(self, body):
        available_actions = body.get('available_actions')

        assert available_actions is not None
        assert len(available_actions) == 1
        assert available_actions[0] == 'nova-soft-reboot'

    def it_should_handle_a_list_with_a_valid_plugin(self):
        body = self.resource.get_available_actions_dict(self.plugins)
        self._check_for_one_element(body)

    def it_should_not_contain_duplicates(self):
        bad_list = [NovaSoftReboot(), NovaSoftReboot()]
        body = self.resource.get_available_actions_dict(bad_list)

        self._check_for_one_element(body)

    def it_should_not_contain_non_plugin_types(self):
        bad_list = [NovaSoftReboot(), 'bam']
        body = self.resource.get_available_actions_dict(bad_list)

        self._check_for_one_element(body)
Exemple #3
0
class AvailableActions(Spec):
    """ Get Available Actions Dictionary"""
    ACTIONS = ['nova-soft-reboot', 'echo-sample']

    def before_each(self):
        self.plugins = [NovaSoftReboot(), EchoPlugin()]
        self.resource = AvailableActionsResource(
            action_plugins_list=self.plugins)

    def _check_for_attributes(self, body, expected_action_names=[]):
        available_actions = body.get('available_actions')

        expect(available_actions).not_to.be_none()
        expect(len(available_actions)).to.equal(len(expected_action_names))
        for expected_action in expected_action_names:
            expect(expected_action).to.be_in(available_actions)

    def should_handle_a_list_with_a_valid_plugin(self):
        body = self.resource.get_available_actions_dict(self.plugins)
        self._check_for_attributes(body, self.ACTIONS)

    def should_not_contain_duplicates(self):
        bad_list = [NovaSoftReboot(), NovaSoftReboot(), EchoPlugin()]
        body = self.resource.get_available_actions_dict(bad_list)

        self._check_for_attributes(body, self.ACTIONS)

    def should_not_contain_non_plugin_types(self):
        bad_list = [NovaSoftReboot(), EchoPlugin(), 'bam']
        body = self.resource.get_available_actions_dict(bad_list)

        self._check_for_attributes(body, self.ACTIONS)