Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# This file is part of daf_butler. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (http://www.lsst.org). 

6# See the COPYRIGHT file at the top-level directory of this distribution 

7# for details of code ownership. 

8# 

9# This program is free software: you can redistribute it and/or modify 

10# it under the terms of the GNU General Public License as published by 

11# the Free Software Foundation, either version 3 of the License, or 

12# (at your option) any later version. 

13# 

14# This program is distributed in the hope that it will be useful, 

15# but WITHOUT ANY WARRANTY; without even the implied warranty of 

16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

17# GNU General Public License for more details. 

18# 

19# You should have received a copy of the GNU General Public License 

20# along with this program. If not, see <http://www.gnu.org/licenses/>. 

21 

22"""Unit tests for the daf_butler dataset-type CLI option. 

23""" 

24 

25import click 

26import click.testing 

27import unittest 

28 

29from lsst.daf.butler.cli.opt import dataset_type_option 

30 

31 

32@click.command() 

33@click.pass_context 

34@dataset_type_option(help="the dataset type") 

35def cli(ctx, dataset_type): 

36 click.echo(dataset_type, nl=False) 

37 

38 

39class Suite(unittest.TestCase): 

40 

41 def test_single(self): 

42 runner = click.testing.CliRunner() 

43 result = runner.invoke(cli, ["--dataset-type", "one"]) 

44 self.assertEqual(result.exit_code, 0) 

45 self.assertEqual(result.stdout, "['one']") 

46 

47 def test_multiple(self): 

48 runner = click.testing.CliRunner() 

49 result = runner.invoke(cli, ["--dataset-type", "one,two"]) 

50 self.assertEqual(result.exit_code, 0) 

51 self.assertEqual(result.stdout, "['one', 'two']") 

52 

53 def test_singlePair(self): 

54 runner = click.testing.CliRunner() 

55 result = runner.invoke(cli, ["--dataset-type", "one,two"]) 

56 self.assertEqual(result.exit_code, 0) 

57 self.assertEqual(result.stdout, "['one', 'two']") 

58 

59 def test_multiplePair(self): 

60 runner = click.testing.CliRunner() 

61 result = runner.invoke(cli, ["--dataset-type", "one,two", "-d", "three,four"]) 

62 self.assertEqual(result.exit_code, 0) 

63 self.assertEqual(result.stdout, "['one', 'two', 'three', 'four']") 

64 

65 

66if __name__ == "__main__": 66 ↛ 67line 66 didn't jump to line 67, because the condition on line 66 was never true

67 unittest.main()