39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
|
"""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})"
|