Ejemplo n.º 1
0
def test_data_set_optional_fields_just_src():
    json = '{"src":"http://foo.com","path":"/mount/path"}'
    with pytest.warns(None) as record:
        dataset = DownloadableContent.from_json(json)
        assert dataset == DownloadableContent(src="http://foo.com",
                                              path="/mount/path")
    assert not record.list
Ejemplo n.º 2
0
def test_data_set_with_enums():
    json = '{"src":"http://foo.com","type":"FILE","status":"DONE","path":"/mount/path"}'
    dataset = DownloadableContent.from_json(json)
    assert dataset == DownloadableContent(src="http://foo.com",
                                          path="/mount/path",
                                          type=FetchedType.FILE,
                                          status=FetcherStatus.DONE)
Ejemplo n.º 3
0
def test_data_set_dont_fail_unknown_fields():
    json = '{"src":"http://foo.com","foo":"bar","path":"/mount/path"}'
    dataset = DownloadableContent.from_json(json)
    assert not hasattr(dataset, "foo")
Ejemplo n.º 4
0
def test_data_set_optional_missing_src():
    json = '{"dst":"http://foo.com", "md5":"42"}'
    with pytest.raises(KeyError):
        DownloadableContent.from_json(json)