Exemple #1
0
 def test0001(self, *args):
     """
     Test the add_child_server positive exit
     """
     m_db_get_server = args[3]  # I prefer this to the params.
     m_ans_add_server = args[2]
     m_ans_add_server_hierarchy = args[0]
     # Generete a "local server info"
     uuidlocal = str(uuid.uuid1())
     localinfo = {
         'id': uuidlocal,
         'name': 'localserver',
         'ip': '127.0.0.1',
         'port': '40001',
         'descr': 'Mock server local'
     }
     m_db_get_server.return_value = (True, localinfo)
     m_ans_add_server.return_value = (True, "Mock ans_add_server")
     m_ans_add_server_hierarchy.return_value = (
         True, "Mock ans_add_server_hierarchy")
     guuid = str(uuid.uuid1())
     res = add_child_server('192.168.1.1', guuid)
     (_, keydict) = m_ans_add_server.call_args
     self.assertTrue(keydict.get('system_ip') == '192.168.1.1')
     self.assertTrue(keydict.get('server_id') == uuidlocal)
     self.assertTrue(keydict.get('server_ip') == '127.0.0.1')
     self.assertTrue(keydict.get('server_port') == '40001')
     self.assertTrue(keydict.get('server_descr') == localinfo['descr'])
     #
     (_, keydict) = m_ans_add_server_hierarchy.call_args
     self.assertTrue(keydict.get('system_ip') == '192.168.1.1')
     self.assertTrue(keydict.get('parent_id') == localinfo['id'])
     self.assertTrue(keydict.get('child_id') == guuid)
     self.assertTrue(res[0])
 def test0001(self, *args):
     """
     Test the add_child_server positive exit
     """
     m_db_get_server = args[3]  # I prefer this to the params.
     m_ans_add_server = args[2]
     m_ans_add_server_hierarchy = args[0]
     # Generete a "local server info"
     uuidlocal = str(uuid.uuid1())
     localinfo = {
         'id': uuidlocal,
         'name': 'localserver',
         'ip': '127.0.0.1',
         'port': '40001',
         'descr': 'Mock server local'
     }
     m_db_get_server.return_value = (True, localinfo)
     m_ans_add_server.return_value = (True, "Mock ans_add_server")
     m_ans_add_server_hierarchy.return_value = (True, "Mock ans_add_server_hierarchy")
     guuid = str(uuid.uuid1())
     res = add_child_server('192.168.1.1', guuid)
     (_, keydict) = m_ans_add_server.call_args
     self.assertTrue(keydict.get('system_ip') == '192.168.1.1')
     self.assertTrue(keydict.get('server_id') == uuidlocal)
     self.assertTrue(keydict.get('server_ip') == '127.0.0.1')
     self.assertTrue(keydict.get('server_port') == '40001')
     self.assertTrue(keydict.get('server_descr') == localinfo['descr'])
     #
     (_, keydict) = m_ans_add_server_hierarchy.call_args
     self.assertTrue(keydict.get('system_ip') == '192.168.1.1')
     self.assertTrue(keydict.get('parent_id') == localinfo['id'])
     self.assertTrue(keydict.get('child_id') == guuid)
     self.assertTrue(res[0])
 def test0002(self, *args):
     """
     Test the add_child_server positive exit. Fail db_get_server
     """
     m_db_get_server = args[3]  # I prefer this to the params.
     m_ans_add_server = args[2]
     m_ans_add_server_hierarchy = args[0]
     # Generete a "local server info"
     m_db_get_server.return_value = (False, "PETE")
     m_ans_add_server.return_value = (True, "Mock ans_add_server")
     m_ans_add_server_hierarchy.return_value = (True, "Mock ans_add_server_hierarchy")
     guuid = str(uuid.uuid1())
     res = add_child_server('192.168.1.1', guuid)
     self.assertFalse(res[0])
     self.assertTrue(res[1] == 'PETE')
Exemple #4
0
 def test0002(self, *args):
     """
     Test the add_child_server positive exit. Fail db_get_server
     """
     m_db_get_server = args[3]  # I prefer this to the params.
     m_ans_add_server = args[2]
     m_ans_add_server_hierarchy = args[0]
     # Generete a "local server info"
     m_db_get_server.return_value = (False, "PETE")
     m_ans_add_server.return_value = (True, "Mock ans_add_server")
     m_ans_add_server_hierarchy.return_value = (
         True, "Mock ans_add_server_hierarchy")
     guuid = str(uuid.uuid1())
     res = add_child_server('192.168.1.1', guuid)
     self.assertFalse(res[0])
     self.assertTrue(res[1] == 'PETE')
 def test0004(self, *args):
     """
     Test the add_child_server positive exit. Fail ans_add_server_hierarchy
     """
     m_db_get_server = args[3]  # I prefer this to the params.
     m_ans_add_server = args[2]  #
     m_ans_add_server_hierarchy = args[0]
     # Generete a "local server info"
     uuidlocal = str(uuid.uuid1())
     guuid = str(uuid.uuid1())
     localinfo = {
         'id': uuidlocal,
         'name': 'localserver',
         'ip': '127.0.0.1',
         'port': '40001',
         'descr': 'Mock server local'
     }
     m_db_get_server.return_value = (True, localinfo)
     m_ans_add_server_hierarchy.return_value = (False, "Mock ERROR ans_add_server_hierarchy")
     m_ans_add_server.return_value = (True, "Mock ans_add_server")
     res = add_child_server('192.168.1.1', guuid)
     self.assertFalse(res[0])
     self.assertTrue(res[1] == 'Mock ERROR ans_add_server_hierarchy')
Exemple #6
0
 def test0004(self, *args):
     """
     Test the add_child_server positive exit. Fail ans_add_server_hierarchy
     """
     m_db_get_server = args[3]  # I prefer this to the params.
     m_ans_add_server = args[2]  #
     m_ans_add_server_hierarchy = args[0]
     # Generete a "local server info"
     uuidlocal = str(uuid.uuid1())
     guuid = str(uuid.uuid1())
     localinfo = {
         'id': uuidlocal,
         'name': 'localserver',
         'ip': '127.0.0.1',
         'port': '40001',
         'descr': 'Mock server local'
     }
     m_db_get_server.return_value = (True, localinfo)
     m_ans_add_server_hierarchy.return_value = (
         False, "Mock ERROR ans_add_server_hierarchy")
     m_ans_add_server.return_value = (True, "Mock ans_add_server")
     res = add_child_server('192.168.1.1', guuid)
     self.assertFalse(res[0])
     self.assertTrue(res[1] == 'Mock ERROR ans_add_server_hierarchy')