コード例 #1
0
def test_extension_from_content_type(rf, httpserver):
    httpserver.serve_content("{}", headers={"content-type": "text/csv"})
    v.data_input(
        fake_cove_middleware(rf.post("/", {"source_url": httpserver.url})))
    supplied_datas = SuppliedData.objects.all()
    assert len(supplied_datas) == 1
    assert supplied_datas[0].original_file.name.endswith(".csv")
コード例 #2
0
ファイル: test_input.py プロジェクト: datadesign-works/cove
def test_extension_from_content_type(rf, httpserver):
    httpserver.serve_content('{}', headers={'content-type': 'text/csv'})
    v.data_input(
        fake_cove_middleware(rf.post('/', {'source_url': httpserver.url})))
    supplied_datas = SuppliedData.objects.all()
    assert len(supplied_datas) == 1
    assert supplied_datas[0].original_file.name.endswith('.csv')
コード例 #3
0
def test_extension_from_content_disposition(rf, httpserver):
    httpserver.serve_content(
        "{}", headers={"content-disposition": 'attachment; filename="something.csv"'}
    )
    v.data_input(fake_cove_middleware(rf.post("/", {"source_url": httpserver.url})))
    supplied_datas = SuppliedData.objects.all()
    assert len(supplied_datas) == 1
    assert supplied_datas[0].original_file.name.endswith(".csv")
コード例 #4
0
ファイル: test_input.py プロジェクト: datadesign-works/cove
def test_connection_error(rf):
    resp = v.data_input(
        fake_cove_middleware(
            rf.post('/', {'source_url': 'http://localhost:1234'})))
    assert b'Connection refused' in resp.content

    resp = v.data_input(
        fake_cove_middleware(
            rf.post('/', {'source_url': 'https://wrong.host.badssl.com/'})))
    assert b'doesn't match either of' in resp.content
コード例 #5
0
ファイル: test_input.py プロジェクト: OpenDataServices/cove
def test_extension_from_content_disposition(rf, httpserver):
    httpserver.serve_content('{}', headers={
        'content-disposition': 'attachment; filename="something.csv"'
    })
    v.data_input(fake_cove_middleware(rf.post('/', {
        'source_url': httpserver.url
    })))
    supplied_datas = SuppliedData.objects.all()
    assert len(supplied_datas) == 1
    assert supplied_datas[0].original_file.name.endswith('.csv')
コード例 #6
0
def test_connection_error(rf):
    resp = v.data_input(
        fake_cove_middleware(
            rf.post("/", {"source_url": "http://localhost:1234"})))
    assert b"Connection refused" in resp.content

    resp = v.data_input(
        fake_cove_middleware(
            rf.post("/", {"source_url": "https://wrong.host.badssl.com/"})))
    assert b"doesn't match either of" in resp.content
コード例 #7
0
ファイル: test_input.py プロジェクト: OpenDataServices/cove
def test_extension_from_content_type(rf, httpserver):
    httpserver.serve_content('{}', headers={
        'content-type': 'text/csv'
    })
    v.data_input(fake_cove_middleware(rf.post('/', {
        'source_url': httpserver.url
    })))
    supplied_datas = SuppliedData.objects.all()
    assert len(supplied_datas) == 1
    assert supplied_datas[0].original_file.name.endswith('.csv')
コード例 #8
0
ファイル: test_input.py プロジェクト: OpenDataServices/cove
def test_connection_error(rf):
    resp = v.data_input(fake_cove_middleware(rf.post('/', {
        'source_url': 'http://localhost:1234'
    })))
    assert b'Connection refused' in resp.content

    resp = v.data_input(fake_cove_middleware(rf.post('/', {
        'source_url': 'https://wrong.host.badssl.com/'
    })))
    assert b'doesn't match either of' in resp.content
コード例 #9
0
ファイル: test_input.py プロジェクト: datadesign-works/cove
def test_directory_for_empty_filename(rf):
    '''
    Check that URLs ending in / correctly create a directory, to test against
    regressions of https://github.com/OpenDataServices/cove/issues/426
    '''
    v.data_input(
        fake_cove_middleware(
            rf.post('/', {'source_url': 'http://example.org/'})))
    supplied_datas = SuppliedData.objects.all()
    assert len(supplied_datas) == 1
    assert os.path.isdir(supplied_datas[0].upload_dir())
コード例 #10
0
ファイル: test_input.py プロジェクト: OpenDataServices/cove
def test_directory_for_empty_filename(rf):
    '''
    Check that URLs ending in / correctly create a directory, to test against
    regressions of https://github.com/OpenDataServices/cove/issues/426
    '''
    v.data_input(fake_cove_middleware(rf.post('/', {
        'source_url': 'http://example.org/'
    })))
    supplied_datas = SuppliedData.objects.all()
    assert len(supplied_datas) == 1
    assert os.path.isdir(supplied_datas[0].upload_dir())
コード例 #11
0
def test_connection_error(rf):
    resp = v.data_input(
        fake_cove_middleware(rf.post("/", {"source_url": "http://localhost:1234"}))
    )
    assert b"Connection refused" in resp.content

    resp = v.data_input(
        fake_cove_middleware(
            rf.post("/", {"source_url": "https://wrong.host.badssl.com/"})
        )
    )
    # https://docs.djangoproject.com/en/3.2/releases/3.0/#miscellaneous
    assert b"doesn't match either of" in resp.content or b"doesn't match either of" in resp.content
コード例 #12
0
ファイル: test_input.py プロジェクト: OpenDataServices/cove
def test_input_post(rf):
    resp = v.data_input(fake_cove_middleware(rf.post('/', {
        'source_url': 'https://raw.githubusercontent.com/OpenDataServices/flatten-tool/master/flattentool/tests/fixtures/tenders_releases_2_releases.json'
    })))
    assert resp.status_code == 302
    assert SuppliedData.objects.count() == 1
    data = SuppliedData.objects.first()
    assert resp.url.endswith(str(data.pk))
コード例 #13
0
ファイル: test_input.py プロジェクト: datadesign-works/cove
def test_input_post(rf):
    resp = v.data_input(
        fake_cove_middleware(
            rf.post(
                '/', {
                    'source_url':
                    'https://raw.githubusercontent.com/OpenDataServices/flatten-tool/master/flattentool/tests/fixtures/tenders_releases_2_releases.json'
                })))
    assert resp.status_code == 302
    assert SuppliedData.objects.count() == 1
    data = SuppliedData.objects.first()
    assert resp.url.endswith(str(data.pk))
コード例 #14
0
ファイル: test_input.py プロジェクト: datadesign-works/cove
def test_http_error(rf):
    resp = v.data_input(
        fake_cove_middleware(
            rf.post('/', {'source_url': 'http://google.co.uk/cove'})))
    assert b'Not Found' in resp.content
コード例 #15
0
ファイル: test_input.py プロジェクト: datadesign-works/cove
def test_input(rf):
    resp = v.data_input(fake_cove_middleware(rf.get('/')))
    assert resp.status_code == 200
コード例 #16
0
def test_http_error(rf):
    resp = v.data_input(
        fake_cove_middleware(rf.post("/", {"source_url": "http://google.co.uk/cove"}))
    )
    assert b"Not Found" in resp.content
コード例 #17
0
ファイル: test_input.py プロジェクト: OpenDataServices/cove
def test_input(rf):
    resp = v.data_input(fake_cove_middleware(rf.get('/')))
    assert resp.status_code == 200
コード例 #18
0
ファイル: test_input.py プロジェクト: OpenDataServices/cove
def test_http_error(rf):
    resp = v.data_input(fake_cove_middleware(rf.post('/', {
        'source_url': 'http://google.co.uk/cove'
    })))
    assert b'Not Found' in resp.content
コード例 #19
0
ファイル: views.py プロジェクト: patlachance/cove
def data_input_iati(request):
    return data_input(request,
                      form_classes=iati_form_classes,
                      text_file_name='text.xml')
コード例 #20
0
ファイル: views.py プロジェクト: OpenDataServices/cove
def data_input_iati(request):
    return data_input(request, form_classes=iati_form_classes, text_file_name='text.xml')