コード例 #1
0
ファイル: TestType_tests.py プロジェクト: kmdouglass/bstore
def test_testType_Put_Data():
    """testType can put its own data and datasetIDs.
    
    """
    # Make up some dataset IDs and a dataset
    dsIDs           = {}
    dsIDs['prefix'] = 'test_prefix'
    dsIDs['acqID']  = 1
    ds              = TestType(datasetIDs = dsIDs)
    ds.data         = array([42])
    
    pathToDB = testDataRoot
    # Remove datastore if it exists
    if exists(str(pathToDB / Path('test_db.h5'))):
        remove(str(pathToDB / Path('test_db.h5')))
    
    myDB = db.HDFDatastore(pathToDB / Path('test_db.h5'))
    myDB.put(ds)
    
    key = 'test_prefix/test_prefix_1/TestType'
    with h5py.File(str(pathToDB / Path('test_db.h5')), 'r') as hdf:
        assert_equal(hdf[key][0],                                42)
        assert_equal(hdf[key].attrs['SMLM_datasetType'], 'TestType')
        assert_equal(hdf[key].attrs['SMLM_prefix'],   'test_prefix')
        assert_equal(hdf[key].attrs['SMLM_acqID'],                1)

    # Remove the test datastore
    remove(str(pathToDB / Path('test_db.h5')))
コード例 #2
0
ファイル: TestType_tests.py プロジェクト: kmdouglass/bstore
def test__repr__():
    """DatasetType generates the correct __repr__ string.
    
    """
    dsIDs           = {}
    dsIDs['prefix'] = 'test_prefix'
    
    ds = TestType(datasetIDs = dsIDs)
    
    assert_equal(ds.__repr__(), 'TestType: {\'prefix\': \'test_prefix\'}')
    
    del(ds.datasetIDs['prefix'])
    assert_equal(ds.__repr__(), 'TestType: {}')
コード例 #3
0
ファイル: TestType_tests.py プロジェクト: kmdouglass/bstore
def test_testType_DatasetIDs():
    """testType can return the correct dataset IDs.
    
    """
    # Make up some dataset IDs and a dataset
    dsIDs           = {}
    dsIDs['prefix'] = 'test_prefix'
    dsIDs['acqID']  = 1
    ds              = TestType(datasetIDs = dsIDs)
    ds.data         = array([42])
    
    ids = ds.datasetIDs
    assert_equal(ids['prefix'],       'test_prefix')
    assert_equal(ids['acqID'],                    1)
    assert_equal(ds.datasetType,         'TestType')
    assert_equal(ds.attributeOf,               None)
コード例 #4
0
ファイル: TestType_tests.py プロジェクト: kmdouglass/bstore
def test_testType_Get_Data():
    """testType can get its own data and datasetIDs.
    
    """
    # Make up some dataset IDs and a dataset
    dsIDs           = {}
    dsIDs['prefix'] = 'test_prefix'
    dsIDs['acqID']  = 1
    ds              = TestType(datasetIDs = dsIDs)
    ds.data         = array([42])
    
    pathToDB = testDataRoot
    # Remove datastore if it exists
    if exists(str(pathToDB / Path('test_db.h5'))):
        remove(str(pathToDB / Path('test_db.h5')))
    
    myDB = db.HDFDatastore(pathToDB / Path('test_db.h5'))
    myDB.put(ds)
    
    # Create a new dataset containing only IDs to test getting of the data
    dsID = myDB.dsID('test_prefix', 1, 'TestType', None,
                     None, None, None, None)   
    
    myNewDS = myDB.get(dsID)
    ids     = myNewDS.datasetIDs
    assert_equal(ids['prefix'],       'test_prefix')
    assert_equal(ids['acqID'],                    1)
    assert_equal(ids['channelID'],             None)
    assert_equal(ids['dateID'],                None)
    assert_equal(ids['posID'],                 None)
    assert_equal(ids['sliceID'],               None)
    assert_equal(myNewDS.datasetType,    'TestType')
    assert_equal(myNewDS.attributeOf,          None)
    assert_equal(myNewDS.data,                   42)
    
    # Remove the test datastore
    remove(str(pathToDB / Path('test_db.h5')))