-
Notifications
You must be signed in to change notification settings - Fork 71
Add missing fields in timer object. #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9aa6299
Added missing fields in timer object.
pdthummar d6a59aa
Reformatted the file.
pdthummar 4cedffb
Reformatted the file.
pdthummar 5eedd26
Added unittest for testing timer.py file.
pdthummar e1b4780
updated the file as per the recommendation.
pdthummar 6e8250f
updated the function name
pdthummar 8d0e018
Added few more tests
pdthummar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
|
vrdmr marked this conversation as resolved.
|
||
|
|
||
| import json | ||
| import unittest | ||
|
|
||
| import azure.functions.timer as timer | ||
| from azure.functions.meta import Datum | ||
|
|
||
|
|
||
| class TestTimer(unittest.TestCase): | ||
| def test_timer_decode(self): | ||
| # given | ||
|
vrdmr marked this conversation as resolved.
|
||
| data = '''{"Schedule":{"AdjustForDST":true}, | ||
| "ScheduleStatus":{ | ||
| "Last":"2022-03-28T15:40:00.0105419-05:00", | ||
| "Next":"2022-03-28T15:45:00-05:00", | ||
| "LastUpdated":"2022-03-28T15:40:00.0105419-05:00"}, | ||
| "IsPastDue":false}''' | ||
| datum: Datum = Datum(value=data, type='json') | ||
| data_dict = json.loads(data) | ||
|
|
||
| # when | ||
| timer_request: timer.TimerRequest = \ | ||
| timer.TimerRequestConverter.decode(datum, trigger_metadata={}) | ||
|
|
||
| # then | ||
| self.assertEqual(timer_request.schedule, data_dict["Schedule"]) | ||
| self.assertEqual(timer_request.schedule_status, | ||
| data_dict["ScheduleStatus"]) | ||
| self.assertEqual(timer_request.past_due, data_dict["IsPastDue"]) | ||
|
|
||
| def test_timer_initialize_without_args(self): | ||
| # given | ||
| past_due = False | ||
| schedule_status = {} | ||
| schedule = {} | ||
|
|
||
| # when | ||
| test_timer = timer.TimerRequest() | ||
|
|
||
| # then | ||
| self.assertEqual(past_due, test_timer.past_due) | ||
| self.assertEqual(schedule_status, test_timer.schedule_status) | ||
| self.assertEqual(schedule, test_timer.schedule) | ||
|
|
||
| def test_timer_no_implementation_exception(self): | ||
| # given | ||
| datum: Datum = Datum(value="test", type='string') | ||
| is_exception_raised = False | ||
|
|
||
| # when | ||
| try: | ||
| timer.TimerRequestConverter.decode(datum, trigger_metadata={}) | ||
| except NotImplementedError: | ||
| is_exception_raised = True | ||
|
|
||
| # then | ||
| self.assertTrue(is_exception_raised) | ||
|
|
||
| def test_timer_input_type(self): | ||
| check_input_type = ( | ||
| timer.TimerRequestConverter.check_input_type_annotation | ||
| ) | ||
| self.assertTrue(check_input_type(timer.TimerRequest)) | ||
| self.assertFalse(check_input_type(str)) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@YunchuWang - Getting your input here - If we plan to add PyDocs here - what could we add here?
@pdthummar No need to worry in this PR (mostly). But we should explore adding more PyDoc comments as they eventually show up in azure.functions.timerrequest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vrdmr would suggest giving a overview what this class does, adding definition of each field in init, and link to https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer?tabs=in-process&pivots=programming-language-java#attributes