diff --git a/src/lambda_function.py b/src/lambda_function.py index 39da81e..76c46fb 100644 --- a/src/lambda_function.py +++ b/src/lambda_function.py @@ -157,7 +157,7 @@ def lambda_handler(event, context): return {"success": True} elif event.get("trigger_test_key") == os.environ["TRIGGER_TEST_KEY"]: - daily_executor(os.environ["JAMIES_ATHLETE_ID"]) + return daily_executor(get_user(os.environ["JAMIES_ATHLETE_ID"])) # Catch any error routing or funny business else: diff --git a/test.ipynb b/test.ipynb index b6690d9..e08bf87 100644 --- a/test.ipynb +++ b/test.ipynb @@ -173,56 +173,52 @@ "# upsert_training_week(os.environ[\"DANNYS_ATHLETE_ID\"], response)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Trigger Lambda E2E" + ] + }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 3, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "firstname: Jamie\n", - "lastname: Voynow\n", - "email: voynow99@gmail.com\n", - "preferences: Training for a marathon, prefer workouts on wed and long runs on sat\n", - "profile: https://dgalywyr863hv.cloudfront.net/pictures/athletes/98390356/23289449/16/large.jpg\n", - "is_active: True\n" - ] - } - ], + "outputs": [], "source": [ - "from src.auth_manager import get_strava_client\n", - "from src.supabase_client import get_user\n", + "import requests\n", + "import os\n", "\n", - "user = get_user(98390356)\n", - "athlete = get_strava_client(98390356).get_athlete()\n", + "url = \"https://lwg77yq7dd.execute-api.us-east-1.amazonaws.com/prod/signup\"\n", "\n", - "print(\"firstname:\", athlete.firstname)\n", - "print(\"lastname:\", athlete.lastname)\n", - "print(\"email:\", user.email)\n", - "print(\"preferences:\", user.preferences)\n", - "print(\"profile:\", athlete.profile)\n", - "print(\"is_active:\", user.is_active)\n", - "\n" + "response = requests.post(url, json={\n", + " \"trigger_test_key\": os.environ[\"TRIGGER_TEST_KEY\"]\n", + "})" ] }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 5, "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "Jamie\n", - "Voynow\n", - "https://dgalywyr863hv.cloudfront.net/pictures/athletes/98390356/23289449/16/large.jpg\n" - ] + "data": { + "text/plain": [ + "{'errorMessage': \"'str' object has no attribute 'athlete_id'\",\n", + " 'errorType': 'AttributeError',\n", + " 'requestId': '8efbb5cc-cc5e-4a2d-964d-077e27238abf',\n", + " 'stackTrace': [' File \"/var/task/src/lambda_function.py\", line 160, in lambda_handler\\n daily_executor(os.environ[\"JAMIES_ATHLETE_ID\"])\\n',\n", + " ' File \"/var/task/src/lambda_function.py\", line 109, in daily_executor\\n logging.error(f\"Error processing user {user.athlete_id}: {e}\")\\n']}" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" } ], - "source": [] + "source": [ + "response.json()" + ] }, { "cell_type": "code",