Skip to content

Feature: Retrive site information trough webservice#7

Merged
erseco merged 5 commits intomainfrom
feat/site-info
Aug 5, 2025
Merged

Feature: Retrive site information trough webservice#7
erseco merged 5 commits intomainfrom
feat/site-info

Conversation

@erseco
Copy link
Owner

@erseco erseco commented Aug 5, 2025

This pull request adds a new "site" command group to the CLI, enabling users to fetch and display detailed Moodle site information. It introduces new data models for site details, extends the session API for generic webservice calls, and provides test coverage for the new functionality.

New CLI feature: Site info commands

  • Added a new site command group to the CLI, allowing users to retrieve site information via py-moodle site info, with output available in both table and JSON formats (src/py_moodle/cli/app.py, src/py_moodle/cli/site.py). [1] [2] [3]

Data modeling and API integration

  • Introduced new dataclasses (SiteInfo, SiteFunction, AdvancedFeature) to model the site information returned by the Moodle API, and implemented the get_site_info function to fetch and parse this data (src/py_moodle/site.py).

Session API improvements

  • Added a generic call method to MoodleSession for making arbitrary Moodle webservice API calls, which is now used to implement site info retrieval (src/py_moodle/session.py). [1] [2]

Testing

  • Added a test to verify that get_site_info correctly retrieves and parses site information from a real Moodle environment (tests/test_site.py).

google-labs-jules bot and others added 3 commits August 5, 2025 07:24
This commit adds a new function to retrieve site information using the
`core_webservice_get_site_info` webservice function.

A new `site` command has been added to the CLI to expose this
functionality. The output can be formatted as a table or as JSON.

A test has been added to ensure the new function works as expected.
The test runs against a real Moodle environment.
@erseco erseco requested a review from Copilot August 5, 2025 07:27
@erseco erseco self-assigned this Aug 5, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request introduces a new CLI command group for retrieving Moodle site information through webservice APIs. The feature allows users to fetch comprehensive site details and display them in either table or JSON format.

  • Adds a new site command group with info subcommand to the CLI
  • Introduces structured data models for site information, functions, and advanced features
  • Extends the session API with a generic call method for arbitrary webservice requests

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/py_moodle/site.py Defines data models (SiteInfo, SiteFunction, AdvancedFeature) and implements get_site_info function
src/py_moodle/session.py Adds generic call method to MoodleSession for webservice API calls
src/py_moodle/cli/site.py Implements site CLI command group with info subcommand and JSON/table output options
src/py_moodle/cli/app.py Registers the new site command group with the main CLI application
tests/test_site.py Adds integration test for get_site_info function
Comments suppressed due to low confidence (1)

tests/test_site.py:7

  • [nitpick] The function name 'test_get_site_info_real' could be clearer. Consider renaming to 'test_get_site_info_integration' or 'test_get_site_info_with_live_session' to better indicate this is an integration test.
def test_get_site_info_real(request):

Comment on lines +28 to +35
class DataclassEncoder(json.JSONEncoder):
def default(self, o):
from dataclasses import asdict, is_dataclass

if is_dataclass(o):
return asdict(o)
return super().default(o)

Copy link

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DataclassEncoder class is defined inside the function scope. Consider moving this to module level or a utility module to improve reusability and avoid recreating the class on each function call.

Suggested change
class DataclassEncoder(json.JSONEncoder):
def default(self, o):
from dataclasses import asdict, is_dataclass
if is_dataclass(o):
return asdict(o)
return super().default(o)

Copilot uses AI. Check for mistakes.
erseco and others added 2 commits August 5, 2025 08:35
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@erseco erseco merged commit cc6caec into main Aug 5, 2025
6 checks passed
@erseco erseco deleted the feat/site-info branch August 5, 2025 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants