-
Notifications
You must be signed in to change notification settings - Fork 39
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
Tests api processor routers #105
Tests api processor routers #105
Conversation
expected_response = get_app_from_ini_config_file_json(config_sample_path) | ||
expected_response["dashboardurl"] = expected_response["dashboard_url"] | ||
del expected_response["dashboard_url"] | ||
|
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.
Why is this change required?
I tested the endpoint /app
and it returns the key "dashboard_url"
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.
I am not sure about that, in my case, when i debug, the endpoint returns the key "dashboardurl". However, my function get_app_from_ini_config_file_json, returns all the keys fine, less "dashboard_url", so we have to change it manually.
assert response.status_code == 200 | ||
expected_response = expected_response_function(config_sample_path) | ||
assert response.json() == expected_response | ||
elif correct_type == "integer": |
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.
Is missing the correct_type == "integer"
case?
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.
I think you meant the "bool" case, I made it explicit now.
api/tests/app/test_app.py
Outdated
response = client.put('/app', json=body) | ||
|
||
expected_response = expected_response_function(config_sample_path) | ||
expected_response_2 = expected_response_default() |
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.
Maybe we can rename the variable as default_response
?
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.
Changed!
8aa8e0f
to
dd4155a
Compare
api/tests/README.md
Outdated
@@ -0,0 +1,10 @@ | |||
###How tests were built | |||
|
|||
To further improve the tests, I made this file to easily understand how they worked. |
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.
To further improve the tests, I made this file to easily understand how they worked. | |
This file aims to clarify how the unitary test work. |
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.
Changed!
api/tests/README.md
Outdated
|
||
To further improve the tests, I made this file to easily understand how they worked. | ||
|
||
The main thing to know is to understand what role fixtures play, especially Config_rollback. |
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.
The main thing to know is to understand what role fixtures play, especially Config_rollback. | |
The main thing to know is to understand what role fixtures play, especially `Config_rollback`. |
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.
Is there another thing to clarify or just Config_rollback?
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.
No, just Config_rollback
api/tests/README.md
Outdated
|
||
The main thing to know is to understand what role fixtures play, especially Config_rollback. | ||
|
||
Config_rollback fixture does the following: |
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.
Config_rollback fixture does the following: | |
The `Config_rollback` fixture does the following: |
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.
Changed!
api/tests/README.md
Outdated
The main thing to know is to understand what role fixtures play, especially Config_rollback. | ||
|
||
Config_rollback fixture does the following: | ||
1. setUp: Initialize the app with a different config file (the one with template in the name). |
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.
1. setUp: Initialize the app with a different config file (the one with template in the name). | |
1. `setUp`: Initializes the app with a different config file (given from the name of an actual config file). |
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.
Changed!
api/tests/README.md
Outdated
|
||
Config_rollback fixture does the following: | ||
1. setUp: Initialize the app with a different config file (the one with template in the name). | ||
2. Returns the client to make the request and also returns the root of the config file. That root is also returned in order to go directly to that file and check if the changes made from our endpoints were valid. |
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.
Does root mean path? or its content? I presume is the path
2. Returns the client to make the request and also returns the root of the config file. That root is also returned in order to go directly to that file and check if the changes made from our endpoints were valid. | |
2. Returns the client to make the request and also the root of the config file. The latter is returned in order to check directly if the endpoints managed to change the said file with the intended updates. |
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.
Thanks, changed!
api/tests/app/test_config.py
Outdated
# The line below is absolutely necessary. Fixtures are passed as arguments to test functions. That is why IDE could | ||
# not recognized them. |
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.
# The line below is absolutely necessary. Fixtures are passed as arguments to test functions. That is why IDE could | |
# not recognized them. | |
# The line below is absolutely necessary. Fixtures are passed as arguments to test functions. | |
# This is why the IDE can't recognize them. |
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.
Changed!
api/tests/app/test_config.py
Outdated
# It is weird that this change does not appear in response.json() | ||
# Because if request was successfully, the PUT request will change the flag "has_been_configured" |
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.
Should this be a FIXME:
comment?
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.
This issue was reported and Pablo has already fixed it. :) The comment will be deleted.
api/tests/utils/fixtures_tests.py
Outdated
|
||
from fastapi.testclient import TestClient | ||
|
||
# from api.tests.utils.common_variables import default |
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.
Should this be deleted?
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.
Yes, deleted!
api/tests/utils/fixtures_tests.py
Outdated
# Here, to import ProcessorAPI successfully, "Settings" must be previously initialized with a config, that is why | ||
# import order matters |
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.
# Here, to import ProcessorAPI successfully, "Settings" must be previously initialized with a config, that is why | |
# import order matters | |
# Import ProcessorAPI after Settings has been initialized with a config. |
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.
Changed!
In this branch, first endpoints tests were added.
All "app" and "config" router endpoints were tested with pytest.