This repository has been archived by the owner on Jul 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
squad_client/commands/download_attachments: Attachment download command
Add an attachment download command to squad-client to download attachments from a given TestRun. Signed-off-by: Katie Worton <[email protected]>
- Loading branch information
1 parent
6659fa1
commit ce36f78
Showing
3 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from squad_client import logging | ||
from squad_client.core.command import SquadClientCommand | ||
from squad_client.core.models import TestRun | ||
from squad_client.shortcuts import download_attachments | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class DownloadAttachmentsCommand(SquadClientCommand): | ||
command = "download-attachments" | ||
help_text = "download the attachments from a SQUAD testrun" | ||
|
||
def register(self, subparser): | ||
parser = super(DownloadAttachmentsCommand, self).register(subparser) | ||
parser.add_argument( | ||
"--testrun", | ||
help="The SQUAD ID of the testrun", | ||
type=int, | ||
required=True, | ||
) | ||
parser.add_argument( | ||
"--filenames", | ||
nargs="+", | ||
help="If not all files are required, specify the names of the files to download", | ||
) | ||
parser.add_argument( | ||
"--debug", | ||
action='store_true', | ||
help="Set debug mode" | ||
) | ||
|
||
def run(self, args): | ||
if args.debug: | ||
logger.setLevel(logging.DEBUG) | ||
|
||
# Check testrun | ||
testrun = TestRun(args.testrun) | ||
if testrun is None: | ||
logger.error(f"TestRun {args.testrun} not found") | ||
|
||
# Check if requested files exist | ||
return download_attachments(testrun, args.filenames) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters