forked from jbjbjb1/TogglCon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_lambda_handler.py
41 lines (32 loc) · 1.13 KB
/
test_lambda_handler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
""" export TOGGL_API_KEY='your_toggl_api_key_here'
export WORKSPACE_ID='your_workspace_id_here'
export USER_EMAIL='[email protected]'
or for Windows
set TOGGL_API_KEY=your_toggl_api_key_here
set WORKSPACE_ID=your_workspace_id_here
set [email protected] """
import os
import togglcon
def test_lambda_handler():
# Fetch environment variables
togglapikey = os.getenv('TOGGL_API_KEY')
workspace_ID = os.getenv('WORKSPACE_ID')
email = os.getenv('USER_EMAIL')
# Mock event and context
event = {
'togglapikey': togglapikey,
'date': '2024-08-21', # This is the date fromat from API
'email': email,
'workspace_ID': workspace_ID
}
context = {} # In most cases, context can be left as an empty dict
# Call the lambda_handler function with the mocked event and context
response = togglcon.lambda_handler(event, context)
# Print the response to see the output
print('Status Code:', response['statusCode'])
print('Response Body:', response['body'])
print('\n')
print(response)
# Run the test
if __name__ == "__main__":
test_lambda_handler()