# Path: openprovider/api.py
# def api_factory(account=''):
#     username = _get_env('username', account)
#     try:
#         password_hash = _get_env('password_hash', account)
#         password = None
#     except KeyError:
#         password_hash = None
#         password = _get_env('password', account)
#     url = os.environ.get('OPENPROVIDER_URL', 'https://api.openprovider.eu')
# 
#     return OpenProvider(username=username, password=password, password_hash=password_hash, url=url)
# 
# Path: openprovider/models.py
# class Nameserver(Model):
#     """
#     A nameserver with either an IPv4 or an IPv6 address.
# 
#     name (required)
#         URI or hostname of the nameserver
#     ip (required if no valid ip6)
#         IPv4 address of the nameserver
#     ip6 (required if no valid ip)
#         IPv6 address of the nameserver
#     """
# 
#     def __str__(self):
#         return str(self.name)
# 
# Path: tests/api_tests.py
# def configure_betamax(api, **additional_apis):
#     with Betamax.configure() as config:
#         config.cassette_library_dir = 'tests/fixtures/cassettes'
#         config.default_cassette_options['match_options'] = ['method', 'uri', 'body']
# 
#         def _set_api(api, template):
#             for attr in ('username', 'password', 'password_hash'):
#                 value = getattr(api, attr, None)
#                 if value:
#                     config.define_cassette_placeholder(template % attr.upper(), value)
# 
#         # Configure primary API
#         config.define_cassette_placeholder('<URL>', api.url)
#         _set_api(api, '<%s>')
#         # placeholders aren't replaced in gzipped responses
#         api.session.headers['Accept-Encoding'] = ''
# 
#         # Any additional APIs
#         for name, api in additional_apis.items():
#             template = '<' + name.upper() + '_%s>' if name else '<%s>'
#             _set_api(api, template)
#             # placeholders aren't replaced in gzipped responses
#             api.session.headers['Accept-Encoding'] = ''


import pytest
import uuid
from openprovider.api import api_factory
from openprovider.models import Nameserver
from .api_tests import configure_betamax
from __future__ import absolute_import




@pytest.fixture
def api():
    api = api_factory('test')
    configure_betamax(api)
    return api


@pytest.fixture
def domainname(sld=None, tld='nl'):
    """Generate a psuedorandom domain name."""
    if sld is None:
        sld = uuid.uuid4()
    return 'ci-%s.%s' % (sld, tld)


@pytest.fixture
def nameservers():
    """Return the name servers for example.com."""
    return [
        Nameserver(name='a.iana-servers.net', ip='199.43.132.53', ip6='2001:500:8c::53'),

# Path: openprovider/api.py
# def api_factory(account=''):
#     username = _get_env('username', account)
#     try:
#         password_hash = _get_env('password_hash', account)
#         password = None
#     except KeyError:
#         password_hash = None
#         password = _get_env('password', account)
#     url = os.environ.get('OPENPROVIDER_URL', 'https://api.openprovider.eu')
# 
#     return OpenProvider(username=username, password=password, password_hash=password_hash, url=url)
# 
# Path: openprovider/models.py
# class Nameserver(Model):
#     """
#     A nameserver with either an IPv4 or an IPv6 address.
# 
#     name (required)
#         URI or hostname of the nameserver
#     ip (required if no valid ip6)
#         IPv4 address of the nameserver
#     ip6 (required if no valid ip)
#         IPv6 address of the nameserver
#     """
# 
#     def __str__(self):
#         return str(self.name)
# 
# Path: tests/api_tests.py
# def configure_betamax(api, **additional_apis):
#     with Betamax.configure() as config:
#         config.cassette_library_dir = 'tests/fixtures/cassettes'
#         config.default_cassette_options['match_options'] = ['method', 'uri', 'body']
# 
#         def _set_api(api, template):
#             for attr in ('username', 'password', 'password_hash'):
#                 value = getattr(api, attr, None)
#                 if value:
#                     config.define_cassette_placeholder(template % attr.upper(), value)
# 
#         # Configure primary API
#         config.define_cassette_placeholder('<URL>', api.url)
#         _set_api(api, '<%s>')
#         # placeholders aren't replaced in gzipped responses
#         api.session.headers['Accept-Encoding'] = ''
# 
#         # Any additional APIs
#         for name, api in additional_apis.items():
#             template = '<' + name.upper() + '_%s>' if name else '<%s>'
#             _set_api(api, template)
#             # placeholders aren't replaced in gzipped responses
#             api.session.headers['Accept-Encoding'] = ''


# Path: tests/conftest.py
import pytest
import uuid
from openprovider.api import api_factory
from openprovider.models import Nameserver
from .api_tests import configure_betamax

from __future__ import absolute_import




@pytest.fixture
def api():
    api = api_factory('test')
    configure_betamax(api)
    return api


@pytest.fixture
def domainname(sld=None, tld='nl'):
    """Generate a psuedorandom domain name."""
    if sld is None:
        sld = uuid.uuid4()
    return 'ci-%s.%s' % (sld, tld)


@pytest.fixture
def nameservers():
    """Return the name servers for example.com."""
    return [
        Nameserver(name='a.iana-servers.net', ip='199.43.132.53', ip6='2001:500:8c::53'),

        Nameserver(name='b.iana-servers.net', ip='199.43.133.53', ip6='2001:500:8d::53'),