def test_open_write(self, mock_ensure_dir_exists, mock_open):
        store = LocalStore("/tmp/")
        with store.open("test.txt", "w") as handle:
            handle.write("content")

        mock_ensure_dir_exists.assert_called_once_with("/tmp/test.txt")
        mock_open.assert_called_once_with("/tmp/test.txt",
                                          "w",
                                          encoding="utf8")
    def test_open_read(self, mock_ensure_dir_exists, mock_open):
        mock_open.side_effect = [
            mock.mock_open(read_data="content").return_value
        ]

        store = LocalStore("/tmp/")
        with store.open("test.txt", "r") as handle:
            content = handle.readlines()

        mock_ensure_dir_exists.assert_not_called()
        mock_open.assert_called_once_with("/tmp/test.txt",
                                          "r",
                                          encoding="utf8")

        assert content == ["content"]
Exemple #3
0
def main(output_folder):
    config = read_config()
    client = WebClient()
    store = LocalStore(config["store"]["path"])

    task = GetIntensiveCareDataset(config["collector"], client, store)
    task(output_folder=output_folder)
    def test_ensure_dir_exists_error(self, mock_makedirs):
        mock_makedirs.side_effect = OSError

        # pylint: disable=protected-access
        LocalStore("/tmp")._ensure_dir_exists("/tmp/test.txt")

        mock_makedirs.assert_called_once_with("/tmp")
def main(name, input_folder, output_folder):
    config = read_config()
    store = LocalStore(config["store"]["path"])

    task = MergeIntensiveCareDataset(config["collector"], store)
    task(name=name, input_folder=input_folder, output_folder=output_folder)
Exemple #6
0
def main(input_folder, output_folder):
    config = read_config()
    store = LocalStore(config["store"]["path"])

    task = CleanNationalDataset(config["collector"], store)
    task(input_folder=input_folder, output_folder=output_folder)
 def test_is_write_mode(self, mode, expected):
     # pylint: disable=protected-access
     assert LocalStore("/tmp")._is_write_mode(mode) == expected
    def test_list(self, mock_glob):
        store = LocalStore("/tmp")
        store.list("*.txt")

        mock_glob.assert_called_once_with("/tmp/*.txt")