def test_download_clobber(tmpdir, nasa_item): tmpdir.chdir() with IaRequestsMock() as rsps: rsps.add(responses.GET, DOWNLOAD_URL_RE, body="test content") nasa_item.download(files="nasa_meta.xml") rsps.add(responses.GET, DOWNLOAD_URL_RE, body="new test content") nasa_item.download(files="nasa_meta.xml") load_file("nasa/nasa_meta.xml") == "new test content"
def test_download_clobber(tmpdir, nasa_item): tmpdir.chdir() with IaRequestsMock() as rsps: rsps.add(responses.GET, DOWNLOAD_URL_RE, body='test content') nasa_item.download(files='nasa_meta.xml') rsps.add(responses.GET, DOWNLOAD_URL_RE, body='new test content') nasa_item.download(files='nasa_meta.xml') load_file('nasa/nasa_meta.xml') == 'new test content'
def test_download_clobber(tmpdir, nasa_item): tmpdir.chdir() with IaRequestsMock() as rsps: rsps.add(responses.GET, DOWNLOAD_URL_RE, body='test content') nasa_item.download(files='nasa_meta.xml') rsps.reset() rsps.add(responses.GET, DOWNLOAD_URL_RE, body='new test content') nasa_item.download(files='nasa_meta.xml') load_file('nasa/nasa_meta.xml') == 'new test content'
def test_download_checksum(tmpdir, caplog): tmpdir.chdir() # test overwrite based on checksum. with IaRequestsMock() as rsps: rsps.add_metadata_mock('nasa') rsps.add(responses.GET, DOWNLOAD_URL_RE, body='test content') rsps.add(responses.GET, DOWNLOAD_URL_RE, body='overwrite based on md5') nasa_item = get_item('nasa') nasa_item.download(files='nasa_meta.xml') nasa_item.download(files='nasa_meta.xml', checksum=True) assert load_file('nasa/nasa_meta.xml') == 'overwrite based on md5' # test no overwrite based on checksum. rsps.reset() rsps.add(responses.GET, DOWNLOAD_URL_RE, body=load_test_data_file('nasa_meta.xml')) nasa_item.download(files='nasa_meta.xml', checksum=True) nasa_item.download(files='nasa_meta.xml', checksum=True) assert 'skipping nasa' in caplog.text assert 'nasa_meta.xml, file already exists based on checksum.' in caplog.text
def test_download(tmpdir): tmpdir.chdir() with IaRequestsMock() as rsps: rsps.add(responses.GET, '{0}//archive.org/download/nasa/nasa_meta.xml'.format(PROTOCOL), body='test content') rsps.add_metadata_mock('nasa') download('nasa', 'nasa_meta.xml') p = os.path.join(str(tmpdir), 'nasa') assert len(os.listdir(p)) == 1 assert load_file('nasa/nasa_meta.xml') == 'test content'
def test_download_checksum(tmpdir, caplog): tmpdir.chdir() # test overwrite based on checksum. with IaRequestsMock() as rsps: rsps.add_metadata_mock("nasa") rsps.add(responses.GET, DOWNLOAD_URL_RE, body="test content") rsps.add(responses.GET, DOWNLOAD_URL_RE, body="overwrite based on md5") nasa_item = get_item("nasa") nasa_item.download(files="nasa_meta.xml") nasa_item.download(files="nasa_meta.xml", checksum=True) assert load_file("nasa/nasa_meta.xml") == "overwrite based on md5" # test no overwrite based on checksum. rsps.add(responses.GET, DOWNLOAD_URL_RE, body=load_test_data_file("nasa_meta.xml")) nasa_item.download(files="nasa_meta.xml", checksum=True) nasa_item.download(files="nasa_meta.xml", checksum=True) assert "skipping nasa" in caplog.text() assert "nasa_meta.xml, file already exists based on checksum." in caplog.text()
import pytest from tests.conftest import load_file _pulse_content = load_file("clients/pulse.csv") def test_wem_live_balancing_summary() -> None: pass