-
Notifications
You must be signed in to change notification settings - Fork 4
reQueueMovie and getMovieStatus endpoints #51
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
dgarciabriseno
merged 4 commits into
Helioviewer-Project:main
from
akash5100:movies_endpoint
Aug 8, 2022
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| from typing import Optional | ||
|
|
||
| from hvpy.io import HvpyParameters, OutputType | ||
|
|
||
|
|
||
| class getMovieStatusInputParameters(HvpyParameters): | ||
| """ | ||
| Handles the input parameters of the ``getMovieStatus`` API. | ||
|
|
||
| Attributes | ||
| ---------- | ||
| {Shared} | ||
| id | ||
| Unique movie identifier, returned as a response by the ``queueMovie`` endpoint request. | ||
| format | ||
| Movie format. | ||
| verbose | ||
| Optionally include extra metadata in the response. | ||
| Defaults to `False`. | ||
| callback | ||
| Wrap the response object in a function call of your choosing. | ||
| Default is `None` (no wrapping), optional. | ||
| token | ||
| API token. | ||
| Defaults to `None`. | ||
|
|
||
| References | ||
| ---------- | ||
| * `<https://api.helioviewer.org/docs/v2/api/api_groups/movies.html#id8>`__ | ||
| {Shared} | ||
| """ | ||
|
|
||
| id: str | ||
| format: str | ||
| verbose: Optional[bool] = False | ||
| callback: Optional[str] = None | ||
| token: Optional[str] = None | ||
|
|
||
| def get_output_type(self) -> OutputType: | ||
| """ | ||
| Returns the output type of the API call. | ||
| """ | ||
| if self.callback is not None: | ||
| return OutputType.STRING | ||
| return OutputType.JSON | ||
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,32 @@ | ||
| from typing import Optional | ||
|
|
||
| from hvpy.io import HvpyParameters, OutputType | ||
|
|
||
|
|
||
| class reQueueMovieInputParameters(HvpyParameters): | ||
| """ | ||
| Handles the input parameters of the ``reQueueMovie`` API. | ||
|
nabobalis marked this conversation as resolved.
|
||
|
|
||
| Attributes | ||
| ---------- | ||
| {Shared} | ||
| id | ||
| Unique movie identifier, returned as a response by the ``queueMovie`` endpoint request. | ||
| force | ||
| Boolean to force the re-queueing of the movie. | ||
| Defaults to `False`, optional. | ||
|
|
||
| References | ||
| ---------- | ||
| * `<https://api.helioviewer.org/docs/v2/api/api_groups/movies.html#id2>`__ | ||
| {Shared} | ||
| """ | ||
|
|
||
| id: str | ||
| force: Optional[bool] = False | ||
|
|
||
| def get_output_type(self) -> OutputType: | ||
| """ | ||
| Returns the output type of the API call. | ||
| """ | ||
| return OutputType.JSON | ||
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,48 @@ | ||
| import pytest | ||
|
|
||
| from hvpy import getMovieStatus | ||
| from hvpy.api_groups.movies.get_movie_status import getMovieStatusInputParameters | ||
|
|
||
|
|
||
| def test_json_response(): | ||
| response = getMovieStatus( | ||
| id="VXvX5", | ||
| format="mp4", | ||
| ) | ||
| assert response["url"] is not None | ||
| assert response["status"] is not None | ||
|
|
||
|
|
||
| def test_str_response(): | ||
| response = getMovieStatus( | ||
| id="VXvX5", | ||
| format="mp4", | ||
| callback="myCallback", | ||
| ) | ||
| assert response.startswith("myCallback(") | ||
|
|
||
|
|
||
| def test_error_hanpytestdling(): | ||
| with pytest.raises(TypeError, match="missing 1 required positional argument: 'id'"): | ||
| getMovieStatus( | ||
| format="mp4", | ||
| verbose=False, | ||
| callback=None, | ||
| token=None, | ||
| ) | ||
|
|
||
| with pytest.raises(TypeError, match="missing 1 required positional argument: 'format'"): | ||
| getMovieStatus( | ||
| id="VXvX5", | ||
| verbose=False, | ||
| callback=None, | ||
| token=None, | ||
| ) | ||
|
|
||
|
|
||
| def test_url_property(): | ||
| params = getMovieStatusInputParameters( | ||
| id="VXvX5", | ||
| format="mp4", | ||
| ) | ||
| assert params.url == "https://api.helioviewer.org/v2/getMovieStatus/" |
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,22 @@ | ||
| import pytest | ||
|
|
||
| from hvpy import reQueueMovie | ||
| from hvpy.api_groups.movies.re_queue_movie import reQueueMovieInputParameters | ||
|
|
||
|
|
||
| def test_json_response(): | ||
| response = reQueueMovie(id="gxRN5", force=True) | ||
| assert response["id"] is not None | ||
| assert response["eta"] is not None | ||
| assert response["queue"] is not None | ||
| assert response["token"] is not None | ||
|
|
||
|
|
||
| def test_error_handling(): | ||
| with pytest.raises(TypeError, match="missing 1 required positional argument: 'id'"): | ||
| reQueueMovie() | ||
|
|
||
|
|
||
| def test_url_property(): | ||
| params = reQueueMovieInputParameters(id="gxRN5") | ||
| assert params.url == "https://api.helioviewer.org/v2/reQueueMovie/" |
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
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.
Uh oh!
There was an error while loading. Please reload this page.