Skip to content

Commit

Permalink
add test for dask utility
Browse files Browse the repository at this point in the history
  • Loading branch information
danangmassandy committed Oct 9, 2024
1 parent 7c9d02e commit 9c2658e
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions django_project/gap/tests/utils/test_dask.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# coding=utf-8
"""
Tomorrow Now GAP.
.. note:: Unit tests for Zarr Utilities.
"""

from django.test import TestCase

from gap.models import Preferences
from gap.utils.dask import execute_dask_compute


class MockDelayed(object):
"""Mock class for delayed object."""

def compute(self):
"""Mock compute method."""
pass


class TestDaskUtils(TestCase):
"""Unit test for dask utilities."""

def test_empty_num_of_threads(self):
"""Test num_of_threads is not set."""
preferences = Preferences.load()
preferences.dask_threads_num = -1
preferences.save()
execute_dask_compute(MockDelayed())

def test_use_num_of_threads(self):
"""Test num_of_threads is set to 1."""
preferences = Preferences.load()
preferences.dask_threads_num = 1
preferences.save()
execute_dask_compute(MockDelayed())

0 comments on commit 9c2658e

Please sign in to comment.