Skip to content
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

Server API: Get status #56

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Server API: Get status #56

wants to merge 6 commits into from

Conversation

izzzzzi
Copy link

@izzzzzi izzzzzi commented Feb 19, 2025

  • Implement get_status() method in sync and async ServerApi
  • Create Server model to represent server status
  • Update demo.py with server status and database backup examples
  • Add Server import to init.py
  • Fix minor typos in demo.py comments

Zakhar Izmaylov added 2 commits February 19, 2025 16:50
* Implement get_status() method in sync and async ServerApi
* Create Server model to represent server status
* Update demo.py with server status and database backup examples
* Add Server import to __init__.py
* Fix minor typos in demo.py comments
* Add comprehensive tests for get_status() in sync and async APIs
* Implement tests for get_db() method with successful and error scenarios
* Use requests_mock and httpx_mock for mocking API responses
* Improve test coverage for server-related API methods
@iwatkot
Copy link
Owner

iwatkot commented Feb 19, 2025

@izzzzzi, hello!

Thank you for contributing to the project!

Please, fix mypy and pylint errors, they can be found in the action run: https://github.com/iwatkot/py3xui/actions/runs/13414500703/job/37488134601?pr=56

You can also use them locally before pushing the next commits:

pip install mypy
pip install pylint
mypy py3xui
pylint py3xui

Looking forward to hearing from you.

Thank you
Sincerely

@iwatkot iwatkot self-assigned this Feb 19, 2025
@iwatkot iwatkot added the enhancement New feature or request label Feb 19, 2025
@iwatkot iwatkot changed the title Add server status retrieval and database backup functionality Server API: Get status Feb 19, 2025
* Improve server status API methods in sync and async APIs
* Add headers and data handling for server status requests
* Update Server model with more robust field mappings
* Modify demo.py to use simplified email variable
* Add QR code directory creation logic
* Update .gitignore to exclude QR code and database files
* Enhance test_api.py and test_async_api.py with more comprehensive server status response
* Update server status test mocks to include additional fields like CPU cores, network stats, and Xray information
* Modify exception handling in test_get_db_failed to use requests.exceptions.HTTPError
@iwatkot
Copy link
Owner

iwatkot commented Feb 20, 2025

@izzzzzi, hey!

I would suggest to comment the get_db test function back because it does exactly the same thing as before and crashes the tests. :D

* Load server status response from external JSON file in both sync and async tests
* Update test_api.py and test_async_api.py to use shared response file
* Adjust URL endpoints and assertion values to match new response data
* Simplify test mocking and improve test readability
* Replace hardcoded response dictionaries with JSON file loading in test_api.py and test_async_api.py
* Use ApiFields constants for consistent response key references
* Remove commented region markers and unnecessary imports
* Standardize response loading for client traffic and other test scenarios
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants