예제 #1
0
def null_arg():
    """ Null argument. """
    try:
        _ = participants_parser(None)
    except AssertionError:
        print('Exception catched. Great')
        return 1, 1
    else:
        print('Error: Exception not catched')
        return 0, 1
예제 #2
0
def illformated_file():
    """ Illformated file. """
    try:
        _ = participants_parser("illformated_test.csv")
    except ValueError:
        print('Exception catched. Great')
        return 1, 1
    else:
        print('Error: Exception not catched')
        return 0, 1
예제 #3
0
def no_file():
    """ No file on disk. """
    try:
        _ = participants_parser("something_that_does_not_exist")
    except IOError:
        print('Exception catched. Great')
        return 1, 1
    else:
        print('Error: Exception not catched')
        return 0, 1
예제 #4
0
def bad_type_arg():
    """ Argument is an int not a str. """
    try:
        _ = participants_parser(0)
    except TypeError:
        print('Exception catched. Great')
        return 1, 1
    else:
        print('Error: Exception not catched')
        return 0, 1
예제 #5
0
def good():
    """ Good test, should work. """
    try:
        participants = participants_parser("test.csv")
        couples = participants_shuffler(participants)
        for couple in couples:
            print(str(couple[0]), '->', str(couple[1]))
        print("File Parsed. Great.")
        return 1, 1
    except:
        return 0, 1
예제 #6
0
def good():
    """ Good test, should work. """
    try:
        participants = participants_parser("test.csv")
        for participant in participants:
            print(str(participant))
        print("File Parsed. Great.")
        return 1, 1
    except:
        print("Something happened.")
        return 0, 1
예제 #7
0
파일: main.py 프로젝트: hnrck/secret-santa
def main():
    """ Main function. """
    if len(argv) <= 1:
        raise AssertionError(
            'Error: A CSV file containing participants is needed.')

    if len(argv) > 2:
        raise AssertionError('Error: A single CSV file is needed.')

    csv_file = argv[1]
    if csv_file[-4:] != ".csv":
        raise AssertionError('Error: The argument might not be a csv file.')

    participants = participants_parser(csv_file)
    couples = participants_shuffler(participants)
    participants_mail(couples)