コード例 #1
0
def test_file_history_url(database, monkeypatch):
    sub = SubmissionFactory()
    database.session.add(sub)
    database.session.commit()

    # set up certify history so it works
    cert_hist = CertifyHistoryFactory(submission=sub)
    database.session.add(cert_hist)
    database.session.commit()

    file_hist = CertifiedFilesHistoryFactory(certify_history_id=cert_hist.certify_history_id,
                                             submission_id=sub.submission_id, filename="/path/to/file_d2.csv",
                                             warning_filename="/path/to/warning_file_cross.csv",
                                             narrative=None, file_type_id=None)
    database.session.add(file_hist)
    database.session.commit()

    s3_url_handler = Mock()
    s3_url_handler.return_value.get_signed_url.return_value = 'some/url/here.csv'
    monkeypatch.setattr(fileHandler, 'S3Handler', s3_url_handler)

    # checking for local response to non-warning file
    json_response = fileHandler.file_history_url(sub, file_hist.certified_files_history_id, False, True)
    url = json.loads(json_response.get_data().decode('utf-8'))["url"]
    assert url == "/path/to/file_d2.csv"

    # local response to warning file
    json_response = fileHandler.file_history_url(sub, file_hist.certified_files_history_id, True, True)
    url = json.loads(json_response.get_data().decode('utf-8'))["url"]
    assert url == "/path/to/warning_file_cross.csv"

    # generic test to make sure it's reaching the s3 handler properly
    json_response = fileHandler.file_history_url(sub, file_hist.certified_files_history_id, False, False)
    url = json.loads(json_response.get_data().decode('utf-8'))["url"]
    assert url == 'some/url/here.csv'
コード例 #2
0
 def get_certified_file(submission, certified_files_history_id, is_warning):
     """ Get the signed URL for the specified file history """
     return file_history_url(submission, certified_files_history_id, is_warning, is_local)
コード例 #3
0
 def get_certified_file(submission, certified_files_history_id, is_warning):
     """ Get the signed URL for the specified file history """
     return file_history_url(submission, certified_files_history_id, is_warning, is_local)
コード例 #4
0
 def get_submitted_published_file(published_files_history_id):
     """ Get the signed URL for the specified submitted and published file """
     return file_history_url(published_files_history_id, False, is_local)
コード例 #5
0
 def get_certified_file(submission, published_files_history_id, **kwargs):
     """ Get the signed URL for the specified file history """
     is_warning = kwargs.get('is_warning')
     return file_history_url(published_files_history_id, is_warning,
                             is_local, submission)