Skip to content

Commit

Permalink
fixture added.
Browse files Browse the repository at this point in the history
  • Loading branch information
dougransom committed Jan 1, 2023
1 parent 6380905 commit d879331
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

from string import Template
from pathlib import Path
import pytest
from distutils.dir_util import copy_tree
import natlink

thisDir = Path(__file__).parent

@pytest.fixture()
def unimacro_setup(tmpdir):

tmp_test_root = tmpdir

natlink_config_dir=tmp_test_root.mkdir('.natlink')
unimacro_userdir=tmp_test_root.mkdir("unimacro_user_directory")
natlink_config_file=natlink_config_dir/"natlink.ini"

sub={
'unimacrouserdirectory':unimacro_userdir
}
natlinkini_source_folder=Path(__file__).parent / "unimacro_test_natlink_config.natlink"
natlinkini_source_config = natlinkini_source_folder/"natlink.ini"
with open(natlinkini_source_config) as f:
src=Template(f.read())
config_file_text=src.substitute(sub)

print(f"natlink_config_dir: f{natlink_config_dir}")
with open(natlink_config_file,'w') as fw:
fw.write(config_file_text)

#copy the unimacro user directory to the unimacro_user_directory
copy_tree(str(thisDir/"test_sample_unimacro_userdir"),str(unimacro_userdir))

pytest.MonkeyPatch().setenv("NATLINK_USERDIR",str(natlink_config_dir))
oo=natlink.natConnect()
yield [natlink_config_dir,unimacro_userdir,oo]
natlink.natDisconnect()




def test_foo(unimacro_setup):
pass

33 changes: 33 additions & 0 deletions tests/unimacro_test_natlink_config.natlink/natlink.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[directories]
vocoladirectory = vocola2
vocolagrammarsdirectory = natlink_userdir\vocolagrammars
unimacrodirectory = unimacro
unimacrogrammarsdirectory = unimacro\unimacrogrammars

[settings]
log_level = DEBUG
load_on_startup = True
load_on_begin_utterance = False
load_on_mic_on = True
load_on_user_changed = True

[manual configuration]
instruction1 = set next line in the directories section when you
instruction2 = want to define a Natlink user directory, independent of
instruction3 = any package, like Dragonfly, Unimacro or Vocola.
instruction4 = Note: you can drop a python grammar file in any of the directories,
instruction5 = the distinction is made for package updates, and for convenience
natlinkuserdirectory = ~\Documents\UserDirectory

[vocola]
vocolatakesunimacroactions = True
vocolauserdirectory = ~\OneDrive\doug\VocolaGrammars

[unimacro]
unimacrouserdirectory = $unimacrouserdirectory

[settings.debugadapterprotocol]
dap_enabled = True
dap_port = 7474
dap_wait_for_debugger_attach_on_startup = True

0 comments on commit d879331

Please sign in to comment.