Ejemplo n.º 1
0
 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()
Ejemplo n.º 2
0
 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')
Ejemplo n.º 3
0
 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')
Ejemplo n.º 4
0
 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') == ''
Ejemplo n.º 5
0
 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')
Ejemplo n.º 6
0
 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"
Ejemplo n.º 7
0
 def test_defaul_xmlrpc(self):
     c = oca.Client('test:test')
     assert c.one_address == oca.Client.DEFAULT_ONE_ADDRESS
Ejemplo n.º 8
0
 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')
Ejemplo n.º 9
0
 def test_with_plain(self):
     c = oca.Client('test:plain:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3')
     assert c.one_auth == 'test:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3'
Ejemplo n.º 10
0
 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'
Ejemplo n.º 11
0
 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()
Ejemplo n.º 12
0
 def test_secret(self):
     c = oca.Client('test:test')
     assert c.one_auth == 'test:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3'
Ejemplo n.º 13
0
 def __init__(self):
     self.client = oca.Client(self.ONE_USER + ':' + self.ONE_PASSWORD, self.ONE_ENDPOINT)
Ejemplo n.º 14
0
 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'
Ejemplo n.º 15
0
 def test_secret(self):
     c = oca.Client('test:test')
     assert c.one_auth == 'test:test'
Ejemplo n.º 16
0
 def factory(cls, url, username, password):
     # type: (str, str, str) -> NebulaIPPool
     client = oca.Client('{}:{}'.format(username, password), url)
     return cls(client)