# Path: sacredboard/app/data/filestorage/filestorage.py
# class FileStorage(DataStorage):
#     """Object to interface with one of sacred's file stores."""
# 
#     def get_run_dao(self) -> RunDAO:
#         """Return the Data Access Object for manipulating runs."""
#         return FileStoreRunDAO(self.path_to_dir)
# 
#     def __init__(self, path_to_dir):
#         """Initialize file storage run accessor."""
#         super().__init__()
#         self.path_to_dir = os.path.expanduser(path_to_dir)


import bson
import pytest
import json
import tempfile
import os
from sacredboard.app.data.filestorage import FileStorage
                                                        ["numpy", "1.11.2"],
                                                        ["sacred", "0.6.10"]],
                                       "name": "German nouns"},
                        "result": 2403.52, "artifacts": [], "comment": "",
                        # N.B. time formatting is different between mongodb and file store.
                        "start_time": "2017-06-02T07:13:05.305845",
                        "stop_time": "2017-06-02T07:14:02.455460",
                        "heartbeat": "2017-06-02T07:14:02.452597",
           "captured_out": "Output: \n"}
    info = {"info": "present"}

    experiment_dir = tempfile.mkdtemp()
    experiment42 = os.path.join(experiment_dir, "42") # experiment number 42
    os.mkdir(experiment42)

    with open(os.path.join(experiment42, "config.json"), 'w') as config_file:
       json.dump(config, config_file)

    with open(os.path.join(experiment42, "run.json"), 'w') as run_file:
        json.dump(run, run_file)

    with open(os.path.join(experiment42, "info.json"), 'w') as info_file:
        json.dump(info, info_file)

    return experiment_dir

@pytest.fixture
def tmpfilestore() -> FileStorage:
    """Fixture that prepares a file store in /tmp for dependency injection."""
    dir = create_tmp_datastore()

# Path: sacredboard/app/data/filestorage/filestorage.py
# class FileStorage(DataStorage):
#     """Object to interface with one of sacred's file stores."""
# 
#     def get_run_dao(self) -> RunDAO:
#         """Return the Data Access Object for manipulating runs."""
#         return FileStoreRunDAO(self.path_to_dir)
# 
#     def __init__(self, path_to_dir):
#         """Initialize file storage run accessor."""
#         super().__init__()
#         self.path_to_dir = os.path.expanduser(path_to_dir)


# Path: sacredboard/tests/data/test_filestorage.py
import bson
import pytest
import json
import tempfile
import os
from sacredboard.app.data.filestorage import FileStorage

                                                        ["numpy", "1.11.2"],
                                                        ["sacred", "0.6.10"]],
                                       "name": "German nouns"},
                        "result": 2403.52, "artifacts": [], "comment": "",
                        # N.B. time formatting is different between mongodb and file store.
                        "start_time": "2017-06-02T07:13:05.305845",
                        "stop_time": "2017-06-02T07:14:02.455460",
                        "heartbeat": "2017-06-02T07:14:02.452597",
           "captured_out": "Output: \n"}
    info = {"info": "present"}

    experiment_dir = tempfile.mkdtemp()
    experiment42 = os.path.join(experiment_dir, "42") # experiment number 42
    os.mkdir(experiment42)

    with open(os.path.join(experiment42, "config.json"), 'w') as config_file:
       json.dump(config, config_file)

    with open(os.path.join(experiment42, "run.json"), 'w') as run_file:
        json.dump(run, run_file)

    with open(os.path.join(experiment42, "info.json"), 'w') as info_file:
        json.dump(info, info_file)

    return experiment_dir

@pytest.fixture
def tmpfilestore() -> FileStorage:
    """Fixture that prepares a file store in /tmp for dependency injection."""
    dir = create_tmp_datastore()

    return FileStorage(dir)