Skip to content

Commit

Permalink
Add test for the make-discrete-skymap subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonKrughoff committed Sep 25, 2020
1 parent 88c9aa9 commit d305eda
Showing 1 changed file with 85 additions and 0 deletions.
85 changes: 85 additions & 0 deletions tests/test_cliCmdMakeDiscreteSkymap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# This file is part of pipe_tasks.
#
# Developed for the LSST Data Management System.
# This product includes software developed by the LSST Project
# (http://www.lsst.org).
# See the COPYRIGHT file at the top-level directory of this distribution
# for details of code ownership.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""Unit tests for daf_butler CLI make-discrete-skymap command.
"""

import unittest

from lsst.daf.butler.tests import CliCmdTestBase
from lsst.pipe.tasks.cli.cmd import make_discrete_skymap


class DefineMakeDiscreteSkymap(CliCmdTestBase, unittest.TestCase):

@staticmethod
def defaultExpected():
return dict(config_file=None,
collections=())

@staticmethod
def command():
return make_discrete_skymap

def test_repoBasic(self):
"""Test the most basic required arguments."""
self.run_test(["make-discrete-skymap",
"--collections", "foo/bar,baz",
"--instrument", "a.b.c", "here"],
self.makeExpected(repo="here",
collections=("foo/bar", "baz"),
out_collection="skymaps",
skymap_id="discrete",
instrument="a.b.c"))

def test_all(self):
"""Test all the arguments."""
self.run_test(["make-discrete-skymap",
"--instrument", "a.b.c",
"--collections", "foo/bar,baz",
"--config-file", "/path/to/config",
"--collections", "boz",
"--out-collection", "biz",
"--skymap-id", "wiz",
"here"],
self.makeExpected(repo="here",
instrument="a.b.c",
config_file="/path/to/config",
out_collection="biz",
skymap_id="wiz",
# The list of collections must be in
# exactly the same order as it is
# passed in the list of arguments to
# run_test.
collections=("foo/bar", "baz", "boz")))

def test_missing(self):
"""test a missing argument"""
self.run_missing(["make-discrete-skymap", "--collections", "foo/bar,baz", "--instrument", "a.b.c"],
'Missing argument "REPO"')
self.run_missing(["make-discrete-skymap", "--collections", "foo/bar,baz", "here"],
'Missing option "-i" / "--instrument"')
self.run_missing(["make-discrete-skymap", "--instrument", "a.b.c", "here"],
'Error: Missing option "--collections".')


if __name__ == "__main__":
unittest.main()

0 comments on commit d305eda

Please sign in to comment.