Add spawner config tests
This commit is contained in:
parent
2333ccd168
commit
f1f6526daa
2 changed files with 44 additions and 2 deletions
38
tests/test_spawner.py
Normal file
38
tests/test_spawner.py
Normal file
|
@ -0,0 +1,38 @@
|
|||
"""Test GLiCID spawner module."""
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
import glicid_spawner.spawner
|
||||
from batchspawner import SlurmSpawner
|
||||
from glicid_spawner import GlicidSpawner
|
||||
|
||||
User = namedtuple('User', 'name')
|
||||
|
||||
|
||||
def test_spawner_config():
|
||||
"""Test spawner configuration."""
|
||||
spawner = GlicidSpawner()
|
||||
|
||||
assert isinstance(spawner, GlicidSpawner)
|
||||
assert isinstance(spawner, SlurmSpawner)
|
||||
|
||||
assert spawner.glicid_singleuser_cmd == 'glicid-spawner-singleuser'
|
||||
assert spawner.batchspawner_singleuser_cmd == 'glicid-spawner-singleuser'
|
||||
|
||||
|
||||
def test_spawner_options_form(monkeypatch):
|
||||
"""Test spawner options form."""
|
||||
monkeypatch.setattr(
|
||||
glicid_spawner.spawner, 'options_form', lambda username: f"options_form('{username}')"
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
glicid_spawner.spawner,
|
||||
'options_from_form',
|
||||
lambda formdata: f'options_from_form({formdata})',
|
||||
)
|
||||
|
||||
spawner = GlicidSpawner(user=User('john-doe'))
|
||||
|
||||
assert spawner.user.name == 'john-doe'
|
||||
assert spawner.options_form() == "options_form('john-doe')"
|
||||
assert spawner.options_from_form({'foo': 123}) == "options_from_form({'foo': 123})"
|
Loading…
Add table
Add a link
Reference in a new issue