def test_api_factory_with_env(): os.environ['OPENPROVIDER_APIFACTORY_TEST_USERNAME'] = '******' os.environ['OPENPROVIDER_APIFACTORY_TEST_PASSWORD'] = '******' api = api_factory('apifactory_test') assert api.username == 'myusername' assert api.password == 'mypassword'
def test_with_env(self): os.environ['OPENPROVIDER_APIFACTORY_TEST_USERNAME'] = '******' os.environ['OPENPROVIDER_APIFACTORY_TEST_PASSWORD'] = '******' api = api_factory('apifactory_test') self.assertEqual(api.username, 'myusername') self.assertEqual(api.password, 'mypassword')
def test_transfer(api): try: secundary_api = api_factory('test_secundary') configure_betamax(api, second=secundary_api) except KeyError: pytest.skip("No secundary account configured") domain = 'ci-%d.com' % calendar.timegm(dt.now().timetuple()) primary_handle = 'YN000088-NL' secundary_handle = 'YN000101-NL' # Register a domain at the primary account with Betamax(api.session).use_cassette('domain_transfer_create'): response = api.domain.create_domain_request( domain, 1, primary_handle, primary_handle, primary_handle, ns_group='dns-openprovider', ) auth_code = str(response.auth_code) # Now transfer it to the second account with Betamax(secundary_api.session).use_cassette('domain_transfer_transfer'): response = secundary_api.domain.transfer_domain_request( domain, 1, auth_code, secundary_handle, secundary_handle, secundary_handle, ns_group='dns-openprovider', ) assert response.status == 'ACT' # Should be gone at the first provider with Betamax(api.session).use_cassette('domain_transfer_retrieve_old_registry'): with pytest.raises(NoSuchElement): api.domain.retrieve_domain_request(domain) # And be there at the second with Betamax(secundary_api.session).use_cassette('domain_transfer_retrieve_new_registry'): secundary_api.domain.retrieve_domain_request(domain) is not None # Try to clean up try: with Betamax(secundary_api.session).use_cassette('domain_transfer_delete_domain'): secundary_api.delete_domain_request(domain) except: pass
def test_api_factory_no_env(): with pytest.raises(KeyError) as excinfo: api_factory('myaccount') assert str(excinfo.value) == "'Missing openprovider username for account myaccount'"
def test_no_env(self): with self.assertRaises(KeyError) as cm: api_factory('myaccount') self.assertEqual(str(cm.exception), "'Missing openprovider username for account myaccount'")
os.environ.setdefault('OPENPROVIDER_USERNAME', 'test') os.environ.setdefault('OPENPROVIDER_PASSWORD', 'test') try: # Try to use IPython... from IPython import embed def repl(): embed(banner1="") except ImportError: # But if that fails, fall back to normal Python. import code def repl(): code.interact(banner="", local=globals()) op = api_factory() print(textwrap.dedent(__doc__).strip()) print("") print("Address: %s" % op.url) print("Username: %s" % op.username) # Clean up the environment del api_factory del textwrap del os repl()
def setUp(self): self.api = api_factory('test') configure_betamax(self.api)
def api(): api = api_factory('test') configure_betamax(api) return api
def test_api_factory_no_env(): with pytest.raises(KeyError) as excinfo: api_factory('myaccount') assert str(excinfo.value ) == "'Missing openprovider username for account myaccount'"