def test_simple_download_days_old_1(): with patch('skyfield.io.urlopen', lambda url: BytesIO(b'FOOBAR')): write_file('data.txt', 'BAZ') download_file(url='http://foo.com/data.txt', filename='data.txt', days_old=1) assert open('data.txt', 'rb').read() == b'BAZ' os.remove('data.txt')
def test_simple_download(): httpretty.register_uri(httpretty.GET, 'http://foo.com/data.txt', body='FOOBAR') download_file(url='http://foo.com/data.txt', filename='data.txt') assert os.path.exists('data.txt') assert open('data.txt', 'rb').read() == b'FOOBAR' os.remove('data.txt')
def test_simple_download_days_old_0(): httpretty.register_uri(httpretty.GET, 'http://foo.com/data.txt', body='FOOBAR') write_file('data.txt', 'BAZ') download_file(url='http://foo.com/data.txt', filename='data.txt', days_old=0) assert open('data.txt', 'rb').read() == b'FOOBAR' os.remove('data.txt')
def test_simple_download(): with patch('skyfield.io.urlopen', lambda url: BytesIO(b'FOOBAR')): download_file(url='http://foo.com/data.txt', filename='data.txt') assert os.path.exists('data.txt') assert open('data.txt', 'rb').read() == b'FOOBAR' os.remove('data.txt')