示例#1
0
def test_unzip_is_not_a_bool():
    problems = []
    kwargs = DownloadRequirement._parse(varname='FOO',
                                        item=dict(url='http://example.com/', unzip=[]),
                                        problems=problems)
    assert ["Value of 'unzip' for download item FOO should be a boolean, not []."] == problems
    assert kwargs is None
示例#2
0
def test_description_is_not_a_string():
    problems = []
    kwargs = DownloadRequirement._parse(varname='FOO',
                                        item=dict(url='http://example.com/', description=[]),
                                        problems=problems)
    assert ["'description' field for download item FOO is not a string"] == problems
    assert kwargs is None
示例#3
0
def test_use_variable_name_for_filename():
    problems = []
    kwargs = DownloadRequirement._parse(varname='FOO', item='http://example.com/', problems=problems)
    assert [] == problems
    assert kwargs['filename'] == 'FOO'
    assert kwargs['url'] == 'http://example.com/'
    assert not kwargs['unzip']
def test_checksum_is_not_a_string():
    problems = []
    kwargs = DownloadRequirement._parse(varname='FOO',
                                        item=dict(url='http://example.com/',
                                                  md5=[]),
                                        problems=problems)
    assert ['Checksum value for FOO should be a string not [].'] == problems
    assert kwargs is None
def test_download_item_is_none_not_a_string_or_dict():
    problems = []
    kwargs = DownloadRequirement._parse(varname='FOO',
                                        item=None,
                                        problems=problems)
    assert [
        "Download name FOO should be followed by a URL string or a dictionary describing the download."
    ] == problems
    assert kwargs is None
示例#6
0
def test_no_unzip_if_url_ends_in_zip_and_filename_also_does():
    problems = []
    kwargs = DownloadRequirement._parse(varname='FOO',
                                        item=dict(url='http://example.com/bar.zip', filename='something.zip'),
                                        problems=problems)
    assert [] == problems
    assert kwargs['filename'] == 'something.zip'
    assert kwargs['url'] == 'http://example.com/bar.zip'
    assert not kwargs['unzip']
示例#7
0
def test_description_property():
    problems = []
    kwargs = DownloadRequirement._parse(varname='FOO',
                                        item=dict(url='http://example.com/', description="hi"),
                                        problems=problems)
    assert [] == problems
    assert kwargs['description'] == 'hi'
    req = DownloadRequirement(RequirementsRegistry(), **kwargs)
    assert req.title == 'FOO'
示例#8
0
def test_use_unzip_if_url_ends_in_zip():
    problems = []
    kwargs = DownloadRequirement._parse(varname='FOO', item='http://example.com/bar.zip', problems=problems)
    assert [] == problems
    assert kwargs['filename'] == 'bar'
    assert kwargs['url'] == 'http://example.com/bar.zip'
    assert kwargs['unzip']
    req = DownloadRequirement(RequirementsRegistry(), **kwargs)
    assert req.filename == 'bar'
    assert req.url == 'http://example.com/bar.zip'
    assert req.unzip
示例#9
0
def test_allow_manual_override_of_use_unzip_if_url_ends_in_zip():
    problems = []
    kwargs = DownloadRequirement._parse(varname='FOO',
                                        item=dict(url='http://example.com/bar.zip', unzip=False),
                                        problems=problems)
    assert [] == problems
    assert kwargs['filename'] == 'bar.zip'
    assert kwargs['url'] == 'http://example.com/bar.zip'
    assert not kwargs['unzip']

    req = DownloadRequirement(RequirementsRegistry(), **kwargs)
    assert req.filename == 'bar.zip'
    assert req.url == 'http://example.com/bar.zip'
    assert not req.unzip