def test_GetOutputDir_TimestampIsNoneCustomPrefix_ReturnsNoTimestampCustomPrefix(
            self, mock_join):
        test_prefix = "CustomPrefix"

        scanner.get_output_dir(None, test_prefix)

        mock_join.assert_called_with(test_prefix, "NO_TIMESTAMP")
    def test_GetOutputDir_TimestampGivenDefaultPrefix_ReturnsTimestampedDirDefaultPrefix(
            self, mock_join):
        timestamp = datetime.datetime(2016, 1, 1, 12, 0, 0, 123456)

        scanner.get_output_dir(timestamp)

        expected_timestamp = "2016-01-01T12_00_00_123456"
        mock_join.assert_called_with("TestResults", expected_timestamp)
    def test_GetOutputDir_TimestampGivenCustomPrefix_ReturnsTimestampedDirCustomPrefix(
            self, mock_join):
        timestamp = datetime.datetime(2016, 1, 1, 12, 0, 0, 123456)
        test_prefix = "CustomPrefix"

        scanner.get_output_dir(timestamp, test_prefix)

        expected_timestamp = "2016-01-01T12_00_00_123456"
        mock_join.assert_called_with(test_prefix, expected_timestamp)
Beispiel #4
0
def execute(args=None):
    parser = get_parser()

    args, extra = parser.parse_known_args(args)

    # create output directory
    timestamp = datetime.now() if not args.no_timestamp else None
    if args.output_path:
        output_dir = get_output_dir(timestamp, os.path.abspath(args.output_path))
    else:
        output_dir = get_output_dir(timestamp)
    if os.path.exists(output_dir):
        shutil.rmtree(output_dir)
    os.makedirs(output_dir)

    # setup logging
    setup_logging(os.path.join(output_dir, "aztest.log"), lg.DEBUG)
    logger.info("AZ Test Scanner")

    # execute command
    return args.func(args, extra, output_dir)
    def test_GetOutputDir_TimestampIsNoneDefaultPrefix_ReturnsNoTimestampDefaultPrefix(
            self, mock_join):
        scanner.get_output_dir(None)

        mock_join.assert_called_with("TestResults", "NO_TIMESTAMP")