Skip to content

Commit

Permalink
Merge pull request #108 from launchableinc/ST-716
Browse files Browse the repository at this point in the history
[ST-716] add debug option to print payload
  • Loading branch information
Konboi authored Jan 25, 2021
2 parents 2848c44 + 2109617 commit 6574433
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions launchable/commands/record/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,14 @@
type=str,
metavar='BUILD_NAME'
)
@click.option(
'--debug',
help='print request payload',
default=False,
is_flag=True,
)
@click.pass_context
def tests(context, base_path: str, session_id: str, build_name: str):
def tests(context, base_path: str, session_id: str, build_name: str, debug: bool):
if session_id and build_name:
raise click.UsageError(
'Only one of -build or -session should be specified')
Expand Down Expand Up @@ -137,14 +143,12 @@ def payload():
yield json.dumps(CaseEvent.from_case_and_suite(self.path_builder, case, suite, p))
yield ']}'

# TODO: this probably should be a flag
if True:
# generator adapter that prints the content
def printer(f):
for d in f:
print(d)
yield d
payload = printer(payload())
def printer(f):
for d in f:
print(d)
yield d

payload = printer(payload()) if debug else payload()

# str -> bytes then gzip compress
payload = (s.encode() for s in payload)
Expand Down

0 comments on commit 6574433

Please sign in to comment.