Exemplo n.º 1
0
 def test_valid_format(self, controler, controler_with_logging, tmpdir, mocker):
     """Make sure that a valid format returns the apropiate writer class."""
     path = os.path.join(tmpdir.mkdir('report').strpath, 'report.csv')
     hamsterlib.reports.TSVWriter = mocker.MagicMock(return_value=hamsterlib.reports.TSVWriter(
         path))
     hamster_cli._export(controler, 'csv', None, None)
     assert hamsterlib.reports.TSVWriter.called
Exemplo n.º 2
0
 def test_with_end(self, controler, controler_with_logging, tmpdir, mocker):
     """Make sure that passing a end date is passed to the fact gathering method."""
     controler.facts.get_all = mocker.MagicMock()
     path = os.path.join(tmpdir.mkdir('report').strpath, 'report.csv')
     hamsterlib.reports.TSVWriter = mocker.MagicMock(
         return_value=hamsterlib.reports.TSVWriter(path))
     end = fauxfactory.gen_datetime()
     hamster_cli._export(controler, 'csv', None, end)
     args, kwargs = controler.facts.get_all.call_args
     assert kwargs['end'] == end
Exemplo n.º 3
0
 def test_with_end(self, controler, controler_with_logging, tmpdir, mocker):
     """Make sure that passing a end date is passed to the fact gathering method."""
     controler.facts.get_all = mocker.MagicMock()
     path = os.path.join(tmpdir.mkdir('report').strpath, 'report.csv')
     hamsterlib.reports.TSVWriter = mocker.MagicMock(return_value=hamsterlib.reports.TSVWriter(
         path))
     end = fauxfactory.gen_datetime()
     hamster_cli._export(controler, 'csv', None, end)
     args, kwargs = controler.facts.get_all.call_args
     assert kwargs['end'] == end
Exemplo n.º 4
0
 def test_invalid_format(self, controler_with_logging, format, mocker):
     """Make sure that passing an invalid format exits prematurely."""
     controler = controler_with_logging
     hamster_cli.sys.exit = mocker.MagicMock()
     hamster_cli._export(controler, format, None, None)
     assert hamster_cli.sys.exit.called
Exemplo n.º 5
0
 def test_xml(self, controler, controler_with_logging, mocker):
     """Make sure that passing 'xml' as format parameter returns the apropiate writer class."""
     hamsterlib.reports.XMLWriter = mocker.MagicMock()
     hamster_cli._export(controler, 'xml', None, None)
     assert hamsterlib.reports.XMLWriter.called
Exemplo n.º 6
0
 def test_ical(self, controler, controler_with_logging, mocker):
     """Make sure that a valid format returns the apropiate writer class."""
     hamsterlib.reports.ICALWriter = mocker.MagicMock()
     hamster_cli._export(controler, 'ical', None, None)
     assert hamsterlib.reports.ICALWriter.called
Exemplo n.º 7
0
 def test_invalid_format(self, controler_with_logging, format, mocker):
     """Make sure that passing an invalid format exits prematurely."""
     controler = controler_with_logging
     with pytest.raises(ClickException):
         hamster_cli._export(controler, format, None, None)
Exemplo n.º 8
0
 def test_xml(self, controler, controler_with_logging, mocker):
     """Make sure that passing 'xml' as format parameter returns the apropiate writer class."""
     hamsterlib.reports.XMLWriter = mocker.MagicMock()
     hamster_cli._export(controler, 'xml', None, None)
     assert hamsterlib.reports.XMLWriter.called
Exemplo n.º 9
0
 def test_ical(self, controler, controler_with_logging, mocker):
     """Make sure that a valid format returns the apropiate writer class."""
     hamsterlib.reports.ICALWriter = mocker.MagicMock()
     hamster_cli._export(controler, 'ical', None, None)
     assert hamsterlib.reports.ICALWriter.called
Exemplo n.º 10
0
 def test_invalid_format(self, controler_with_logging, format, mocker):
     """Make sure that passing an invalid format exits prematurely."""
     controler = controler_with_logging
     with pytest.raises(ClickException):
         hamster_cli._export(controler, format, None, None)