コード例 #1
0
    def test_list(self):
        api = Icinga2API(username=constants.username,
                         password=constants.password,
                         url=constants.url,
                         debug=True)

        result = api.hostgroups.list()

        assert constants.Test_Hostgroup['name'] in result
コード例 #2
0
    def test_exists(self):
        api = Icinga2API(username=constants.username,
                         password=constants.password,
                         url=constants.url,
                         debug=True)

        result = api.hostgroups.exists(constants.Test_Hostgroup['name'])

        assert result
コード例 #3
0
    def test_delete(self):
        api = Icinga2API(username=constants.username,
                         password=constants.password,
                         url=constants.url,
                         debug=True)

        result = api.hostgroups.delete(constants.Test_Hostgroup['name'])

        assert result['results'][0]['code'] == 200
コード例 #4
0
    def test_objects(self):
        api = Icinga2API(username=constants.username,
                         password=constants.password,
                         url=constants.url,
                         debug=True)

        result = api.hostgroups.objects()

        assert any(
            res.get('name', None) == constants.Test_Hostgroup['name']
            for res in result)
コード例 #5
0
def test_service_exists():
    """
    Testing if the service was added correctly
    """
    api = Icinga2API(username=constants.username,
                     password=constants.password,
                     url=constants.url,
                     debug=False)

    response = api.services.exists(constants.TestService_name)

    assert response
コード例 #6
0
def test_host_delete():
    """
    Delete the created Host
    """
    api = Icinga2API(username=constants.username,
                     password=constants.password,
                     url=constants.url,
                     debug=False)

    response = api.hosts.delete(constants.TestHost_data['attrs']['name'])

    assert response != None
コード例 #7
0
def test_host_list():
    """
    Listing all Hosts, and check if created host is present
    """
    api = Icinga2API(username=constants.username,
                     password=constants.password,
                     url=constants.url,
                     debug=False)

    response = api.hosts.list()

    assert constants.TestHost_data['attrs']['name'] in response
コード例 #8
0
def test_host_exists():
    """
    Testing if the host was added correctly
    """
    api = Icinga2API(username=constants.username,
                     password=constants.password,
                     url=constants.url,
                     debug=False)

    response = api.hosts.exists(constants.TestHost_data['attrs']['name'])

    assert response
コード例 #9
0
def test_service_objects():
    """
    Get all service Objects and check if created service is present
    """
    api = Icinga2API(username=constants.username,
                     password=constants.password,
                     url=constants.url,
                     debug=False)

    response = api.services.objects()

    assert any(result['attrs'].get('name', None) == constants.TestService_name
               for result in response)
コード例 #10
0
def test_service_delete():
    """
    Delete the created service
    """
    api = Icinga2API(username=constants.username,
                     password=constants.password,
                     url=constants.url,
                     debug=False)

    response = api.services.delete(
        servicename=constants.TestService_name,
        hostname=constants.TestHost_data['attrs']['name'])

    assert response != None
コード例 #11
0
def test_service_list():
    """
    Listing all services, and check if created service is present
    """
    api = Icinga2API(username=constants.username,
                     password=constants.password,
                     url=constants.url,
                     debug=False)

    response = api.services.list(
        hostname=constants.TestHost_data['attrs']['name'])

    assert constants.TestHost_data['attrs'][
        'name'] + "!" + constants.TestService_name in response.values()
コード例 #12
0
def test_host_objects():
    """
    Get all Host Objects and check if created host is present
    """
    api = Icinga2API(username=constants.username,
                     password=constants.password,
                     url=constants.url,
                     debug=False)

    response = api.hosts.objects()

    assert any(
        res.get('name', None) == constants.TestHost_data['attrs']['name']
        for res in response)
コード例 #13
0
def test_host_add():
    """
    Testing the addition of a host
    """
    api = Icinga2API(username=constants.username,
                     password=constants.password,
                     url=constants.url,
                     debug=False)

    data = copy.deepcopy(constants.TestHost_data)

    response = api.hosts.add(data)

    assert response['results'][0]['code'] == 200
コード例 #14
0
def test_service_add():
    """
    Testing the addition of a service
    """
    api = Icinga2API(username=constants.username,
                     password=constants.password,
                     url=constants.url,
                     debug=False)

    response = api.services.add(
        servicename=constants.TestService_name,
        hostname=constants.TestHost_data['attrs']['name'],
        data=constants.TestService_data)

    assert response['results'][0]['code'] == 200
コード例 #15
0
    def test_add(self):
        api = Icinga2API(username=constants.username, password=constants.password, url=constants.url, debug=True)

        result = api.usergroups.add(constants.Test_Usergroup)

        assert result['results'][0]['code'] == 200