Skip to content

Commit bc7ff78

Browse files
tuan-phamwilliaminfante
authored andcommitted
chore: pydocstyle
1 parent d4235f9 commit bc7ff78

File tree

2 files changed

+52
-3
lines changed

2 files changed

+52
-3
lines changed

pact/broker.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,27 @@ class Broker():
1515
"""PactBroker helper functions."""
1616

1717
def __init__(self, broker_base_url=None, broker_username=None, broker_password=None, broker_token=None):
18+
"""
19+
Create a Broker instance.
20+
21+
:param broker_base_url: URL of the pact broker that pacts will be
22+
published to. Can also be supplied through the PACT_BROKER_BASE_URL
23+
environment variable. Defaults to None.
24+
:type broker_base_url: str
25+
:param broker_username: Username to use when connecting to the pact
26+
broker if authentication is required. Can also be supplied through
27+
the PACT_BROKER_USERNAME environment variable. Defaults to None.
28+
:type broker_username: str
29+
:param broker_password: Password to use when connecting to the pact
30+
broker if authentication is required. Strongly recommend supplying
31+
this value through the PACT_BROKER_PASSWORD environment variable
32+
instead. Defaults to None.
33+
:type broker_password: str
34+
:param broker_token: Authentication token to use when connecting to
35+
the pact broker. Strongly recommend supplying this value through
36+
the PACT_BROKER_TOKEN environment variable instead.
37+
Defaults to None.
38+
"""
1839
self.broker_base_url = broker_base_url
1940
self.broker_username = broker_username
2041
self.broker_password = broker_password

pact/message_pact.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def __init__(
4343
):
4444
"""
4545
Create a Pact instance using messages.
46+
4647
:param consumer: A consumer for this contract that uses messages.
4748
:type consumer: pact.MessageConsumer
4849
:param provider: The generic provider for this contract.
@@ -115,21 +116,49 @@ def given(self, provider_states):
115116
return self
116117

117118
def with_metadata(self, metadata):
119+
"""
120+
Define metadata attached to the message.
121+
122+
:param metadata: dictionary of metadata attached to the message.
123+
:type metadata: dict or None
124+
:rtype: Pact
125+
"""
118126
self._insert_message_if_complete()
119127
self._messages[0]['metaData'] = metadata
120128
return self
121129

122130
def with_content(self, contents):
131+
"""
132+
Define message content (event) that will be use in the message.
133+
134+
:param contents: dictionary of dictionary used in the message.
135+
:type metadata: dict
136+
:rtype: Pact
137+
"""
123138
self._insert_message_if_complete()
124139
self._messages[0]['contents'] = contents
125140
return self
126141

127142
def expects_to_receive(self, description):
143+
"""
144+
Define the name of this contract (Same as upon_receiving in http pact implementation).
145+
146+
:param scenario: A unique name for this contract.
147+
:type scenario: basestring
148+
:rtype: Pact
149+
"""
128150
self._insert_message_if_complete()
129151
self._messages[0]['description'] = description
130152
return self
131153

132154
def write_to_pact_file(self):
155+
"""
156+
Create a pact file based on provided attributes in DSL.
157+
158+
Return 0 if success, 1 otherwise.
159+
160+
:rtype: int
161+
"""
133162
command = [
134163
MESSAGE_PATH,
135164
"update",
@@ -145,6 +174,7 @@ def write_to_pact_file(self):
145174
def _insert_message_if_complete(self):
146175
"""
147176
Insert a new message if current message is complete.
177+
148178
An interaction is complete if it has all the mandatory fields.
149179
If there are no message, a new message will be added.
150180
:rtype: None
@@ -155,9 +185,7 @@ def _insert_message_if_complete(self):
155185
self._messages.insert(0, {})
156186

157187
def __enter__(self):
158-
"""
159-
Enter a Python context. This function is required for context manager to work.
160-
"""
188+
"""Enter a Python context. This function is required for context manager to work."""
161189
pass
162190

163191
def __exit__(self, exc_type, exc_val, exc_tb):

0 commit comments

Comments
 (0)