Skip to content

Commit de5d8e6

Browse files
committed
Pytests working
1 parent 04cd6a7 commit de5d8e6

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

datajoint/axon.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@
1010
import http.client
1111
import botocore
1212
import botocore.config
13-
from .log import log
13+
from .logging import logger as log
1414
from time import time
1515
import multiprocessing
1616

1717
import boto3
1818
from botocore.credentials import RefreshableCredentials
1919
from botocore.session import get_session
20-
from djsciops import settings as djsciops_settings
2120
try:
2221
# Python 3.4+
2322
if sys.platform.startswith('win'):
@@ -46,7 +45,7 @@
4645
"ROUTE": "/realms/datajoint/protocol/openid-connect",
4746
},
4847
}
49-
issuer = djsciops_settings.get_config()["djauth"]["issuer"]
48+
issuer = "https://keycloak-qa.datajoint.io/realms/datajoint"
5049

5150

5251
def _client_login(
@@ -66,6 +65,7 @@ def _client_login(
6665
)
6766
connection.request("POST", auth_provider_token_route, body, headers)
6867
jwt_payload = json.loads(connection.getresponse().read().decode())
68+
assert "access_token" in jwt_payload, f"Access token not found in response: {jwt_payload=}."
6969
return jwt_payload["access_token"]
7070

7171

docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,5 @@ services:
7575
set -e
7676
pip install -q -e ".[test]"
7777
pip freeze | grep datajoint
78-
pytest --cov-report term-missing --cov=datajoint tests
78+
pytest -vv -xs tests/test_axon.py
7979

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ test = [
4747
"pytest-cov",
4848
"black==24.2.0",
4949
"flake8",
50+
"moto[s3]>=4.2.13",
51+
]
52+
axon = [
53+
"boto3",
5054
]
5155

5256
[project.urls]

tests/test_axon.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
from datajoint.axon import Session
22
import pytest
3-
import moto3
3+
import boto3
4+
from moto import mock_aws
45

56

7+
@pytest.fixture
8+
def moto_account_id():
9+
"""Default account ID for moto"""
10+
return "123456789012"
11+
12+
@mock_aws
613
class TestSession:
714
def test_can_init(self):
815
session = Session(
9-
aws_account_id="123456789012",
16+
aws_account_id=moto_account_id,
1017
s3_role="test-role",
1118
auth_client_id="test-client-id",
1219
auth_client_secret="test-client-secret",

0 commit comments

Comments
 (0)