Skip to content

Commit 85031b1

Browse files
committed
Test plugin root_dir
1 parent b4a7059 commit 85031b1

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

tests/test_plugin.py

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pytest
12
from pyflowlauncher.plugin import Plugin
23

34

@@ -28,4 +29,25 @@ def test_add_methods():
2829
def test_settings():
2930
plugin = Plugin()
3031
plugin._client.recieve = lambda: {'method': 'settings', 'parameters': [], 'settings': {'test': 'test'}}
31-
assert plugin.settings == {'test': 'test'}
32+
assert plugin.settings == {'test': 'test'}
33+
34+
35+
def test_run_dir(tmp_path, monkeypatch):
36+
monkeypatch.setattr('sys.argv', [tmp_path / 'plugin.py'])
37+
plugin = Plugin()
38+
assert plugin.plugin_run_dir() == tmp_path
39+
40+
41+
def test_root_dir(tmp_path, monkeypatch):
42+
monkeypatch.setattr('sys.argv', [tmp_path / 'plugin.py'])
43+
monkeypatch.setattr('pyflowlauncher.plugin.Path.exists', lambda _: True)
44+
plugin = Plugin()
45+
assert plugin.plugin_root_dir() == tmp_path
46+
47+
48+
def test_root_dir_not_found(tmp_path, monkeypatch):
49+
monkeypatch.setattr('sys.argv', [tmp_path / 'plugin.py'])
50+
monkeypatch.setattr('pyflowlauncher.plugin.Path.exists', lambda _: False)
51+
plugin = Plugin()
52+
with pytest.raises(FileNotFoundError):
53+
assert plugin.plugin_root_dir() == tmp_path

0 commit comments

Comments
 (0)