How to use the towerlib.towerlibexceptions.InvalidValue function in towerlib

To help you get started, we’ve selected a few towerlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github schubergphilis / towerlib / tests / integration / test_team.py View on Github external
def test_mutating_name(self):
        with self.recorder:

            with self.assertRaises(InvalidValue):
                self.team.name = 'a' * 513
            original_name = self.team.name
            self.team.name = 'valid_name'
            self.assertEqual(self.team.name, 'valid_name')
            self.team.name = original_name
            self.assertEqual(self.team.name, original_name)
github schubergphilis / towerlib / towerlib / entities / project.py View on Github external
def name(self, value):
        """Update the name of the project.

        Returns:
            None:

        """
        max_characters = 512
        conditions = [validate_max_length(value, max_characters)]
        if all(conditions):
            self._update_values('name', value)
        else:
            raise InvalidValue('{value} is invalid. Condition max_characters must be less than or equal to '
                               '{max_characters}'.format(value=value, max_characters=max_characters))
github schubergphilis / towerlib / towerlib / entities / host.py View on Github external
def instance_id(self, value):
        """Update the instance_id of the host.

        Returns:
            None:

        """
        max_characters = 1024
        conditions = [validate_max_length(value, max_characters)]
        if all(conditions):
            self._update_values('instance_id', value)
        else:
            raise InvalidValue('{value} is invalid. Condition max_characters must be less than or equal to '
                               '{max_characters}'.format(value=value, max_characters=max_characters))
github schubergphilis / towerlib / towerlib / entities / user.py View on Github external
def email(self, value):
        """Update the email address of the user.

        Returns:
            None:

        """
        max_characters = 254
        conditions = [validate_max_length(value, max_characters)]
        if all(conditions):
            self._update_values('email', value)
        else:
            raise InvalidValue('{value} is invalid. Condition max_characters must be less or equal to '
                               '{max_characters}'.format(value=value, max_characters=max_characters))
github schubergphilis / towerlib / towerlib / entities / credential.py View on Github external
def inputs(self, value):
        """Update the inputs of the credential type.

        Returns:
            None:

        """
        if isinstance(value, dict):
            self._update_values('inputs', value)
        else:
            raise InvalidValue('Value is not valid dictionary received: {value}'.format(value=value))
github schubergphilis / towerlib / towerlib / entities / host.py View on Github external
def variables(self, value):
        """Update the variables on the host.

        Returns:
            None:

        """
        conditions = [validate_json(value)]
        if all(conditions):
            self._update_values('variables', value)
        else:
            raise InvalidValue(
                '{value} is not valid json.'.format(value=value))
github schubergphilis / towerlib / towerlib / entities / organization.py View on Github external
def name(self, value):
        """Update the name of the organization.

        Returns:
            None:

        """
        max_characters = 512
        conditions = [validate_max_length(value, max_characters)]
        if all(conditions):
            self._update_values('name', value)
        else:
            raise InvalidValue('{value} is invalid. Condition max_characters must be less than or equal to '
                               '{max_characters}'.format(value=value, max_characters=max_characters))
github schubergphilis / towerlib / towerlib / entities / user.py View on Github external
def last_name(self, value):
        """Update the last name of the user.

        Returns:
            None:

        """
        max_characters = 30
        conditions = [validate_max_length(value, max_characters)]
        if all(conditions):
            self._update_values('last_name', value)
        else:
            raise InvalidValue(value)
github schubergphilis / towerlib / towerlib / entities / project.py View on Github external
def local_path(self, value):
        """Update the internal local path of the project.

        Returns:
            None:

        """
        max_characters = 1024
        conditions = [validate_max_length(value, max_characters)]
        if all(conditions):
            self._update_values('local_path', value)
        else:
            raise InvalidValue('{value} is invalid. Condition max_characters must be less than or equal to '
                               '{max_characters}'.format(value=value, max_characters=max_characters))
github schubergphilis / towerlib / towerlib / entities / project.py View on Github external
def scm_update_cache_timeout(self, value):
        """Update the scm_update_cache_timeout of the project.

        Returns:
            None:

        """
        minimum = 0
        maximum = 2147483647
        conditions = [validate_range(value, minimum, maximum)]
        if all(conditions):
            self._update_values('scm_update_cache_timeout', value)
        else:
            raise InvalidValue('{value} is invalid, must be between {minimum} and {maximum}'.format(value=value,
                                                                                                    minimum=minimum,
                                                                                                    maximum=maximum))