def test_main_fetch(fetch): """Test if Fetch part of main completes without error.""" argv = [ 'hourly', '--startyear', '2008', '--ensemble', 'false', '--variables', 'total_precipitation', '--statistics', 'true', '--split', 'true', '--endyear', '2008', '--ensemble', 'true' ] args = cli._parse_args(argv) assert cli._execute(args) # should give an AssertionError if endyear is before startyear argv = [ 'hourly', '--startyear', '2008', '--ensemble', 'false', '--variables', 'total_precipitation', '--statistics', 'true', '--split', 'true', '--endyear', '2007', '--ensemble', 'true' ] args = cli._parse_args(argv) with pytest.raises(AssertionError): assert cli._execute(args) # monthly call without endyear argv = [ 'monthly', '--startyear', '2008', '--ensemble', 'false', '--variables', 'total_precipitation', '--synoptic', 'true', '--split', 'true', '--ensemble', 'true' ] args = cli._parse_args(argv) cli._execute(args)
def test_main_info(info): """Test if Info part of main completes without error.""" info.return_value.infotype = 'list' argv = ['info', 'levels'] args = cli._parse_args(argv) cli._execute(args) info.return_value.infotype = 'total_precipitation' argv = ['info', 'total_precipitation'] args = cli._parse_args(argv) cli._execute(args)
def test_main_fetch(fetch): """Test if Fetch part of main completes without error.""" argv = ['hourly', '--startyear', '2008', '--variables', 'total_precipitation', '--statistics', '--endyear', '2008', '--ensemble'] args = cli._parse_args(argv) assert cli._execute(args) # should give an AssertionError if endyear is before startyear argv = ['hourly', '--startyear', '2008', '--variables', 'total_precipitation', '--statistics', '--endyear', '2007', '--ensemble'] args = cli._parse_args(argv) with pytest.raises(AssertionError): assert cli._execute(args) # should give an AssertionError if years are out of bounds argv = ['hourly', '--startyear', '1950', '--variables', 'total_precipitation', '--statistics', '--endyear', '2007', '--ensemble'] args = cli._parse_args(argv) with pytest.raises(AssertionError): assert cli._execute(args) # should give an AssertionError if years are out of bounds argv = ['hourly', '--startyear', '1950', '--variables', 'total_precipitation', '--statistics', '--endyear', '2007', '--ensemble', '--prelimbe'] args = cli._parse_args(argv) with pytest.raises(AssertionError): assert cli._execute(args) # monthly call without endyear argv = ['monthly', '--startyear', '2008', '--variables', 'total_precipitation', '--synoptic', '--ensemble'] args = cli._parse_args(argv) cli._execute(args) # no land available for back extension argv = ['monthly', '--startyear', '1980', '--endyear', '1980', '--variables', 'total_precipitation', '--synoptic', '--ensemble', '--land'] args = cli._parse_args(argv) with pytest.raises(AssertionError): cli._execute(args)