def setUp(self): self.client = oca.Client('test:test') self.xml = open( os.path.join(os.path.dirname(oca.__file__), 'tests/fixtures/templatepool.xml')).read()
def test_invalid_call(self): c = oca.Client('test:test') c.server.one = Mock() c.server.one.test_method = lambda x: [False, '2'] c.call('test_method')
def test_connection_error(self): c = oca.Client('test:test') c.server.one = Mock() c.server.one.test_method = Mock(side_effect=socket.error(1)) c.call('test_method')
def test_return_one_value_call(self): c = oca.Client('test:test') c.server.one = Mock() c.server.one.test_method = lambda x: [True, '', 0] assert c.call('test_method') == ''
def test_retrurn_error_code_0_call(self): c = oca.Client('test:test') c.server.one = Mock() c.server.one.test_method = lambda x: [False, '2', 1] c.call('test_method')
def test_addres(self): c = oca.Client('test:test', "http://8.8.8.8:2633/RPC2") assert c.one_address == "http://8.8.8.8:2633/RPC2"
def test_defaul_xmlrpc(self): c = oca.Client('test:test') assert c.one_address == oca.Client.DEFAULT_ONE_ADDRESS
def test_invalid_secret(self): os.environ["ONE_AUTH"] = os.path.join(os.path.dirname(oca.__file__), 'tests/fixtures/one_auth') c = oca.Client('testtest')
def test_with_plain(self): c = oca.Client('test:plain:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3') assert c.one_auth == 'test:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3'
def test_default_user_path(self): os.environ["ONE_AUTH"] = os.path.join(os.path.dirname(oca.__file__), 'tests/fixtures/one_auth') c = oca.Client() assert c.one_auth == 'test:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3'
def test_wrong_default_user_path(self): oca.Client.DEFAULT_ONE_AUTH = '/ad/ads/a/das/d/sad/sad/sa/d/one_auth' c = oca.Client()
def test_secret(self): c = oca.Client('test:test') assert c.one_auth == 'test:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3'
def __init__(self): self.client = oca.Client(self.ONE_USER + ':' + self.ONE_PASSWORD, self.ONE_ENDPOINT)
def test_default_user_path(self): os.environ["ONE_AUTH"] = os.path.join(os.path.dirname(oca.__file__), 'tests/fixtures/one_auth') c = oca.Client() assert c.one_auth == 'test:test'
def test_secret(self): c = oca.Client('test:test') assert c.one_auth == 'test:test'
def factory(cls, url, username, password): # type: (str, str, str) -> NebulaIPPool client = oca.Client('{}:{}'.format(username, password), url) return cls(client)