diff --git a/.gitignore b/.gitignore index e4f8ff58e..191965988 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ __pycache__/ *.py[cod] venv/ +venv-freeze/ # C extensions *.so diff --git a/app/letters/utils.py b/app/letters/utils.py index c14cc80d1..a293663c1 100644 --- a/app/letters/utils.py +++ b/app/letters/utils.py @@ -135,14 +135,15 @@ def get_letter_pdf(notification): s3 = boto3.resource('s3') bucket = s3.Bucket(bucket_name) - for item in bucket.objects.filter(Prefix=get_bucket_prefix_for_notification(notification, is_test_letter)): - obj = s3.Object( - bucket_name=bucket_name, - key=item.key - ) - file_content = obj.get()["Body"].read() + item = next(x for x in bucket.objects.filter( + Prefix=get_bucket_prefix_for_notification(notification, is_test_letter) + )) - return file_content + obj = s3.Object( + bucket_name=bucket_name, + key=item.key + ) + return obj.get()["Body"].read() def _move_s3_object(source_bucket, source_filename, target_bucket, target_filename): diff --git a/requirements-app.txt b/requirements-app.txt index 613e31c88..500f01f06 100644 --- a/requirements-app.txt +++ b/requirements-app.txt @@ -5,7 +5,7 @@ cffi==1.11.5 celery==3.1.26.post2 # pyup: <4 docopt==0.6.2 Flask-Bcrypt==0.7.1 -flask-marshmallow==0.8.0 +flask-marshmallow==0.9.0 Flask-Migrate==2.2.1 Flask-SQLAlchemy==2.3.2 Flask==1.0.2 @@ -15,16 +15,16 @@ gunicorn==19.7.1 iso8601==0.1.12 jsonschema==2.6.0 marshmallow-sqlalchemy==0.14.0 -marshmallow==2.15.3 +marshmallow==2.15.4 psycopg2-binary==2.7.5 PyJWT==1.6.4 -SQLAlchemy==1.2.9 +SQLAlchemy==1.2.10 -notifications-python-client==4.8.2 +notifications-python-client==5.0.0 # PaaS awscli-cwlogs>=1.4,<1.5 -git+https://github.com/alphagov/notifications-utils.git@29.3.4#egg=notifications-utils==29.3.4 +git+https://github.com/alphagov/notifications-utils.git@29.3.5#egg=notifications-utils==29.3.5 git+https://github.com/alphagov/boto.git@2.43.0-patch3#egg=boto==2.43.0-patch3 diff --git a/requirements.txt b/requirements.txt index 61a7ff250..1d69a09bd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ cffi==1.11.5 celery==3.1.26.post2 # pyup: <4 docopt==0.6.2 Flask-Bcrypt==0.7.1 -flask-marshmallow==0.8.0 +flask-marshmallow==0.9.0 Flask-Migrate==2.2.1 Flask-SQLAlchemy==2.3.2 Flask==1.0.2 @@ -17,17 +17,17 @@ gunicorn==19.7.1 iso8601==0.1.12 jsonschema==2.6.0 marshmallow-sqlalchemy==0.14.0 -marshmallow==2.15.3 +marshmallow==2.15.4 psycopg2-binary==2.7.5 PyJWT==1.6.4 -SQLAlchemy==1.2.9 +SQLAlchemy==1.2.10 -notifications-python-client==4.8.2 +notifications-python-client==5.0.0 # PaaS awscli-cwlogs>=1.4,<1.5 -git+https://github.com/alphagov/notifications-utils.git@29.3.4#egg=notifications-utils==29.3.4 +git+https://github.com/alphagov/notifications-utils.git@29.3.5#egg=notifications-utils==29.3.5 git+https://github.com/alphagov/boto.git@2.43.0-patch3#egg=boto==2.43.0-patch3 @@ -35,12 +35,12 @@ git+https://github.com/alphagov/boto.git@2.43.0-patch3#egg=boto==2.43.0-patch3 alembic==1.0.0 amqp==1.4.9 anyjson==0.3.3 -awscli==1.15.70 +awscli==1.15.74 bcrypt==3.1.4 billiard==3.3.0.23 bleach==2.1.3 boto3==1.6.16 -botocore==1.10.69 +botocore==1.10.73 certifi==2018.4.16 chardet==3.0.4 click==6.7 diff --git a/requirements_for_test.txt b/requirements_for_test.txt index b26445b34..1555e3d64 100644 --- a/requirements_for_test.txt +++ b/requirements_for_test.txt @@ -1,14 +1,14 @@ -r requirements.txt flake8==3.5.0 moto==1.3.3 -pytest==3.6.3 +pytest==3.7.1 pytest-env==0.6.2 pytest-mock==1.10.0 pytest-cov==2.5.1 -pytest-xdist==1.22.2 +pytest-xdist==1.22.5 coveralls==1.3.0 freezegun==0.3.10 -requests-mock==1.5.0 +requests-mock==1.5.2 # optional requirements for jsonschema strict-rfc3339==0.7 -rfc3987==1.3.7 +rfc3987==1.3.8 diff --git a/tests/app/letters/test_letter_utils.py b/tests/app/letters/test_letter_utils.py index 8d5f5017c..2430c57cf 100644 --- a/tests/app/letters/test_letter_utils.py +++ b/tests/app/letters/test_letter_utils.py @@ -21,13 +21,13 @@ FROZEN_DATE_TIME = "2018-03-14 17:00:00" @pytest.fixture() -@freeze_time(FROZEN_DATE_TIME) def sample_precompiled_letter_notification_using_test_key(sample_letter_notification): sample_letter_notification.template.hidden = True sample_letter_notification.template.name = PRECOMPILED_TEMPLATE_NAME sample_letter_notification.key_type = KEY_TYPE_TEST sample_letter_notification.reference = 'foo' - sample_letter_notification.created_at = datetime.utcnow() + with freeze_time(FROZEN_DATE_TIME): + sample_letter_notification.created_at = datetime.utcnow() return sample_letter_notification