Пример #1
0
    def test_today(self):
        test_args = []
        args = parser.parse_args(test_args)
        self.assertFalse(args.today)

        test_args = ['--today']
        args = parser.parse_args(test_args)
        self.assertTrue(args.today)
Пример #2
0
    def test_last_hour(self):
        test_args = []
        args = parser.parse_args(test_args)
        self.assertFalse(args.last_hour)

        test_args = ['--last-hour']
        args = parser.parse_args(test_args)
        self.assertTrue(args.last_hour)
Пример #3
0
    def test_mtd(self):
        test_args = []
        args = parser.parse_args(test_args)
        self.assertFalse(args.mtd)

        test_args = ['--mtd']
        args = parser.parse_args(test_args)
        self.assertTrue(args.mtd)
Пример #4
0
    def test_log_level(self):
        test_args = []
        args = parser.parse_args(test_args)
        self.assertEquals('info', args.log_level)

        test_args = ['--log-level', 'debug']
        args = parser.parse_args(test_args)
        self.assertEquals('debug', args.log_level)
Пример #5
0
    def test_output_directory(self):
        test_args = []
        args = parser.parse_args(test_args)
        self.assertEquals('/etc/usage/reports', args.output_directory)

        test_args = ['--output-directory', '/somedir']
        args = parser.parse_args(test_args)
        self.assertEquals('/somedir', args.output_directory)
Пример #6
0
    def test_mtd(self):
        test_args = []
        args = parser.parse_args(test_args)
        self.assertFalse(args.mtd)

        test_args = ['--mtd']
        args = parser.parse_args(test_args)
        self.assertTrue(args.mtd)
Пример #7
0
    def test_today(self):
        test_args = []
        args = parser.parse_args(test_args)
        self.assertFalse(args.today)

        test_args = ['--today']
        args = parser.parse_args(test_args)
        self.assertTrue(args.today)
Пример #8
0
    def test_show_tags(self):
        test_args = []
        args = parser.parse_args(test_args)
        self.assertFalse(args.show_tags)

        test_args = ['--show-tags']
        args = parser.parse_args(test_args)
        self.assertTrue(args.show_tags)
Пример #9
0
    def test_max_samples(self):
        test_args = []
        args = parser.parse_args(test_args)
        self.assertEquals(15000, args.max_samples)

        test_args = ['--max-samples', '1']
        args = parser.parse_args(test_args)
        self.assertEquals(1, args.max_samples)
Пример #10
0
    def test_log_level(self):
        test_args = []
        args = parser.parse_args(test_args)
        self.assertEquals('info', args.log_level)

        test_args = ['--log-level', 'debug']
        args = parser.parse_args(test_args)
        self.assertEquals('debug', args.log_level)
Пример #11
0
    def test_use_stdout(self):
        test_args = []
        args = parser.parse_args(test_args)
        self.assertFalse(args.use_stdout)

        test_args = ['--use-stdout']
        args = parser.parse_args(test_args)
        self.assertTrue(args.use_stdout)
Пример #12
0
    def test_output_directory(self):
        test_args = []
        args = parser.parse_args(test_args)
        self.assertEquals('/etc/usage/reports', args.output_directory)

        test_args = ['--output-directory', '/somedir']
        args = parser.parse_args(test_args)
        self.assertEquals('/somedir', args.output_directory)
Пример #13
0
    def test_definition_filename(self):
        test_args = []
        args = parser.parse_args(test_args)
        self.assertEquals('/etc/usage/report.yaml', args.definition_filename)

        test_args = ['--definition-filename', 'afile']
        args = parser.parse_args(test_args)
        self.assertEquals('afile', args.definition_filename)
Пример #14
0
    def test_config_file(self):
        test_args = []
        args = parser.parse_args(test_args)
        self.assertEquals('/etc/usage/usage.yaml', args.config_file)

        test_args = ['--config-file', 'somefile']
        args = parser.parse_args(test_args)
        self.assertEquals('somefile', args.config_file)
Пример #15
0
    def test_last_hour(self):
        test_args = []
        args = parser.parse_args(test_args)
        self.assertFalse(args.last_hour)

        test_args = ['--last-hour']
        args = parser.parse_args(test_args)
        self.assertTrue(args.last_hour)
Пример #16
0
    def test_use_stdout(self):
        test_args = []
        args = parser.parse_args(test_args)
        self.assertFalse(args.use_stdout)

        test_args = ['--use-stdout']
        args = parser.parse_args(test_args)
        self.assertTrue(args.use_stdout)
Пример #17
0
    def test_show_tags(self):
        test_args = []
        args = parser.parse_args(test_args)
        self.assertFalse(args.show_tags)

        test_args = ['--show-tags']
        args = parser.parse_args(test_args)
        self.assertTrue(args.show_tags)
Пример #18
0
    def test_config_file(self):
        test_args = []
        args = parser.parse_args(test_args)
        self.assertEquals('/etc/usage/usage.yaml', args.config_file)

        test_args = ['--config-file', 'somefile']
        args = parser.parse_args(test_args)
        self.assertEquals('somefile', args.config_file)
Пример #19
0
    def test_max_samples(self):
        test_args = []
        args = parser.parse_args(test_args)
        self.assertEquals(15000, args.max_samples)

        test_args = ['--max-samples', '1']
        args = parser.parse_args(test_args)
        self.assertEquals(1, args.max_samples)
Пример #20
0
    def test_definition_filename(self):
        test_args = []
        args = parser.parse_args(test_args)
        self.assertEquals('/etc/usage/report.yaml', args.definition_filename)

        test_args = ['--definition-filename', 'afile']
        args = parser.parse_args(test_args)
        self.assertEquals('afile', args.definition_filename)
Пример #21
0
    def test_stop(self):
        test_args = []
        args = parser.parse_args(test_args)
        self.assertFalse(args.stop)

        # This causes the following to exit. not sure how to test.
        # test_args = ['--stop', 'notadatetime']
        # with self.assertRaises(ArgumentTypeError):
        #    args = parser.parse_args(test_args)

        test_args = ['--stop', '2016-06-01 00:00:00']
        args = parser.parse_args(test_args)
        self.assertTrue(isinstance(args.stop, datetime.datetime))
Пример #22
0
    def test_stop(self):
        test_args = []
        args = parser.parse_args(test_args)
        self.assertFalse(args.stop)

        # This causes the following to exit. not sure how to test.
        # test_args = ['--stop', 'notadatetime']
        # with self.assertRaises(ArgumentTypeError):
        #    args = parser.parse_args(test_args)

        test_args = ['--stop', '2016-06-01 00:00:00']
        args = parser.parse_args(test_args)
        self.assertTrue(isinstance(args.stop, datetime.datetime))