コード例 #1
0
ファイル: test_core_plugins.py プロジェクト: BASIN-3D/basin3d
def test_plugin_access_objects():
    """Test the plugin and check the access objects available"""
    from tests.testplugins import alpha
    assert isinstance(
        alpha.AlphaSourcePlugin(CatalogTinyDb()).get_plugin_access(), dict)
    plugin_access_objects = alpha.AlphaSourcePlugin(
        CatalogTinyDb()).get_plugin_access()
    assert list(plugin_access_objects.keys()) == [
        basin3d.core.models.MeasurementTimeseriesTVPObservation,
        basin3d.core.models.MonitoringFeature
    ]

    assert plugin_access_objects[
        basin3d.core.models.
        MonitoringFeature].__class__.__name__ == 'tests.testplugins.alpha.AlphaMonitoringFeatureAccess'
    assert plugin_access_objects[basin3d.core.models.MeasurementTimeseriesTVPObservation].__class__.__name__ == \
        'tests.testplugins.alpha.AlphaMeasurementTimeseriesTVPObservationAccess'
コード例 #2
0
ファイル: test_core_plugins.py プロジェクト: BASIN-3D/basin3d
def test_plugin_views(monkeypatch):
    """Import the alpha plugin and try to call the api directly"""
    from tests.testplugins import alpha

    monkeypatch.setattr(alpha.AlphaSourcePlugin, 'get_datasource', Mock())
    plugin_views = alpha.AlphaSourcePlugin(CatalogTinyDb()).get_plugin_access()
    assert isinstance(plugin_views, dict)
    assert basin3d.core.models.MeasurementTimeseriesTVPObservation in plugin_views
    assert basin3d.core.models.MonitoringFeature in plugin_views
コード例 #3
0
ファイル: test_catalog.py プロジェクト: BASIN-3D/basin3d
def test_process_plugin_variable_mapping(catalog):
    """Test a bad mapping file with the wrong header"""
    from tests.testplugins import alpha
    from basin3d.core.catalog import CatalogException
    with pytest.raises(CatalogException):
        catalog._process_plugin_variable_mapping(
            alpha.AlphaSourcePlugin(catalog),
            map_filename='mapping_alpha_wrong_header.csv',
            datasource=DataSource())
コード例 #4
0
ファイル: conftest.py プロジェクト: BASIN-3D/basin3d
def plugin_access_alpha():
    """
    Create a DataSourcePluginAccess object
    """
    from tests.testplugins import alpha
    from basin3d.core.catalog import CatalogTinyDb
    catalog = CatalogTinyDb()
    plugins = [alpha.AlphaSourcePlugin(catalog)]
    catalog.initialize(plugins)
    return plugins[0].access_classes[MeasurementTimeseriesTVPObservation]
コード例 #5
0
ファイル: test_core_plugins.py プロジェクト: BASIN-3D/basin3d
def test_plugin_direct(monkeypatch):
    """Import the alpha plugin and try to call the api directly"""
    from tests.testplugins import alpha

    monkeypatch.setattr(alpha.AlphaSourcePlugin, 'get_datasource', Mock())
    assert alpha.AlphaSourcePlugin().direct("path") is None
コード例 #6
0
ファイル: test_catalog.py プロジェクト: BASIN-3D/basin3d
 def test_create_catalog():
     from tests.testplugins import alpha
     from basin3d.core.catalog import CatalogTinyDb
     catalog = CatalogTinyDb()
     plugins = [alpha.AlphaSourcePlugin(catalog)]
     catalog.initialize(plugins)
     results = [{
         'basin3d_id': 'ACT',
         'datasource': {
             'credentials': {},
             'id': 'Alpha',
             'id_prefix': 'A',
             'location': 'https://asource.foo/',
             'name': ''
         },
         'datasource_id': 'Alpha',
         'datasource_variable_id': 'Acetate',
         'observed_property': {
             'datasource': {
                 'credentials': {},
                 'id': 'Alpha',
                 'id_prefix': 'A',
                 'location': 'https://asource.foo/',
                 'name': 'Alpha'
             },
             'datasource_description': '',
             'datasource_variable': 'Acetate',
             'observed_property_variable': {
                 'basin3d_id': 'ACT',
                 'categories': ['Biogeochemistry', 'Anions'],
                 'full_name': 'Acetate '
                 '(CH3COO)',
                 'units': 'mM'
             },
             'sampling_medium': 'WATER'
         },
         'observed_property_variable': {
             'basin3d_id': 'ACT',
             'categories': ['Biogeochemistry', 'Anions'],
             'full_name': 'Acetate (CH3COO)',
             'units': 'mM'
         }
     }, {
         'basin3d_id': 'Ag',
         'datasource': {
             'credentials': {},
             'id': 'Alpha',
             'id_prefix': 'A',
             'location': 'https://asource.foo/',
             'name': ''
         },
         'datasource_id': 'Alpha',
         'datasource_variable_id': 'Ag',
         'observed_property': {
             'datasource': {
                 'credentials': {},
                 'id': 'Alpha',
                 'id_prefix': 'A',
                 'location': 'https://asource.foo/',
                 'name': 'Alpha'
             },
             'datasource_description': '',
             'datasource_variable': 'Ag',
             'observed_property_variable': {
                 'basin3d_id': 'Ag',
                 'categories': ['Biogeochemistry', 'Trace '
                                'elements'],
                 'full_name': 'Silver '
                 '(Ag)',
                 'units': 'mg/L'
             },
             'sampling_medium': 'WATER'
         },
         'observed_property_variable': {
             'basin3d_id': 'Ag',
             'categories': ['Biogeochemistry', 'Trace elements'],
             'full_name': 'Silver (Ag)',
             'units': 'mg/L'
         }
     }, {
         'datasource_id': 'Alpha',
         'datasource': {},
         'datasource_variable_id': 'Aluminum',
         'observed_property': {},
         'basin3d_id': 'Al',
         'observed_property_variable': {}
     }]
     for item in catalog.in_memory_db:
         idx = item.doc_id - 1
         assert results[idx] == item
コード例 #7
0
ファイル: test_catalog.py プロジェクト: BASIN-3D/basin3d
def test_get_observed_property_variables():
    """Test that all of the observed property variable are returned"""
    from tests.testplugins import alpha
    from basin3d.core.catalog import CatalogTinyDb
    catalog = CatalogTinyDb()
    plugins = [alpha.AlphaSourcePlugin(catalog)]
    catalog.initialize(plugins)
    assert [
        'ACT', 'Br', 'Cl', 'DIN', 'DTN', 'F', 'NO3', 'NO2', 'PO4', 'SO4', 'S2',
        'S2O3', 'HCO3', 'DIC', 'DOC', 'NPOC', 'POC', 'TIC', 'TOC', 'd13C',
        'CO2_d13C_soilgas', 'CH4_d13C_soilgas', 'd15N', 'N2O_d15N_soilgas',
        'CO2_d18O_soilgas', 'N2O_d18O_soilgas', 'SO4_d34S', 'U235', 'H2O_d18O',
        'H2O_dD', 'NH4', 'Ca', 'Mg', 'K', 'Si', 'Na', 'MICRO_COV', 'MGO1',
        'MGO2', 'MGO3', 'GENE_TRAN', 'MICRO_PEP', 'MICRO_PLFA', 'NH3', 'CO2',
        'H2', 'H2S', 'CH4', 'N2', 'N2O', 'O2', 'Al', 'Sb', 'As', 'Ba', 'Be',
        'B', 'Cd', 'Cs', 'Co', 'Cu', 'Eu', 'Ge', 'Fe2', 'Hg', 'Pb', 'Li',
        'Mn2', 'Mo', 'Ni', 'Rb', 'Se', 'Ag', 'Sr', 'Th', 'Sn', 'Ti', 'Cr',
        'FeT', 'Mn', 'P', 'U', 'V', 'Zn', 'Zr', 'AT', 'ALB', 'APA', 'APR',
        'DP', 'ET', 'HI', 'PPT', 'PPT_TOT_5', 'PPT_TOT_10', 'PPT_TOT_60',
        'PPT_TOT_DAY', 'UV_IN', 'UV_REF', 'NIR_IN', 'NIR_REF', 'PAR_IN',
        'PAR_REF', 'LWIR_IN', 'LWIR_REF', 'BB_IN', 'BB_REF', 'RH', 'SD', 'SWE',
        'SDEN', 'ST', 'PPT_SF', 'SRAD', 'WBT', 'W_DIR', 'W_GS', 'W_SPD',
        'W_CH', 'ERT', 'CEC', 'EXAFS', 'SEQ', 'XRD', 'XRF', 'XANES', 'HCND',
        'SED_SIZE', 'HCND_Sat', 'Porosity', 'SBD', 'SYD', 'HCND_Unsat',
        'RET_CUR', 'LSE', 'GWF', 'Well logs', 'SAT', 'SDE', 'SMO', 'STM',
        'SWP', 'SEC', 'FDOM', 'DO', 'EC', 'SC', 'SAL', 'GWL', 'PH', 'ORP',
        'RDC', 'SWL', 'WLH', 'WLE', 'WT', 'TDS', 'TSS', 'TRB', 'STO_RES',
        'LAI', 'PLT_HT', 'PAI', 'PFT', 'SAP', 'RGB', 'GCC', 'NDVI'
    ] == [i.basin3d_id for i in catalog.find_observed_property_variables()]

    # This test creates a catalog
    def test_create_catalog():
        from tests.testplugins import alpha
        from basin3d.core.catalog import CatalogTinyDb
        catalog = CatalogTinyDb()
        plugins = [alpha.AlphaSourcePlugin(catalog)]
        catalog.initialize(plugins)
        results = [{
            'basin3d_id': 'ACT',
            'datasource': {
                'credentials': {},
                'id': 'Alpha',
                'id_prefix': 'A',
                'location': 'https://asource.foo/',
                'name': ''
            },
            'datasource_id': 'Alpha',
            'datasource_variable_id': 'Acetate',
            'observed_property': {
                'datasource': {
                    'credentials': {},
                    'id': 'Alpha',
                    'id_prefix': 'A',
                    'location': 'https://asource.foo/',
                    'name': 'Alpha'
                },
                'datasource_description': '',
                'datasource_variable': 'Acetate',
                'observed_property_variable': {
                    'basin3d_id': 'ACT',
                    'categories': ['Biogeochemistry', 'Anions'],
                    'full_name': 'Acetate '
                    '(CH3COO)',
                    'units': 'mM'
                },
                'sampling_medium': 'WATER'
            },
            'observed_property_variable': {
                'basin3d_id': 'ACT',
                'categories': ['Biogeochemistry', 'Anions'],
                'full_name': 'Acetate (CH3COO)',
                'units': 'mM'
            }
        }, {
            'basin3d_id': 'Ag',
            'datasource': {
                'credentials': {},
                'id': 'Alpha',
                'id_prefix': 'A',
                'location': 'https://asource.foo/',
                'name': ''
            },
            'datasource_id': 'Alpha',
            'datasource_variable_id': 'Ag',
            'observed_property': {
                'datasource': {
                    'credentials': {},
                    'id': 'Alpha',
                    'id_prefix': 'A',
                    'location': 'https://asource.foo/',
                    'name': 'Alpha'
                },
                'datasource_description': '',
                'datasource_variable': 'Ag',
                'observed_property_variable': {
                    'basin3d_id': 'Ag',
                    'categories': ['Biogeochemistry', 'Trace '
                                   'elements'],
                    'full_name': 'Silver '
                    '(Ag)',
                    'units': 'mg/L'
                },
                'sampling_medium': 'WATER'
            },
            'observed_property_variable': {
                'basin3d_id': 'Ag',
                'categories': ['Biogeochemistry', 'Trace elements'],
                'full_name': 'Silver (Ag)',
                'units': 'mg/L'
            }
        }, {
            'datasource_id': 'Alpha',
            'datasource': {},
            'datasource_variable_id': 'Aluminum',
            'observed_property': {},
            'basin3d_id': 'Al',
            'observed_property_variable': {}
        }]
        for item in catalog.in_memory_db:
            idx = item.doc_id - 1
            assert results[idx] == item