Skip to content

Commit

Permalink
Add test for executor
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-janssen committed Apr 24, 2024
1 parent 3e54b36 commit 6c32950
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion tests/test_flux.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# Copyright (c) Jan Janssen

import os
from time import sleep
import unittest

import pandas
from pysqa import QueueAdapter
from pysqa.executor.executor import Executor


try:
Expand All @@ -16,11 +16,17 @@
skip_flux_test = True


def funct_add(a, b):
return a+b


@unittest.skipIf(skip_flux_test, "Flux is not installed, so the flux tests are skipped.")
class TestFluxQueueAdapter(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.path = os.path.dirname(os.path.abspath(__file__))
cls.test_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), "cache")
os.makedirs(cls.test_dir, exist_ok=True)
cls.flux = QueueAdapter(directory=os.path.join(cls.path, "config/flux"))

def test_config(self):
Expand Down Expand Up @@ -106,3 +112,18 @@ def test_flux_integration(self):
self.assertEqual(self.flux.get_status_of_job(process_id=job_id), 'running')
self.flux.delete_job(process_id=job_id)
self.assertEqual(self.flux.get_status_of_job(process_id=job_id), 'error')

def test_executor_integration(self):
with Executor(
cwd=self.test_dir,
queue_adapter=self.flux,
queue_adapter_kwargs={
"queue": "flux",
"job_name": "test",
"cores": 1,
}
) as exe:
fs = exe.submit(fn=funct_add, a=1, b=2)
self.assertFalse(fs.done())
self.assertEqual(fs.result(), 3)
self.assertTrue(fs.done())

0 comments on commit 6c32950

Please sign in to comment.