Skip to content

Commit

Permalink
Add new unit tests for show_dataset_types=True
Browse files Browse the repository at this point in the history
  • Loading branch information
leeskelvin committed Feb 18, 2025
1 parent f794ede commit f4a3baf
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions tests/test_cliCmdQueryCollections.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,34 @@ def test_all(self):
exclude_dataset_types=("*_config", "*_log", "*_metadata", "packages"),
),
)

def test_show_dataset_types(self):
"""Test the --show-dataset-types option."""
self.run_test(
["query-collections", "here", "--chains", "TABLE", "--show-dataset-types"],
self.makeExpected(
repo="here",
show_dataset_types=True,
exclude_dataset_types=("*_config", "*_log", "*_metadata", "packages"),
),
)

def test_exclude_dataset_types(self):
"""Test the --exclude-dataset-types option."""
self.run_test(
[
"query-collections",
"here",
"--chains",
"TABLE",
"--show-dataset-types",
"--exclude-dataset-types",
"flat",
],
self.makeExpected(
repo="here",
show_dataset_types=True,
exclude_dataset_types=("flat",),
),
)

Expand Down Expand Up @@ -230,6 +258,39 @@ def testChained(self):
)
self.assertAstropyTablesEqual(table, expected)

# Test table with show_dataset_types == True
table = queryCollections(
"here",
glob=(),
collection_type=CollectionType.all(),
chains="TREE",
show_dataset_types=True,
)
expected = Table(
array(
(
("calibration1", "CALIBRATION", ""),
("chain1", "CHAINED", ""),
(" tag1", "TAGGED", ""),
(" run1", "RUN", ""),
(" chain2", "CHAINED", ""),
(" calibration1", "CALIBRATION", ""),
(" run1", "RUN", ""),
("chain2", "CHAINED", ""),
(" calibration1", "CALIBRATION", ""),
(" run1", "RUN", ""),
("imported_g", "RUN", "bias"),
("", "", "flat"),
("imported_r", "RUN", "bias"),
("", "", "flat"),
("run1", "RUN", ""),
("tag1", "TAGGED", ""),
)
),
names=("Name", "Type", "Dataset Types"),
)
self.assertAstropyTablesEqual(table, expected)

result = self.runner.invoke(cli, ["query-collections", "here", "--chains", "TABLE"])
self.assertEqual(result.exit_code, 0, clickResultMsg(result))
expected = Table(
Expand Down

0 comments on commit f4a3baf

Please sign in to comment.