async def test_flush_errors():
    """ Test Flush Errors Method """
    c_task = SimpleCatalogTask()
    writer = json_writer.JSONWriter(TestData.config, c_task)
    await writer.flush_errors("kaboom")

    assert (c_task.data["state"]) == "completed"
    assert (c_task.data["status"]) == "error"
Esempio n. 2
0
    def get_writer(self, work):
        """ Create an appropriate writer object based on the response format """
        if work["response_format"] == "tar":
            return tar_writer.TarWriter(self.config, self.c_task,
                                        work["upload_url"])

        # By default we support the JSON Writer
        return json_writer.JSONWriter(self.config, self.c_task)
async def test_write():
    """ Test Write Method"""
    c_task = SimpleCatalogTask()
    writer = json_writer.JSONWriter(TestData.config, c_task)
    result = {"name": "Fred Flintstone"}
    await writer.write(json.dumps(result), "file1")

    assert (c_task.data["state"]) == "running"
    assert (c_task.data["output"]["name"]) == "Fred Flintstone"
    assert (c_task.data["status"]) == "ok"
def test_cleanup():
    """ Test Cleanup """
    c_task = SimpleCatalogTask()
    writer = json_writer.JSONWriter(TestData.config, c_task)
    writer.cleanup()