Exemple #1
0
    def test_send_to_influxdb_no_credentials(self, influx_db_values):
        old_user, old_pass = mnm.INFLUX_USER, mnm.INFLUX_PASS
        mnm.INFLUX_USER = mnm.INFLUX_PASS = None

        responses.add(responses.POST,
                      mnm.INFLUXDB_PLATFORM,
                      json={"message": "saved"},
                      status=201)

        try:
            method_response = mnm.send_to_influxdb(influx_db_values)

            assert method_response is None
            assert len(responses.calls) == 0
        finally:
            mnm.INFLUX_USER, mnm.INFLUX_PASS = old_user, old_pass
Exemple #2
0
    def test_send_to_influxdb_down(self, influx_db_values):
        responses.add(responses.POST,
                      mnm.INFLUXDB_PLATFORM,
                      json={"message": "error"},
                      status=201)

        old_user, old_pass = mnm.INFLUX_USER, mnm.INFLUX_PASS
        mnm.INFLUX_USER = mnm.INFLUX_PASS = "******"

        try:
            method_response = mnm.send_to_influxdb(influx_db_values)

            assert method_response is None
            assert len(responses.calls) == 1
            assert responses.calls[0].response.text == '{"message": "error"}'
        finally:
            mnm.INFLUX_USER, mnm.INFLUX_PASS = old_user, old_pass