-
Notifications
You must be signed in to change notification settings - Fork 3
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
5 changed files
with
73 additions
and
6 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
.git | ||
.gitignore |
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,3 @@ | ||
ve/ | ||
.cache/ | ||
seaworthy/__pycache__/ |
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,40 @@ | ||
from seaworthy.containers.redis import RedisContainer | ||
from seaworthy.containers.rabbitmq import RabbitMQContainer | ||
from seaworthy.definitions import ContainerDefinition | ||
from seaworthy.pytest.fixtures import resource_fixture | ||
|
||
|
||
class JunebugContainer(ContainerDefinition): | ||
IMAGE = 'praekeltfoundation/junebug' | ||
WAIT_PATTERNS = ( | ||
'Junebug is listening on', | ||
) | ||
|
||
def __init__(self, name, create_kwargs): | ||
super().__init__(name, self.IMAGE, self.WAIT_PATTERNS, | ||
create_kwargs=create_kwargs) | ||
|
||
redis_fixture = resource_fixture(RedisContainer(), 'redis') | ||
rabbitmq_fixture = resource_fixture(RabbitMQContainer(), 'rabbitmq') | ||
|
||
container = JunebugContainer('junebug', create_kwargs={ | ||
'ports': { | ||
"80/tcp": None | ||
}, | ||
'environment': { | ||
'AUTH_USERNAME': 'guest', | ||
'AUTH_PASSWORD': 'password', | ||
'AMQP_HOST': 'rabbitmq', | ||
'AMQP_VHOST': '/junebug', | ||
'REDIS_HOST': 'redis', | ||
}}) | ||
|
||
junebug_fixture = container.pytest_fixture( | ||
'junebug_container', dependencies=('redis', 'rabbitmq')) | ||
|
||
# Allow all the fixtures to be imported like `from fixtures import *` | ||
__all__ = [ | ||
"redis_fixture", | ||
"rabbitmq_fixture", | ||
"junebug_fixture", | ||
] |
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,23 @@ | ||
import pytest | ||
|
||
# from seaworthy.logs import output_lines | ||
|
||
from fixtures import * # noqa: F401,F403 | ||
|
||
|
||
class TestJunebugContainer: | ||
|
||
def test_with_authentication(self, junebug_container): | ||
client = junebug_container.http_client() | ||
response = client.get("/jb/channels/", auth=('guest', 'password')) | ||
assert response.status_code == 200 | ||
|
||
def test_without_authentication(self, junebug_container): | ||
client = junebug_container.http_client() | ||
response = client.get("/jb/channels/") | ||
assert response.status_code == 401 | ||
|
||
def test_health(self, junebug_container): | ||
client = junebug_container.http_client() | ||
response = client.get("/jb/health") | ||
assert response.status_code == 200 |