def test_user_list(self): """ query_submitted = {"params": {"output": "extend"}, "jsonrpc": "2.0", "id": 0, "auth": "54d67b63c37e690cf06972678f1e9720", "method": "user.get"} """ module_return = [ { "lang": "en_GB", "rows_per_page": "50", "surname": "Administrator", "name": "Zabbix", "url": "", "attempt_clock": "1515922072", "userid": "1", "autologin": "******", "refresh": "30s", "attempt_failed": "0", "alias": "Admin", "theme": "default", "autologout": "0", "attempt_ip": "10.0.2.2", "type": "3", }, { "lang": "en_GB", "rows_per_page": "50", "surname": "", "name": "", "url": "", "attempt_clock": "0", "userid": "2", "autologin": "******", "refresh": "30s", "attempt_failed": "0", "alias": "guest", "theme": "default", "autologout": "15m", "attempt_ip": "", "type": "1", }, { "lang": "en_GB", "rows_per_page": "50", "surname": "", "name": "James Brown", "url": "", "attempt_clock": "0", "userid": "5", "autologin": "******", "refresh": "30s", "attempt_failed": "0", "alias": "james", "theme": "default", "autologout": "15m", "attempt_ip": "", "type": "1", }, ] # 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", }, { "userid": "2", "alias": "guest", "name": "", "surname": "", "url": "", "autologin": "******", "autologout": "15m", "lang": "en_GB", "refresh": "30s", "type": "1", "theme": "default", "attempt_failed": "0", "attempt_ip": "", "attempt_clock": "0", "rows_per_page": "50", }, { "userid": "5", "alias": "james", "name": "James Brown", "surname": "", "url": "", "autologin": "******", "autologout": "15m", "lang": "en_GB", "refresh": "30s", "type": "1", "theme": "default", "attempt_failed": "0", "attempt_ip": "", "attempt_clock": "0", "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_list(**CONN_ARGS), module_return)
def test_user_list(conn_args, query_return, mock_login): """ query_submitted = {"params": {"output": "extend"}, "jsonrpc": "2.0", "id": 0, "auth": "54d67b63c37e690cf06972678f1e9720", "method": "user.get"} """ module_return = [ { "lang": "en_GB", "rows_per_page": "50", "surname": "Administrator", "name": "Zabbix", "url": "", "attempt_clock": "1515922072", "userid": "1", "autologin": "******", "refresh": "30s", "attempt_failed": "0", "alias": "Admin", "theme": "default", "autologout": "0", "attempt_ip": "10.0.2.2", "type": "3", }, { "lang": "en_GB", "rows_per_page": "50", "surname": "", "name": "", "url": "", "attempt_clock": "0", "userid": "2", "autologin": "******", "refresh": "30s", "attempt_failed": "0", "alias": "guest", "theme": "default", "autologout": "15m", "attempt_ip": "", "type": "1", }, { "lang": "en_GB", "rows_per_page": "50", "surname": "", "name": "James Brown", "url": "", "attempt_clock": "0", "userid": "5", "autologin": "******", "refresh": "30s", "attempt_failed": "0", "alias": "james", "theme": "default", "autologout": "15m", "attempt_ip": "", "type": "1", }, ] # 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", }, { "userid": "2", "alias": "guest", "name": "", "surname": "", "url": "", "autologin": "******", "autologout": "15m", "lang": "en_GB", "refresh": "30s", "type": "1", "theme": "default", "attempt_failed": "0", "attempt_ip": "", "attempt_clock": "0", "rows_per_page": "50", }, { "userid": "5", "alias": "james", "name": "James Brown", "surname": "", "url": "", "autologin": "******", "autologout": "15m", "lang": "en_GB", "refresh": "30s", "type": "1", "theme": "default", "attempt_failed": "0", "attempt_ip": "", "attempt_clock": "0", "rows_per_page": "50", }, ], "id": 0, } ) assert zabbix.user_list(**conn_args) == module_return