Пример #1
0
    def test_post_to_inventory_success(self):
        values = {"account": "12345", "metadata": {"some_key": "some_value"}}
        responses.add(responses.POST, app.INVENTORY_URL,
                      json={"data": [{"host": {"id": "4f81c749-e6e6-46a7-ba3f-e755001ba5ee"}, "status": 200}]}, status=207)
        method_response = app.post_to_inventory('1234', 'abcd1234', values)

        assert method_response == "4f81c749-e6e6-46a7-ba3f-e755001ba5ee"
        assert len(responses.calls) == 1
        assert responses.calls[0].response.text == '{"data": [{"host": {"id": "4f81c749-e6e6-46a7-ba3f-e755001ba5ee"}, "status": 200}]}'
Пример #2
0
    def test_post_to_inventory_fail(self):
        values = {"account": "12345", "metadata": {"bad_key": "bad_value"}}
        responses.add(responses.POST, app.INVENTORY_URL,
                      json={"data": [{"detail": "boop", "status": 400}]}, status=207)
        method_response = app.post_to_inventory('1234', 'abcd1234', values)

        assert method_response is None
        assert len(responses.calls) == 1
        assert responses.calls[0].response.text == '{"data": [{"detail": "boop", "status": 400}]}'
Пример #3
0
    def test_post_to_inventory_fail(self):
        values = {"account": "12345", "metadata": {"bad_key": "bad_value"}}
        responses.add(responses.POST, app.INVENTORY_URL,
                      json={"error message": "boop"}, status=400)
        method_response = app.post_to_inventory('1234', 'abcd1234', values)

        assert method_response is 400
        assert len(responses.calls) == 1
        assert responses.calls[0].response.text == '{"error message": "boop"}'