Exemple #1
0
def test_variable():
    tas = Variable(uri='http://data.test.org/tas.nc', var_name='tas')
    assert tas.var_name == 'tas'
    assert tas.uri == 'http://data.test.org/tas.nc'
    assert 'uri' in tas.json
    assert 'id' in tas.json
    assert Variable.from_json(tas.json).var_name == 'tas'
    assert tas.id in str(tas)
Exemple #2
0
def test_variable_compat():
    tas_data = {
        "id": "tas|v0",
        "uri": "http://somewhere/test.nc",
        "domain": "d0"
    }
    # from json
    tas = Variable.from_json(tas_data)
    assert tas.id == 'tas|v0'
    assert tas.var_name == 'tas'
    assert tas.uri == 'http://somewhere/test.nc'
    assert tas.domain == 'd0'
    # json
    assert tas.json['id'] == 'tas|v0'
    assert tas.json['uri'] == 'http://somewhere/test.nc'
    assert tas.json['domain'] == 'd0'