예제 #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