import pytest
import os
from nixview.util import file_handler

test_file = os.path.join(".", "nix_test.h5")

@pytest.fixture
def setup():
    if not os.path.exists(test_file):
        from nixview.test.create_test_file import create_test_file
        create_test_file(test_file)
    fhandler = file_handler.FileHandler()
    yield fhandler
    fhandler.close()
   
def test_file_handler(setup):
    assert not setup.is_valid
    setup.open(test_file)
    
    assert setup.is_valid