Skip to content

Commit

Permalink
Update tests to ensure config files are accessed from absolute paths,…
Browse files Browse the repository at this point in the history
… not relative to where the test is being run. (WebOfTrust#227)

Signed-off-by: pfeairheller <pfeairheller@gmail.com>
  • Loading branch information
pfeairheller authored Apr 8, 2024
1 parent 4895803 commit f0be9b6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 55 deletions.
5 changes: 4 additions & 1 deletion src/keria/testing/testing_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""
import json
import os
import pathlib
import shutil
from contextlib import contextmanager

Expand All @@ -23,6 +24,8 @@

from keria.app import agenting, indirecting

SCRIPTS_DIR = str(pathlib.Path(str(pathlib.Path(__file__).parent.resolve()), "../../../tests/scripts").resolve())

WitnessUrls = {
"wan:tcp": "tcp://127.0.0.1:5632/",
"wan:http": "http://127.0.0.1:5642/",
Expand Down Expand Up @@ -521,7 +524,7 @@ def openKeria(salter=None, cf=None, temp=True):
salter = coring.Salter(raw=salt)

if cf is None:
cf = configing.Configer(name="keria", headDirPath="tests/scripts", reopen=True, clear=False)
cf = configing.Configer(name="keria", headDirPath=SCRIPTS_DIR, reopen=True, clear=False)

with habbing.openHby(name="keria", salt=salter.qb64, temp=temp, cf=cf) as hby:
ims = eventing.messagize(serder, sigers=sigers)
Expand Down
11 changes: 6 additions & 5 deletions tests/app/test_agenting.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

from keria.app import agenting, aiding
from keria.core import longrunning
from keria.testing.testing_helper import SCRIPTS_DIR


def test_setup_no_http():
Expand Down Expand Up @@ -63,13 +64,13 @@ def test_load_ends(helpers):
def test_agency():
salt = b'0123456789abcdef'
salter = coring.Salter(raw=salt)
cf = configing.Configer(name="keria", headDirPath="scripts", temp=True, reopen=True, clear=False)
cf = configing.Configer(name="keria", headDirPath=SCRIPTS_DIR, temp=True, reopen=True, clear=False)

with habbing.openHby(name="keria", salt=salter.qb64, temp=True, cf=cf) as hby:
hab = hby.makeHab(name="test")

agency = agenting.Agency(name="agency", base="", bran=None, temp=True, configFile="keria",
configDir="scripts")
configDir=SCRIPTS_DIR)
assert agency.cf is not None
assert agency.cf.path.endswith("scripts/keri/cf/keria.json") is True

Expand Down Expand Up @@ -111,7 +112,7 @@ def test_agency():
shutil.rmtree(f'/usr/local/var/keri/adb/{base}')

agency = agenting.Agency(name="agency", base=base, bran=None, configFile="keria",
configDir="scripts")
configDir=SCRIPTS_DIR)
assert agency.cf is not None
assert agency.cf.path.endswith("scripts/keri/cf/keria.json") is True

Expand All @@ -126,7 +127,7 @@ def test_agency():

# Rcreate the agency to see if agent is reloaded from disk
agency = agenting.Agency(name="agency", base=base, bran=None, configFile="keria",
configDir="scripts")
configDir=SCRIPTS_DIR)
doist.enter(doers=[agency])

agent = agency.get(caid)
Expand Down Expand Up @@ -199,7 +200,7 @@ def test_keystate_ends(helpers):
caid = "ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose"
salt = b'0123456789abcdef'
salter = coring.Salter(raw=salt)
cf = configing.Configer(name="keria", headDirPath="scripts", temp=True, reopen=True, clear=False)
cf = configing.Configer(name="keria", headDirPath=SCRIPTS_DIR, temp=True, reopen=True, clear=False)

with habbing.openHby(name="keria", salt=salter.qb64, temp=True, cf=cf) as hby:
hab = hby.makeHab(name="test")
Expand Down
5 changes: 3 additions & 2 deletions tests/app/test_aiding.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from keria.app import aiding, agenting
from keria.app.aiding import IdentifierOOBICollectionEnd, RpyEscrowCollectionEnd
from keria.core import longrunning
from keria.testing.testing_helper import SCRIPTS_DIR


def test_load_ends(helpers):
Expand Down Expand Up @@ -1426,7 +1427,7 @@ def test_approve_delegation(helpers):
caid = "ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose"
salt = b'0123456789abcdef'
salter = coring.Salter(raw=salt)
cf = configing.Configer(name="keria", headDirPath="scripts", temp=True, reopen=True, clear=False)
cf = configing.Configer(name="keria", headDirPath=SCRIPTS_DIR, temp=True, reopen=True, clear=False)

with habbing.openHby(name="keria", salt=salter.qb64, temp=True, cf=cf) as hby:
hab = hby.makeHab(name="test")
Expand Down Expand Up @@ -1506,7 +1507,7 @@ def test_rotation(helpers):
caid = "ELI7pg979AdhmvrjDeam2eAO2SR5niCgnjAJXJHtJose"
salt = b'0123456789abcdef'
salter = coring.Salter(raw=salt)
cf = configing.Configer(name="keria", headDirPath="scripts", temp=True, reopen=True, clear=False)
cf = configing.Configer(name="keria", headDirPath=SCRIPTS_DIR, temp=True, reopen=True, clear=False)

with habbing.openHby(name="keria", salt=salter.qb64, temp=True, cf=cf) as hby:
hab = hby.makeHab(name="test")
Expand Down
47 changes: 0 additions & 47 deletions tests/testing/test_testing_helper.py

This file was deleted.

0 comments on commit f0be9b6

Please sign in to comment.