Esempio n. 1
0
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')
Esempio n. 2
0
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')
Esempio n. 3
0
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')
Esempio n. 4
0
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')
Esempio n. 5
0
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')
Esempio n. 6
0
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')