fake-api-server.ci.surveillance.model.compare¶
This module is responsible for comparing local and remote API configurations to detect and summarize any differences. It provides functionality to identify API changes, including additions, updates, and deletions, and records these changes with statistical and detailed summaries.
This module is new in version 0.2.0.
Classes:
-
APIChangeType: Enum defining the types of changes (add, update, delete).
-
ChangeStatistical: Records the count for each type of API change.
-
ChangeSummary: Tracks detailed changes for each API, grouped by type.
-
ChangeDetail: Combines statistical and detailed summaries, with methods to record changes.
-
CompareInfo: Handles comparison between local and remote API configurations, detecting changes and updating the ChangeDetail instance.
APIChangeType
¶
Bases: Enum
Represents the types of API changes.
This enumeration defines constants representing the different types of changes that can occur within an API. It can be used to provide a clear distinction between additions, updates, and deletions for better management and understanding of API modifications.
ATTRIBUTE | DESCRIPTION |
---|---|
ADD |
Represents the addition of a new element (e.g., endpoint or feature) in the API.
|
UPDATE |
Represents the modification or update of an existing element in the API.
|
DELETE |
Represents the removal or deprecation of an element in the API.
|
ChangeDetail(statistical=ChangeStatistical(), summary=ChangeSummary())
dataclass
¶
Encapsulates details of changes, including statistical data and summary information.
This class is responsible for maintaining detailed records of changes, including
tracking statistical data and summarizing changes for specific types of API changes.
It uses ChangeStatistical
and ChangeSummary
as components to store this information
and provides a method for recording new changes by their type and association with a
specific API context.
ATTRIBUTE | DESCRIPTION |
---|---|
statistical |
Tracks the statistical counts of changes categorized by change type.
TYPE:
|
summary |
Provides a summary of the changes categorized by change type, mapping API URLs to the respective HTTP methods affected.
TYPE:
|
record_change(api, change_type)
¶
Records and tracks changes in API statistics and summaries based on the reported change type and HTTP request method. This method updates the statistical counts and summaries for specific APIs with their associated change types.
PARAMETER | DESCRIPTION |
---|---|
api
|
MockAPI object representing the API whose changes are being recorded.
TYPE:
|
change_type
|
Enum
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
None
|
None |
Source code in fake_api_server_plugin/ci/surveillance/model/compare.py
ChangeStatistical(add=0, delete=0, update=0)
dataclass
¶
Represents statistical data for changes, including additions, deletions, and updates.
This class is used to track the count of different types of changes that may occur in a given process or dataset. The attributes include additions, deletions, and updates. The class can serve as a container for this data and provide an organized way to manage the statistics.
ATTRIBUTE | DESCRIPTION |
---|---|
add |
The number of additions made.
TYPE:
|
delete |
The number of deletions made.
TYPE:
|
update |
The number of updates made.
TYPE:
|
ChangeSummary(add=dict(), delete=dict(), update=dict())
dataclass
¶
Represents a summary of changes applied to HTTP methods across various endpoints.
This class is designed to organize and store the information about additions,
deletions, and updates of HTTP methods for specific endpoints. By categorizing
changes into add
, delete
, and update
, it facilitates tracking and managing
modifications made to an application's API.
ATTRIBUTE | DESCRIPTION |
---|---|
add |
Records newly added HTTP methods for specific endpoints. Each key represents an endpoint, and the corresponding value is a list of added HTTP methods.
TYPE:
|
delete |
Keeps track of HTTP methods that were removed for specific endpoints. Each key represents an endpoint, and the value is a list of deleted HTTP methods.
TYPE:
|
update |
Holds information about HTTP methods that were updated for specific endpoints. Each key represents an endpoint, and the value is a list of updated HTTP methods.
TYPE:
|
CompareInfo(local_model, remote_model, change_detail=ChangeDetail())
dataclass
¶
Represents a comparison between local and remote API configurations.
CompareInfo is designed to compare two API configurations (local and remote) and identify any differences between them. It also records changes such as added, updated, or deleted APIs.
ATTRIBUTE | DESCRIPTION |
---|---|
local_model |
The local API configuration to be compared.
TYPE:
|
remote_model |
The remote API configuration to be compared.
TYPE:
|
change_detail |
Records details about changes identified during comparison.
TYPE:
|
has_different()
¶
Checks if there are differences between the API configurations of the local model and the remote model. The function compares both the existence and content of the APIs in each model and flags any discrepancies.
RETURNS | DESCRIPTION |
---|---|
bool
|
A boolean indicating whether there are differences between the local and remote API configurations. |
RAISES | DESCRIPTION |
---|---|
AssertionError
|
If any API configuration in either local or remote model is |