-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
144 additions
and
3 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from elasticsearch import Elasticsearch | ||
|
||
from app.settings import settings | ||
|
||
|
||
class Elastic: | ||
def __init__(self) -> None: | ||
self.connection = Elasticsearch( | ||
[settings.elastic_url], | ||
basic_auth=(settings.elastic_user, settings.elastic_password), | ||
) | ||
|
||
def delete_index(self) -> None: | ||
if self.connection.indices.exists(index=settings.elastic_index): | ||
self.connection.indices.delete(index=settings.elastic_index) | ||
|
||
def create_index(self) -> None: | ||
if not self.connection.indices.exists(index=settings.elastic_index): | ||
self.connection.indices.create(index=settings.elastic_index) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
cd "$(dirname "$0")/../.." | ||
|
||
docker-compose -f compose-test.yaml up -d elasticsearch | ||
docker-compose -f compose-test.yaml build api | ||
docker-compose -f compose-test.yaml run --rm api flake8 | ||
docker-compose -f compose-test.yaml run --rm api isort --check-only --quiet --settings pyproject.toml . | ||
docker-compose -f compose-test.yaml run --rm api black --check . | ||
sleep 5 # wait for elasticsearch | ||
docker-compose -f compose-test.yaml run --rm api pytest | ||
docker-compose -f compose-test.yaml rm -fs api |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,8 @@ | ||
from app.settings import settings | ||
from tests.case import TestCase | ||
|
||
|
||
class TestElastic(TestCase): | ||
|
||
def test_index_exists(self): | ||
self.assertTrue(self.elastic.connection.indices.exists(index=settings.elastic_index)) |
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