Pytest: customize test discovery through command line - unit-testing

There are ways to configure pytest test discovery through configuration file .
I wonder if there are ways to configure pytest test discovery through command line options/args. In other words, can I just pass some argument/switch to pytest command to achieve this?

Every entry you put in the config file (so-called "inioption") can be passed from command line using the -o/--override-ini option. The -o option can be applied multiple times. E.g.
$ pytest -o python_files='check_*.py' \
-o python_classes=Check \
-o python_functions='*_check'
Source: Configuration Options.

Related

Generating gRPC files for Flutter and Golang using Make file

Is this the right Make file code if I want to deploy my Golang server on Amazon AWS EC2 with this configuration:
Im not allowed to embed image so click here to see the image
Here is the Make File Code:
Shipping package
Assumes user is on MacOS, if other OS, please change PROTO_ROOT_DIR to the path of protobuf installation PROTO_ROOT_DIR = $(shell brew
--prefix)/Cellar/protobuf/3.6.0/include PROJECT_NAME = hello-grpc
Dart requires you to manually ship all google provided proto files too.
_gendart: #mkdir -p model/gen/ship/dart #protoc -I=model/protodefs --dart_out=grpc:model/gen/ship/dart model/protodefs/.proto #protoc -I$(PROTO_ROOT_DIR) --dart_out=model/gen/ship/dart $(PROTO_ROOT_DIR)/google/protobuf/.proto
_gengo: #mkdir -p model/gen #protoc -I=model/protodefs --go_out=plugins=grpc:model/gen model/protodefs/*.proto
gen: _gengo _gendart
build: get gen #env CGO_ENABLED=0 GOOS=linux GOARCH=386 go build
-ldflags '-w -extldflags "-static"' -o build/${PROJECT_NAME}_linux_amd64 . #env GOARCH=amd64 go build
-ldflags '-w -extldflags "-static"' -o build/${PROJECT_NAME}_macosx_amd64 .
get: #go get -u github.com/golang/dep/cmd/dep #dep ensure
install: get gen #cp config_template.json config.json
My confusion is that for building files for Amazon AWS EC2 with the above configuration I need to use (assuming my server go file name is main):
GOOS=linux GOARCH=amd64 go build -o main
But in the Make file this "GOARCH=386" is mentioned in this line:
build: get gen #env CGO_ENABLED=0 GOOS=linux GOARCH=386 go build
What could be the right make file code when Im building Go gRPC Server on Mac OS for the above mentioned Amazon AWS EC2 instance
Please help me :(

TravisCI : Setup two jobs with different configurations

I am setting up an automated Travis CI CI, and was wondering if it is possible to launch two jobs (same tests) with two different configurations.
My app depends on a config.json file, which sets up different DB usages (json and mongo). My use case is simple: run the tests with a config file using json and run the same tests using another config file with mongo.
To retrieve config I'm running a before script which just gets it from somewhere and saves the file.
Thanks!
My solution for this is quite simple, depending on the configuration (in this case env variables), I run specific scripts that download different configurations for each env variable.
before_script:
- sh -c "if [ '$DB' = 'mongo' ]; then sleep 15; fi"
- sh -c "if [ '$DB' = 'mongo' ]; then wget https://google.com/config.json; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then wget https://google.com/config2.json; fi"
That way when the code runs, you can load different configurations

AWS CLI command completion with fish shell

Has anybody been able to set up auto-complete for the AWS CLI with fish shell? The AWS documentation only offers the guide for bash, tcsh, and zsh.
Bash exports the variables COMP_LINE and COMP_POINT that is used by the aws_completer script provided by the Amazon. Is there any equivalent for fish? I'm new with the fish shell and I'm giving it a try.
Building upon David Roussel's answers I cooked up the following:
function __fish_complete_aws
env COMP_LINE=(commandline -pc) aws_completer | tr -d ' '
end
complete -c aws -f -a "(__fish_complete_aws)"
Put this in a file $HOME/.config/fish/completions/aws.fish so fish can autoload it when necessary.
aws_completer appends a space after every option it prints and that gets escaped as \ so trimming it solves the trailing backslashes.
Now we can test the completion with the following:
> complete -C'aws co'
codebuild
codecommit
codepipeline
codestar
cognito-identity
cognito-idp
cognito-sync
comprehend
comprehendmedical
connect
configure
configservice
Using the commandline -c helps if you move back the cursor since it cuts the command line at the cursor so aws_completer can offer the right completions.
I also want to get his to work, and I've made some progress, but it's not perfect.
First I look some advise from here which helps to seem how to emulate the bash environment variables that as_completer expects.
Putting it together I get this:
complete -c aws -f -a '(begin; set -lx COMP_SHELL fish; set -lx COMP_LINE (commandline); /usr/local/bin/aws_completer; end)'
That mostly works but I get spurious extra slashes, so if I try to complete "aws ec2 describe-instances --" I get:
dave#retino ~> aws ec2 describe-instances --
--ca-bundle\ --color\ --filters\ --no-dry-run\ --output\ --region\
--cli-connect-timeout\ --debug\ --generate-cli-skeleton --no-paginate\ --page-size\ --starting-token\
--cli-input-json\ --dry-run\ --instance-ids\ --no-sign-request\ --profile\ --version\
--cli-read-timeout\ --endpoint-url\ --max-items\ --no-verify-ssl\ --query\
It looks to me like there is a trailing whitespace char, but I tried to remove it using sed:
complete -c aws -f -a '(begin; set -lx COMP_SHELL fish; set -lx COMP_LINE (commandline); echo (/usr/local/bin/aws_completer | sed -e \'s/[ ]*//\') ; end)'
But this doesn't seem to help. It seems that fish expects a different output format than bash for it's completer. And indeed the fish decimation for the complete builtin doe say that it expects a space separated list.
So I tried joining the lines with xargs:
complete -c aws -f -a '(begin; set -lx COMP_SHELL fish; set -lx COMP_LINE (commandline); echo (/usr/local/bin/aws_completer | sed -e \'s/[ ]*//\') | xargs echo ; end)'
But this doesn't work either. I just get one completion
This is annoying, I'm so close, but it doesn't work!
While the provided answer doesn't answer the question directly about the using fish; I intend to provide an answer to help in the context of auto-completion & shell.
Amazon has launched a new CLI based tool forked from AWSCLI.
aws-shell is a command-line shell program that provides convenience
and productivity features to help both new and advanced users of the
AWS Command Line Interface. Key features include the following.
Fuzzy auto-completion
Commands (e.g. ec2, describe-instances, sms, create-queue)
Options (e.g. --instance-ids, --queue-url)
Resource identifiers (e.g. Amazon EC2 instance IDs, Amazon SQS queue URLs, Amazon SNS topic names)
Dynamic in-line documentation
Documentation for commands and options are displayed as you type
Execution of OS shell commands
Use common OS commands such as cat, ls, and cp and pipe inputs and outputs without leaving the shell
Export executed commands to a text editor To find out more, check out the related blog post on AWS Command Line Interface blog.
Add this line to your .config/fish/config.fish
complete --command aws --no-files --arguments '(begin; set --local --export COMP_SHELL fish; set --local --export COMP_LINE (commandline); aws_completer | sed \'s/ $//\'; end)'
In case you want to make sure that aws-cli is installed:
test -x (which aws_completer); and complete --command aws --no-files --arguments '(begin; set --local --export COMP_SHELL fish; set --local --export COMP_LINE (commandline); aws_completer | sed \'s/ $//\'; end)'
All credits belong to this issue thread and a comment by an awesome SO contributor #scooter-dangle.
It's actually possible to map bash's completion to fish's.
See the npm completions.
However it's probably still better to write a real fish script (it's not hard!).
The command I use in my virtualenv/bin/activate is this:
complete -C aws_completer aws
Looks like aws-cli has fish support too. There is a bundled installer provided with aws-cli that might be worth checking out: activate.fish. I found it in the same bin directory as the aws command.
For example:
ubuntu#ip-xxx-xx-x-xx:/data/src$ tail -n1 ~/venv/bin/activate
complete -C aws_completer aws
ubuntu#ip-xxx-xx-x-xx:/data/src$ source ~/venv/bin/activate
(venv) ubuntu#ip-xxx-xx-x-xx:/data/src$ aws s3 <- hitting TAB here
cp ls mb mv presign rb rm sync website
(venv) ubuntu#ip-xxx-xx-x-xx:/data/src$ aws s3

Can you use pmrep createConnection command with parameter in Password

Is there a way to create a connection in Informatica from the pmrep command line tool with the "Use Parameter in Password" option? This is simple from the GUI I need to automate the process via a script.
Here is the command I am running:
pmrep createconnection -s Oracle -n DummyConn -u $ParamTEST_DB_USERNAME -p $ParamTEST_DB_PASSWORD -c TEST123 -l US-ASCII
I have tried the following without luck:
-p option which simply treats the password as a normal
-P option which complains there is no environment variable by that name
-k with "Use Parameter In Password"=true
-P is the correct way to go for you.
But before running the command you need to run these 2 commands :
export $ParamTEST_DB_USERNAME= << Your Username >>
export $ParamTEST_DB_PASSWORD= << Password encrypted with pmpasswd >>
The rest of your command seems fine

How to use conditional in .ebextensions config (AWS Elastic Beanstalk)

I wish I could use conditional for .ebextensions configuration, but I don't know how to use it, my current case are :
One of .ebextensions configuration content are create a folder, actually the folder that must be created it's only once, because if I'm deploying app for second times or more I've got error, and the error said "the folder already exist".
So I need to give conditional, if the folder already exist it's not necessary to run again the command for create a folder.
If anyone has any insight or direction on how this can be achieved, I would greatly appreciate it. Thank you!
The .ebextensions config files allow conditional command execution by using the test: directive on a command. Then the command only runs if the test is true (returns 0).
Example .ebextensions/create_dir.config file:
commands:
01_create_dir:
test: test ! -d "${DIR}"
command: mkdir "${DIR}"
Another example (actually tested on EB) to conditionally run a script if a directory is not there:
commands:
01_intall_foo:
test: test ! -d /home/ec2-user/foo
command: "/home/ec2-user/install-foo.sh"
cwd: "/home/ec2-user/"
The sparse documentation from AWS is here:
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html#customize-containers-format-commands
PS.
If you just need to conditionally create the directory, you can do it without conditionals, using the -p option for mkdir to conditionally create the directory like so:
commands:
01_create_dir:
command: mkdir -p "${DIR}"
I think that the only way to do it is with shell conditions:
commands:
make-directory:
command: |
if [ ! -f "${DIR}" ]; then
mkdir "${DIR}"
fi
See bigger example in jcabi-beanstalk-maven-plugin.