#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Pablo Munoz (c) 2019
#
# Utility for creating new unit tests
#
import os
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-t', '--test', nargs='*', help='test name', type=str, required=True)
args = parser.parse_args()
test_name = ' '.join([x[:1].upper() + x[1:].lower() for x in args.test])
filename = 'test_' + test_name.replace(' ', '_') + '.py'

if os.path.isfile(filename):
    raise RuntimeError('Test exists already.')

test_src = open(filename, 'w')
with open('.template.py', 'r') as template:
    for line in template:
        if line == '# Unit tests for {0}\n':
            line = line.format(test_name)
        if line[:9] == "TEST_NAME":
            line = line.format(test_name)
        test_src.write(line)

