Exemple #1
0
    def test_save(self):
        self._cleanup()
        server_id = server_model.collection.insert({"name": "server_check_sort_and_filter_by_host"})
        server = server_model.get_by_id(server_id)
        
        command = "testmehere"
        for i in range(0, 10):
            health_checks_model.save(command=command, server=server)

        assert health_checks_model.collection.find().count() == 1
Exemple #2
0
    def test_save(self):
        self._cleanup()
        server_id = server_model.collection.insert(
            {"name": "server_check_sort_and_filter_by_host"})
        server = server_model.get_by_id(server_id)

        command = "testmehere"
        for i in range(0, 10):
            health_checks_model.save(command=command, server=server)

        assert health_checks_model.collection.find().count() == 1
Exemple #3
0
    def test_get_unique_commands(self):
        self._cleanup()

        server_id = server_model.collection.insert(
            {"name": "server_check_sort_and_filter_by_host"})
        server = server_model.get_by_id(server_id)

        for i in range(0, 10):
            command = "testcommand{0} -w {0} -c {0}".format(i)
            health_checks_model.save(command=command, server=server)

        result = health_checks_api_model.get_unique_commands()

        assert len(result) == 10
Exemple #4
0
    def test_get_unique_commands(self):
        self._cleanup()

        server_id = server_model.collection.insert({"name": "server_check_sort_and_filter_by_host"})
        server = server_model.get_by_id(server_id)

        for i in range(0, 10):
            command = "testcommand{0} -w {0} -c {0}".format(i)
            health_checks_model.save(command=command, server=server)


        result = health_checks_api_model.get_unique_commands()

        assert len(result) == 10
Exemple #5
0
    def test_get_commands_for_server(self):
        self._cleanup()

        server_id = server_model.collection.insert({"name": "server_check_sort_and_filter_by_host"})
        server = server_model.get_by_id(server_id)
        
        command = "testmehere -w 10"
        for i in range(0, 10):
            health_checks_model.save(command=command, server=server)

        second_command = "testmeagain -c 10"
        for i in range(0, 5):
            health_checks_model.save(command=second_command, server=server)

        result = health_checks_api_model.get_commands_for_server(server_id=server['_id'])

        assert result.count() == 2
Exemple #6
0
    def test_get_commands_for_server(self):
        self._cleanup()

        server_id = server_model.collection.insert(
            {"name": "server_check_sort_and_filter_by_host"})
        server = server_model.get_by_id(server_id)

        command = "testmehere -w 10"
        for i in range(0, 10):
            health_checks_model.save(command=command, server=server)

        second_command = "testmeagain -c 10"
        for i in range(0, 5):
            health_checks_model.save(command=second_command, server=server)

        result = health_checks_api_model.get_commands_for_server(
            server_id=server['_id'])

        assert result.count() == 2
Exemple #7
0
    def test_get_params_for_command(self):
        self._cleanup()

        server_id = server_model.collection.insert({"name": "server_check_sort_and_filter_by_host"})
        server = server_model.get_by_id(server_id)

        for i in range(0, 10):
            command = "testcommand -w {0} -c {0}".format(i)
            health_checks_model.save(command=command, server=server)

        # Duplicate - still has to return only 10 unique params
        for i in range(0, 10):
            command = "testcommand -w {0} -c {0}".format(i)
            health_checks_model.save(command=command, server=server)


        result = health_checks_api_model.get_params_for_command(command_string="testcommand")

        assert len(result) == 10
Exemple #8
0
    def test_get_params_for_command(self):
        self._cleanup()

        server_id = server_model.collection.insert(
            {"name": "server_check_sort_and_filter_by_host"})
        server = server_model.get_by_id(server_id)

        for i in range(0, 10):
            command = "testcommand -w {0} -c {0}".format(i)
            health_checks_model.save(command=command, server=server)

        # Duplicate - still has to return only 10 unique params
        for i in range(0, 10):
            command = "testcommand -w {0} -c {0}".format(i)
            health_checks_model.save(command=command, server=server)

        result = health_checks_api_model.get_params_for_command(
            command_string="testcommand")

        assert len(result) == 10
Exemple #9
0
    def test_delete(self):
        self._cleanup()

        server_id = server_model.collection.insert({"name": "server_check_sort_and_filter_by_host"})
        server = server_model.get_by_id(server_id)
        
        command = "testmehere"
        for i in range(0, 5):
            health_checks_model.save(command=command, server=server)

        result = health_checks_model.collection.count()

        check = health_checks_model.collection.find_one()

        assert result == 1
        
        health_checks_model.delete(check_id=check['_id'])

        result = health_checks_model.collection.count()
        assert result == 0
Exemple #10
0
    def test_delete(self):
        self._cleanup()

        server_id = server_model.collection.insert(
            {"name": "server_check_sort_and_filter_by_host"})
        server = server_model.get_by_id(server_id)

        command = "testmehere"
        for i in range(0, 5):
            health_checks_model.save(command=command, server=server)

        result = health_checks_model.collection.count()

        check = health_checks_model.collection.find_one()

        assert result == 1

        health_checks_model.delete(check_id=check['_id'])

        result = health_checks_model.collection.count()
        assert result == 0