Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ all: build test lint
.PHONY: dev
dev: export APPUID = $(APP_UID)
dev: setup_mounts
@docker-compose build && docker-compose up -d web celery
@docker-compose up --build -d web celery

## make build : Build and start docker containers - (web and db)
.PHONY: build
build:
@docker-compose up --build web -d
@docker-compose up --build -d web

.PHONY: down
down: export APPUID = $(APP_UID)
Expand All @@ -37,20 +37,26 @@ down:
logs:
@docker-compose logs -ft

## Run tests with coverage
.PHONY: test
test: export APPUID = $(APP_UID)
test: setup_mounts
ensure_web_container_for_test:
@if [ $$(docker ps -a -f name=dev | wc -l) -eq 2 ]; then \
docker exec dev python -m pytest --version; \
else \
echo "No containers running.. Starting Django runserver:"; \
make build; \
echo "Running Tests"; \
fi

@docker exec dev python -m pytest -v --cov --disable-warnings;\
echo "Tests finished."
## Run tests with coverage
.PHONY: test
test: export APPUID = $(APP_UID)
test: setup_mounts ensure_web_container_for_test
@if [ "$(TESTS)" = "" ]; then \
echo "No arguments passed to make test. Running all tests.."; \
docker exec dev python -m pytest -v --cov --disable-warnings; \
echo "Tests finished."; \
else \
echo "Running tests with filter $(TESTS)"; \
docker exec dev python -m pytest -v --cov --disable-warnings -k '$(TESTS)'; \
fi

## Create lint issues file
.PHONY: lint_issues
Expand Down
4 changes: 2 additions & 2 deletions config.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"localhost"
],
"CSRF_TRUSTED_ORIGINS": [
""
"http://localhost"
]
},
"sso": {
Expand All @@ -21,7 +21,7 @@
"username": "",
"password": "",
"host": "",
"port":
"port": 3306
},
"access_modules": {
"git_urls": [
Expand Down
34 changes: 34 additions & 0 deletions docs/“How-to” guides/Running Tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Running Unit Tests

To run all tests in the code-base, run the following on the root directory for `enigma-public-central`

```bash
make test
```

This will also clone the access modules repo added in config.json and run tests within them.

## How it works

It first ensures that the `web` container running the enigma webserver is up and running.
Then the `make` script will run the `pytest` command as a subshell in the running container.

In case the `web` container is not up, it will first start it.

## Running specific tests

To run specific subset of `pytest` tests, you can add a pass a test filter to the make command, which forwards the filter to `pytest` cli.

Example,

```bash
make test TESTS="test_aws_access"
```

OR

```bash
make test TESTS="test_aws_access or test_grant_gcp_access"
```

Please check this [link](https://docs.pytest.org/en/7.3.x/example/markers.html#using-k-expr-to-select-tests-based-on-their-name) to understand what expressions are supported