Examples
qa_pytest_examples
__all__ = ['CombinedConfiguration', 'CombinedSteps', 'Credentials', 'RabbitMqSelfConfiguration', 'SwaggerPetstoreConfiguration', 'SwaggerPetstoreCredentials', 'SwaggerPetstorePet', 'SwaggerPetstoreSteps', 'TerminalXConfiguration', 'TerminalXCredentials', 'TerminalXSteps', 'TerminalXUser']
module-attribute
CombinedConfiguration
Bases: SwaggerPetstoreConfiguration
, TerminalXConfiguration
Combined configuration that inherits settings from both SwaggerPetstoreConfiguration and TerminalXConfiguration. Useful for scenarios requiring both sets of configuration.
Source code in qa-pytest-examples/src/qa_pytest_examples/combined_configuration.py
12 13 14 15 16 17 18 |
|
CombinedSteps
Bases: SwaggerPetstoreSteps[CombinedConfiguration]
, TerminalXSteps[CombinedConfiguration]
Combined steps implementation that inherits step definitions from both SwaggerPetstoreSteps and TerminalXSteps, using CombinedConfiguration. Useful for scenarios requiring both sets of step logic in a single test suite.
Source code in qa-pytest-examples/src/qa_pytest_examples/combined_steps.py
6 7 8 9 10 11 12 13 14 |
|
Credentials
dataclass
Represents user credentials with username and password.
Source code in qa-pytest-examples/src/qa_pytest_examples/model/credentials.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
password
instance-attribute
username
instance-attribute
__init__(username, password)
from_(colon_separated)
classmethod
Creates a Credentials instance from a colon-separated string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
colon_separated
|
str
|
String in the format 'username:password'. |
required |
Returns:
Name | Type | Description |
---|---|---|
Credentials |
The created credentials instance. |
Source code in qa-pytest-examples/src/qa_pytest_examples/model/credentials.py
17 18 19 20 21 22 23 24 25 26 27 28 |
|
RabbitMqSelfConfiguration
Bases: RabbitMqConfiguration
Configuration for self-contained RabbitMQ test scenarios. Inherits all settings from RabbitMqConfiguration and can be extended for test-specific overrides or additional configuration.
Source code in qa-pytest-examples/src/qa_pytest_examples/rabbitmq_self_configuration.py
6 7 8 9 10 11 12 |
|
SwaggerPetstoreConfiguration
Bases: RestConfiguration
Configuration for Swagger Petstore REST API tests. Inherits from RestConfiguration.
Source code in qa-pytest-examples/src/qa_pytest_examples/swagger_petstore_configuration.py
8 9 10 11 12 13 |
|
SwaggerPetstoreCredentials
dataclass
Bases: Credentials
Credentials for Swagger Petstore users. Inherits from Credentials.
Source code in qa-pytest-examples/src/qa_pytest_examples/model/swagger_petstore_credentials.py
10 11 12 13 14 15 16 |
|
__init__(username, password)
SwaggerPetstorePet
dataclass
Represents a pet in the Swagger Petstore API.
Source code in qa-pytest-examples/src/qa_pytest_examples/model/swagger_petstore_pet.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
name
instance-attribute
status
instance-attribute
__init__(name, status)
from_(response)
staticmethod
Parses a response and yields SwaggerPetstorePet objects for each valid pet entry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
response
|
Response
|
The HTTP response containing pet data. |
required |
Returns: Iterator[SwaggerPetstorePet]: Iterator over parsed pets.
Source code in qa-pytest-examples/src/qa_pytest_examples/model/swagger_petstore_pet.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
random(range=range(1))
staticmethod
Generates a random SwaggerPetstorePet with a unique name and 'available' status.
Returns:
Name | Type | Description |
---|---|---|
SwaggerPetstorePet |
Iterator['SwaggerPetstorePet']
|
The generated pet. |
Source code in qa-pytest-examples/src/qa_pytest_examples/model/swagger_petstore_pet.py
24 25 26 27 28 29 30 31 32 33 |
|
SwaggerPetstoreSteps
Bases: RestSteps[TConfiguration]
BDD-style step definitions for Swagger Petstore API operations.
Type Parameters
TConfiguration: The configuration type, must be a SwaggerPetstoreConfiguration.
Source code in qa-pytest-examples/src/qa_pytest_examples/swagger_petstore_steps.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
adding(pet)
Adds a pet to the Swagger Petstore via the API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pet
|
SwaggerPetstorePet
|
The pet to add. |
required |
Returns: Self: The current step instance for chaining.
Source code in qa-pytest-examples/src/qa_pytest_examples/swagger_petstore_steps.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|
swagger_petstore(client)
Sets the REST session to use for subsequent steps.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
client
|
Session
|
The HTTP client session. |
required |
Returns: Self: The current step instance for chaining.
Source code in qa-pytest-examples/src/qa_pytest_examples/swagger_petstore_steps.py
29 30 31 32 33 34 35 36 37 38 39 40 |
|
the_available_pets(by_rule)
Asserts that the available pets match the provided matcher rule.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
by_rule
|
Matcher[Iterator[SwaggerPetstorePet]]
|
Matcher for the available pets iterator. |
required |
Returns: Self: The current step instance for chaining.
Source code in qa-pytest-examples/src/qa_pytest_examples/swagger_petstore_steps.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
TerminalXConfiguration
Bases: SeleniumConfiguration
Configuration for TerminalX Selenium-based tests. Provides access to users and random user selection.
Source code in qa-pytest-examples/src/qa_pytest_examples/terminalx_configuration.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
|
random_user
property
Returns a random user from the list of users.
Returns:
Name | Type | Description |
---|---|---|
TerminalXUser |
TerminalXUser
|
A randomly selected user. |
users
cached
property
Returns the list of TerminalX users from the configuration parser.
Returns:
Type | Description |
---|---|
List[TerminalXUser]
|
List[TerminalXUser]: The list of users. |
TerminalXCredentials
dataclass
Bases: Credentials
Credentials for TerminalX users. Inherits from Credentials.
Source code in qa-pytest-examples/src/qa_pytest_examples/model/terminalx_credentials.py
10 11 12 13 14 15 16 |
|
__init__(username, password)
TerminalXSteps
Bases: SeleniumSteps[TConfiguration]
BDD-style step definitions for TerminalX UI operations using Selenium.
Type Parameters
TConfiguration: The configuration type, must be a TerminalXConfiguration.
Source code in qa-pytest-examples/src/qa_pytest_examples/terminalx_steps.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
|
clicking_login()
Clicks the login button on the TerminalX landing page.
Returns:
Name | Type | Description |
---|---|---|
Self |
Self
|
The current step instance for chaining. |
Source code in qa-pytest-examples/src/qa_pytest_examples/terminalx_steps.py
38 39 40 41 42 43 44 45 |
|
clicking_search()
Clicks the search button in the TerminalX header.
Returns:
Name | Type | Description |
---|---|---|
Self |
Self
|
The current step instance for chaining. |
Source code in qa-pytest-examples/src/qa_pytest_examples/terminalx_steps.py
47 48 49 50 51 52 53 54 55 56 |
|
logging_in_with(credentials)
Logs in using the provided credentials.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
credentials
|
TerminalXCredentials
|
The credentials to use for login. |
required |
Returns: Self: The current step instance for chaining.
Source code in qa-pytest-examples/src/qa_pytest_examples/terminalx_steps.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
searching_for(text)
Types the given text into the search box.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text
|
str
|
The text to search for. |
required |
Returns: Self: The current step instance for chaining.
Source code in qa-pytest-examples/src/qa_pytest_examples/terminalx_steps.py
99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
submitting_login()
Clicks the submit button on the login form.
Returns:
Name | Type | Description |
---|---|---|
Self |
Self
|
The current step instance for chaining. |
Source code in qa-pytest-examples/src/qa_pytest_examples/terminalx_steps.py
58 59 60 61 62 63 64 65 |
|
terminalx(driver)
Sets the Selenium WebDriver and navigates to the landing page.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
driver
|
WebDriver
|
The Selenium WebDriver instance. |
required |
Returns: Self: The current step instance for chaining.
Source code in qa-pytest-examples/src/qa_pytest_examples/terminalx_steps.py
24 25 26 27 28 29 30 31 32 33 34 35 36 |
|
the_search_hints(by_rule)
Asserts that the search hints match the provided matcher rule.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
by_rule
|
Matcher[Iterator[str]]
|
Matcher for the search hints iterator. |
required |
Returns: Self: The current step instance for chaining.
Source code in qa-pytest-examples/src/qa_pytest_examples/terminalx_steps.py
113 114 115 116 117 118 119 120 121 122 123 124 125 |
|
the_user_logged_in(by_rule)
Asserts that the user is logged in by checking the profile button text.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
by_rule
|
Matcher[str]
|
Matcher for the user name text. |
required |
Returns: Self: The current step instance for chaining.
Source code in qa-pytest-examples/src/qa_pytest_examples/terminalx_steps.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
TerminalXUser
dataclass
Represents a TerminalX user with credentials and a display name.
Source code in qa-pytest-examples/src/qa_pytest_examples/model/terminalx_user.py
10 11 12 13 14 15 16 17 |
|