diff --git a/autopush/db.py b/autopush/db.py index 2b3934dc..03151820 100644 --- a/autopush/db.py +++ b/autopush/db.py @@ -464,7 +464,7 @@ def __init__(self, **kwargs): if "endpoint_url" in conf and not conf["endpoint_url"]: del(conf["endpoint_url"]) region = conf.get("region_name", - os.getenv("AWS_REGION_NAME", "us-east-1")) + os.getenv("AWS_DEFAULT_REGION", "us-east-1")) if "region_name" in conf: del(conf["region_name"]) self.conf = conf diff --git a/autopush/tests/test_db.py b/autopush/tests/test_db.py index 5df008d0..ce7238eb 100644 --- a/autopush/tests/test_db.py +++ b/autopush/tests/test_db.py @@ -99,6 +99,20 @@ def test_ddb_no_endpoint(self, mresource): if safe: os.environ["AWS_LOCAL_DYNAMODB"] = safe + def test_ddb_env(self): + ddb_session_args = dict( + endpoint_url=os.getenv("AWS_LOCAL_DYNAMODB"), + aws_access_key_id="BogusKey", + aws_secret_access_key="BogusKey", + ) + safe = os.getenv("AWS_DEFAULT_REGION") + os.environ["AWS_DEFAULT_REGION"] = "us-west-2" + boto_resource = DynamoDBResource(**ddb_session_args) + assert boto_resource._resource.meta.client.meta.region_name == \ + 'us-west-2' + if safe: + os.environ["AWS_DEFAULT_REGION"] = safe + class DbCheckTestCase(unittest.TestCase): def setUp(cls): diff --git a/autopush/utils.py b/autopush/utils.py index 640f6f34..eed6310c 100644 --- a/autopush/utils.py +++ b/autopush/utils.py @@ -479,7 +479,7 @@ def from_message_table(cls, uaid, item): channel_id=uuid.UUID(key_info["channel_id"]), data=item.get("data"), headers=item.get("headers"), - ttl=item["ttl"], + ttl=item.get("ttl", 0), topic=key_info.get("topic"), message_id=key_info["message_id"], update_id=item.get("updateid"),