示例#1
0
    def test_user_addmedia(self):
        """
        query_submitted = {"params": {"medias": [{"active": 0, "mediatypeid": 1,
        "period": "1-7,00:00-24:00", "severity": 63, "sendto": "*****@*****.**"}],
        "users": [{"userid": 1}]}, "jsonrpc": "2.0", "id": 0, "auth": "b347fc1bf1f5617b93755619a037c19e",
        "method": "user.addmedia"}
        """

        module_return = ["2"]
        query_return = {
            "jsonrpc": "2.0",
            "result": {
                "mediaids": ["2"]
            },
            "id": 0
        }

        with patch.object(zabbix, "_query", return_value=query_return):
            with patch.object(zabbix, "_login", return_value=CONN_ARGS):
                self.assertEqual(
                    zabbix.user_addmedia("1",
                                         active="0",
                                         mediatypeid="1",
                                         period="1-7,00:00-24:00",
                                         sendto="*****@*****.**",
                                         severity="63",
                                         **CONN_ARGS),
                    module_return,
                )
示例#2
0
    def test_user_addmedia(self):
        '''
        query_submitted = {"params": {"medias": [{"active": 0, "mediatypeid": 1,
        "period": "1-7,00:00-24:00", "severity": 63, "sendto": "*****@*****.**"}],
        "users": [{"userid": 1}]}, "jsonrpc": "2.0", "id": 0, "auth": "b347fc1bf1f5617b93755619a037c19e",
        "method": "user.addmedia"}
        '''

        module_return = ['2']
        query_return = {
            "jsonrpc": "2.0",
            "result": {
                "mediaids": ["2"]
            },
            "id": 0
        }

        with patch.object(zabbix, '_query', return_value=query_return):
            with patch.object(zabbix, '_login', return_value=CONN_ARGS):
                self.assertEqual(
                    zabbix.user_addmedia('1',
                                         active='0',
                                         mediatypeid='1',
                                         period='1-7,00:00-24:00',
                                         sendto='*****@*****.**',
                                         severity='63',
                                         **CONN_ARGS), module_return)
示例#3
0
def test_user_addmedia_v40(conn_args, set_zabbix_version, query_return,
                           mock_login):
    method = "user.addmedia"
    module_return = {
        "result":
        False,
        "comment":
        "Method '{}' removed in Zabbix 4.0+ use 'user.update'".format(method),
    }

    query_return({"jsonrpc": "2.0", "result": {"mediaids": ["2"]}, "id": 0})

    set_zabbix_version("4.0")
    assert (zabbix.user_addmedia("1",
                                 active="0",
                                 mediatypeid="1",
                                 period="1-7,00:00-24:00",
                                 sendto="*****@*****.**",
                                 severity="63",
                                 **conn_args) == module_return)
示例#4
0
def test_user_addmedia(conn_args, set_zabbix_version, query_return,
                       mock_login):
    """
    query_submitted = {"params": {"medias": [{"active": 0, "mediatypeid": 1,
    "period": "1-7,00:00-24:00", "severity": 63, "sendto": "*****@*****.**"}],
    "users": [{"userid": 1}]}, "jsonrpc": "2.0", "id": 0, "auth": "b347fc1bf1f5617b93755619a037c19e",
    "method": "user.addmedia"}
    """

    module_return = ["2"]
    query_return({"jsonrpc": "2.0", "result": {"mediaids": ["2"]}, "id": 0})

    set_zabbix_version("3.2")
    assert (zabbix.user_addmedia("1",
                                 active="0",
                                 mediatypeid="1",
                                 period="1-7,00:00-24:00",
                                 sendto="*****@*****.**",
                                 severity="63",
                                 **conn_args) == module_return)