예제 #1
0
def test_user_exists(conn_args, set_zabbix_version, query_return, mock_login):
    """
    query_submitted = {"params": {"filter": {"alias": "Admin"}, "output": "extend"},
    "jsonrpc": "2.0", "id": 0, "auth": "72435c7f754cb2adb4ecddc98216057f",
    "method": "user.get"}
    """

    module_return = True
    # pylint: disable=E8128
    query_return({
        "jsonrpc":
        "2.0",
        "result": [{
            "userid": "1",
            "alias": "Admin",
            "name": "Zabbix",
            "surname": "Administrator",
            "url": "",
            "autologin": "******",
            "autologout": "0",
            "lang": "en_GB",
            "refresh": "30s",
            "type": "3",
            "theme": "default",
            "attempt_failed": "0",
            "attempt_ip": "10.0.2.2",
            "attempt_clock": "1515922072",
            "rows_per_page": "50",
        }],
        "id":
        0,
    })

    set_zabbix_version("3.2")
    assert zabbix.user_exists("Admin", **conn_args) == module_return
예제 #2
0
    def test_user_exists(self):
        '''
        query_submitted = {"params": {"filter": {"alias": "Admin"}, "output": "extend"},
        "jsonrpc": "2.0", "id": 0, "auth": "72435c7f754cb2adb4ecddc98216057f",
        "method": "user.get"}
        '''

        module_return = True
        # pylint: disable=E8128
        query_return = {"jsonrpc": "2.0", "result": [{"userid": "1", "alias": "Admin",
                        "name": "Zabbix", "surname": "Administrator", "url": "", "autologin": "******",
                        "autologout": "0", "lang": "en_GB", "refresh": "30s", "type": "3", "theme": "default",
                        "attempt_failed": "0", "attempt_ip": "10.0.2.2", "attempt_clock": "1515922072",
                        "rows_per_page": "50"}], "id": 0}

        with patch.object(zabbix, '_query', return_value=query_return):
            with patch.object(zabbix, '_login', return_value=CONN_ARGS):
                self.assertEqual(zabbix.user_exists('Admin', **CONN_ARGS), module_return)