示例#1
0
 def test_checkSession(self):
     """
     The login status could be: valid | init | expired depends on the time
     recorded in login session file.
     """
     core_obj = Core()
     result = core_obj.checkSession()
     assert (result in ('valid', 'init', 'expired')) is True
示例#2
0
 def test_parseParameters(self):
     core_obj = Core()
     reminderargs = ['limit', '5']
     reminderargs_with_equal = ['limit=5']
     params_list = core_obj.parseParameters(reminderargs)
     params_list_with_equal = core_obj.parseParameters(reminderargs_with_equal)
     assert isinstance(params_list, dict) is True
     assert isinstance(params_list_with_equal, dict) is True
示例#3
0
 def test_logout(self):
     '''
     The test of this function depends on the local session file which itself time dependent,
     thus here will check the return type only.
     '''
     core_obj = Core()
     result = core_obj.logout()
     assert isinstance(result, str) is True
示例#4
0
 def test_getCommandHelp(self):
     core_obj = Core()
     cmd_success = 'QueryDomainList'
     cmd_failure = 'WRONGCOMMAND'
     txt_failure = "Command 'wrongcommand' not found!"
     response_success = core_obj.getCommandHelp(cmd_success)
     reponse_failure = core_obj.getCommandHelp(cmd_failure)
     assert txt_failure == reponse_failure
     assert isinstance(response_success, str) is True
示例#5
0
 def test_parseArgs(self):
     core_obj = Core()
     parser = core_obj.initParser()
     # example of login args
     login_args = "-u=test.user -p=test.passw0rd -e=ote"
     # split args in an array
     splitted_args = login_args.split()
     # get main commands such as "-c checkdomain"
     login_args = vars(parser.parse_args(splitted_args))
     result, data = core_obj.parseArgs(login_args)
     assert isinstance(result, str)
     assert isinstance(data, str)
示例#6
0
    def test_login(self):
        core_obj = Core()
        # login success case
        login_args = {'userid': 'test.user', 'password': '******',
                      'entity': 'ote'}
        result, msg = core_obj.login(login_args)
        assert result is True

        # login failure case
        login_args = {'userid': 'NOUSER', 'password': '******',
                      'entity': 'ote'}
        result, msg = core_obj.login(login_args)
        assert result is False
示例#7
0
def core_obj():
    """Returns a Core instance"""
    core_obj = Core()
    return core_obj
示例#8
0
 def test_getResponse(self):
     core_obj = Core()
     cmd = {'command': 'querydomainlist', 'limit': '2'}
     response = core_obj.request(cmd)
     return_response = core_obj.getResponse(response, 'list')
     assert isinstance(return_response, dict) is True
示例#9
0
 def test_request(self):
     core_obj = Core()
     cmd_success = {'command': 'querydomainlist', 'limit': '2'}
     response = core_obj.request(cmd_success)
     assert isinstance(response, Response) is True
示例#10
0
 def test_initParser(self):
     core_obj = Core()
     parser = core_obj.initParser()
     assert isinstance(parser, argparse.ArgumentParser) is True
示例#11
0
 def test_getMinParameters(self):
     core_obj = Core()
     cmd = "CheckDomain"
     result = core_obj.getMinParameters(cmd)
     assert 'domain' == result[0]
示例#12
0
 def test_getCommandList(self):
     core_obj = Core()
     result = core_obj.getCommandList()
     assert isinstance(result, str) is True