Skip to content

Commit

Permalink
Add test for the get_dataset_attributes helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjaysrikakulam committed Jan 25, 2024
1 parent a8221ea commit 933a912
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
20 changes: 20 additions & 0 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""Unit tests module for the helper functions"""
import unittest
from tpv.commands.test import mock_galaxy
from tpv.core.helpers import get_dataset_attributes


class TestHelpers(unittest.TestCase):
"""Tests for helper functions"""
def test_get_dataset_attributes(self):
"""Test that the function returns a dictionary with the correct attributes"""
job = mock_galaxy.Job()
job.add_input_dataset(
mock_galaxy.DatasetAssociation(
"test",
mock_galaxy.Dataset("test.txt", file_size=7*1024**3, object_store_id="files1")
)
)
dataset_attributes = get_dataset_attributes(job.input_datasets)
expected_result = {0: {'object_store_id': 'files1', 'size': 7*1024**3}}
self.assertEqual(dataset_attributes, expected_result)
3 changes: 2 additions & 1 deletion tpv/commands/test/mock_galaxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ def __init__(self, name, dataset):
class Dataset:
counter = 0

def __init__(self, file_name, file_size):
def __init__(self, file_name, file_size, object_store_id=None):
self.id = self.counter
self.counter += 1
self.file_name = file_name
self.file_size = file_size
self.object_store_id = object_store_id

def get_size(self, calculate_size=False):
return self.file_size
Expand Down

0 comments on commit 933a912

Please sign in to comment.