Ejemplo n.º 1
0
def populate_dataset(ds_json):
    ds = Dataset({})
    try:
        ds.name = ds_json['dataset_name']
        ds.url = ds_json['dataset_url']
    except Exception, e:
        print 'Dataset exception: ', e
Ejemplo n.º 2
0
def populate_dataset(ds_json):
    ds = Dataset({})
    try:
        ds.name = ds_json['dataset_name']
        ds.url = ds_json['dataset_url']
    except Exception, e:
        print 'Dataset exception: ', e
Ejemplo n.º 3
0
def test_dataset_special_properties():
    ds = Dataset(json.loads(test_dataset_json))

    assert isinstance(ds, Dataset)

    assert ds.release_dt == '2014-01-01T00:00:00'
    with pytest.raises(ValueError):
        ds.release_dt = '2014-01-01T99:00:00'

    assert ds.publication_year == '2014'
    ds.publication_year = '2014 (projected)'
    assert ds.publication_year == '2014'
    ds.publication_year = 'TBD'
    assert ds.publication_year is None

    assert ds.access_dt == '2011-12-31T00:00:00'

    #This one was subtle. Make sure as_json() still works with properties.
    ds_json_out = json.loads(ds.as_json())
    assert ds_json_out['access_dt'] == '2011-12-31T00:00:00'
Ejemplo n.º 4
0
def populate_dataset(ds_json):
    try:
        if not ds_json['dataset_name']:
            raise ValueError('Dataset name is missing')

        ds = Dataset(
            {
                'name': ds_json['dataset_name'],
                'url': ds_json['dataset_url']
            },
            known_ids=trans.DATASET_IDS)

    except Exception, e:
        warning('Dataset exception: ', e)
        ds = None
Ejemplo n.º 5
0
def test_parent():
    f = Figure(json.loads(test_figure_json))
    assert f.parents == []

    ds = Dataset(json.loads(test_dataset_json))
    assert isinstance(ds, Dataset)

    p = Parent.from_obj(ds)
    assert isinstance(p, Parent)
    assert isinstance(p.publication, Dataset)

    f.add_parent(p)
    assert len(f.parents) == 1
    assert f.parents[0] == p
    assert f.parents[0].relationship == 'prov:wasDerivedFrom'
    assert f.parents[0].publication_type_identifier == 'dataset'
    assert f.parents[0].url == '/dataset/cddv2'
    assert f.parents[0].label == 'Climate Division Database Version 2'
Ejemplo n.º 6
0
def test_dataset_special_properties():
    ds = Dataset(json.loads(test_dataset_json))

    assert isinstance(ds, Dataset)

    assert ds.release_dt == '2014-01-01T00:00:00'
    with pytest.raises(ValueError):
        ds.release_dt = '2014-01-01T99:00:00'

    assert ds.publication_year == '2014'
    ds.publication_year = '2014 (projected)'
    assert ds.publication_year == '2014'
    ds.publication_year = 'TBD'
    assert ds.publication_year is None

    assert ds.access_dt == '2011-12-31T00:00:00'

    #This one was subtle. Make sure as_json() still works with properties.
    ds_json_out = json.loads(ds.as_json())
    assert ds_json_out['access_dt'] == '2011-12-31T00:00:00'