How to use the dnsimple.DNSimpleException function in dnsimple

To help you get started, we’ve selected a few dnsimple 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 onlyhavecans / dnsimple-python / tests / test_auth.py View on Github external
def test_authentication_with_invalid_credentials_raises(self):
        with pytest.raises(DNSimpleException) as exception:
            client = DNSimple(email='user@host.com', password='bogus')
            client.domains()

        assert 'Authentication failed' in str(exception.value)
github onlyhavecans / dnsimple-python / tests / test_domains.py View on Github external
# Test deleting by ID
        response = client.delete(domain['domain']['id'])

        assert isinstance(response, dict)
        assert len(response) == 0
        assert len(client.domains()) == (domain_count - 2)

        # Ensure deleting non-existent domain by name fails
        with pytest.raises(DNSimpleException) as exception:
            client.delete('unknown.domain')

        assert "Domain `unknown.domain` not found" in str(exception.value)

        # Ensure deleting non-existent domain by ID fails
        with pytest.raises(DNSimpleException) as exception:
            client.delete(9999)

        assert "Domain `9999` not found" in str(exception.value)
github onlyhavecans / dnsimple-python / tests / test_domains.py View on Github external
def test_check_domain(self, client):
        # Ensure invalid domain names cause errors
        with pytest.raises(DNSimpleException) as exception:
            client.check('add.test')

        assert "TLD .TEST is invalid or not supported" in str(exception.value)

        # Check a domain name that is not available
        status = client.check('google.com')

        assert not status['available']

        status = client.check('dnsimple-python-available-domain.com')

        assert status['available']
github onlyhavecans / dnsimple-python / tests / test_records.py View on Github external
def test_find_record(self, domain, client, token_client):
        www = self.find_record(client, domain, 'www')

        # Test finding by record ID
        assert www
        assert client.record(domain['domain']['id'], www['record']['id']) == www
        assert token_client.record(domain['domain']['id'], www['record']['id']) == www

        # Test that finding a non-existent record fails
        with pytest.raises(DNSimpleException) as exception:
            client.record(domain['domain']['id'], 999999)

        assert 'Record `999999` not found' in str(exception.value)
github onlyhavecans / dnsimple-python / tests / test_records.py View on Github external
assert isinstance(record, dict)

        assert record['record']['name']    == 'www'
        assert record['record']['content'] == domain['domain']['name']

        record = token_client.add_record(domain['domain']['id'], {
            'record_type': 'CNAME',
            'name':        'token-cname',
            'content':     'token.{0}'.format(domain['domain']['name'])
        })

        assert record['record']['name'] == 'token-cname'

        # Test adding without parameters causes an error
        with pytest.raises(DNSimpleException) as exception:
            client.add_record(domain['domain']['name'], {})

        assert 'Validation failed' in str(exception.value)

        assert self.record_count(client, domain) == (start_record_count + 4)
github dnsimple / dnsimple-api-examples / python / bad_auth.py View on Github external
If you want to connect to production omit the sandbox option
"""
client = Client(sandbox=True, access_token='fake')

"""
All calls to client pass through a service. In this case, `client.identity` is the identity service

`client.identity.whoami() is the method for retrieving the account details for your
current credentials via the DNSimple API.

In this case the call will fail and raise an exception.
"""
try:
    whoami = client.identity.whoami()
except DNSimpleException as e:
    print(f'Exception Raised= {e.message}')