@@ -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