How to use the passivetotal.common.exceptions.INVALID_VALUE_TYPE function in passivetotal

To help you get started, we’ve selected a few passivetotal 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 passivetotal / python_api / tests / test_actions.py View on Github external
def test_tags(self):
        """Test various actions for tags."""
        payload = {'query': 'passivetotal.org'}
        response = self.client.get_tags(**payload)
        assert (response['tags'])
        assert ('security' in response['tags'])

        payload = {'query': 'passivetotal.org', 'tags': 'vendor,security'}
        response = self.client.add_tags(**payload)
        assert (response['tags'])
        response = self.client.remove_tags(**payload)
        assert (response['tags'])
        response = self.client.set_tags(**payload)
        assert (response['tags'])

        with pytest.raises(INVALID_VALUE_TYPE) as excinfo:
            def invalid_field():
                payload = {'query': 'passivetotal.org', 'tags': {}}
                self.client.add_tags(**payload)
            invalid_field()
        assert 'must be a list' in str(excinfo.value)
github passivetotal / python_api / tests / test_actions.py View on Github external
assert (response['classification']) == 'non-malicious'

        payload = {'query': 'passivetotal.org',
                   'classification': 'non-malicious'}
        response = self.client.set_classification_status(**payload)
        assert (response['classification']) == 'non-malicious'

        with pytest.raises(MISSING_FIELD) as excinfo:
            def missing_field():
                payload = {'query': 'passivetotal.org',
                           'no-classification': 'unknown'}
                self.client.set_classification_status(**payload)
            missing_field()
        assert 'field is required' in str(excinfo.value)

        with pytest.raises(INVALID_VALUE_TYPE) as excinfo:
            def invalid_field():
                payload = {'query': 'passivetotal.org', 'classification': '_'}
                self.client.set_classification_status(**payload)
            invalid_field()
        assert 'must be one of the following' in str(excinfo.value)
github passivetotal / python_api / passivetotal / libs / actions.py View on Github external
def add_tags(self, **kwargs):
        if type(kwargs['tags']) == str:
            kwargs['tags'] = [x.strip() for x in kwargs['tags'].split(',')]
        if type(kwargs['tags']) != list:
            raise INVALID_VALUE_TYPE("Tags must be a list.")
        data = {'tags': list(set(kwargs['tags'])), 'query': kwargs['query']}
        return self._send_data('PUT', ACTIONS, ACTIONS_TAG, data)
github passivetotal / python_api / passivetotal / libs / actions.py View on Github external
def set_tags(self, **kwargs):
        if type(kwargs['tags']) == str:
            kwargs['tags'] = [x.strip() for x in kwargs['tags'].split(',')]
        if type(kwargs['tags']) != list:
            raise INVALID_VALUE_TYPE("Tags must be a list.")
        data = {'tags': list(set(kwargs['tags'])), 'query': kwargs['query']}
        return self._send_data('POST', ACTIONS, ACTIONS_TAG, data)
github passivetotal / python_api / passivetotal / libs / actions.py View on Github external
def remove_tags(self, **kwargs):
        if type(kwargs['tags']) == str:
            kwargs['tags'] = [x.strip() for x in kwargs['tags'].split(',')]
        if type(kwargs['tags']) != list:
            raise INVALID_VALUE_TYPE("Tags must be a list.")
        data = {'tags': list(set(kwargs['tags'])), 'query': kwargs['query']}
        return self._send_data('DELETE', ACTIONS, ACTIONS_TAG, data)
github passivetotal / python_api / passivetotal / libs / actions.py View on Github external
def set_classification_status(self, **kwargs):
        if 'classification' not in kwargs:
            raise MISSING_FIELD("Classification field is required.")
        if kwargs['classification'] not in CLASSIFICATION_VALID_VALUES:
            raise INVALID_VALUE_TYPE("Value must be one of the following: %s"
                                     % ', '.join(CLASSIFICATION_VALID_VALUES))
        data = {'classification': kwargs['classification'],
                'query': kwargs['query']}
        return self._send_data('POST', ACTIONS, ACTIONS_CLASSIFICATION, data)