Skip to content

Commit

Permalink
added simple test for htcondor pool and job
Browse files Browse the repository at this point in the history
  • Loading branch information
eileen-kuehn committed Apr 8, 2019
1 parent 28f35e9 commit 442cb15
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lapis/pool_io/htcondor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def htcondor_pool_reader(iterable, resource_name_mapping: dict={
:param resource_name_mapping: Mapping from given header names to well-defined resources in simulation
:param pool_type: The type of pool to be yielded
:param make_drone:
:return: Yields the :py:class:`StaticPool`s found in the given iterable
:return: Yields the :py:class:`Pool`s found in the given iterable
"""
assert make_drone
reader = csv.DictReader(iterable, delimiter=' ', skipinitialspace=True)
Expand Down
5 changes: 5 additions & 0 deletions lapis_tests/data/htcondor_pools.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Count TotalSlotCPUs TotalSlotDisk TotalSlotMemory
2 2 224400.0 8000
2 2 223100.0 8000
1 8 196300.0 32200
1 4 29700.0 8000
Empty file added lapis_tests/pool_io/__init__.py
Empty file.
24 changes: 24 additions & 0 deletions lapis_tests/pool_io/test_htcondor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os

import pytest

from lapis.pool_io.htcondor import htcondor_pool_reader


def data_path():
return os.path.join(os.path.dirname(__file__), "..", "data", "htcondor_pools.csv")


class TestHtcondorPoolReader(object):
def test_init(self):
with open(data_path()) as input_file:
with pytest.raises(AssertionError):
next(htcondor_pool_reader(input_file))

def test_simple(self):
with open(data_path()) as input_file:
pools = 0
for pool in htcondor_pool_reader(input_file, make_drone=lambda: None):
assert pool is not None
pools += 1
assert pools > 0
17 changes: 17 additions & 0 deletions lapis_tests/test_job.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import pytest

from lapis.job import Job


class TestJob(object):
def test_init(self):
with pytest.raises(AssertionError):
Job({}, {})
assert Job({}, {"walltime": 100})

def test_name(self):
name = "test"
job = Job({}, {"walltime": 100}, name=name)
assert job.name == name
job = Job({}, {"walltime": 100})
assert job.name == id(job)

0 comments on commit 442cb15

Please sign in to comment.