'''
15-110 Homework 2
Name:
Andrew ID:
'''

import math
import tkinter

################################################################################

'''
#1 - drawIllusion(canvas)
Parameters: Tkinter canvas
Returns: None
'''

def drawIllusion(canvas):
    return


'''
#2 - factorial(x)
Parameters: int
Returns: int
'''

def factorial(x):
    return


'''
#3 - printTriangle(n)
Parameters: int
Returns: None
'''

def printTriangle(n):
    return


'''
#4 - printPrimeFactors(x)
Parameters: int
Returns: None
'''

def printPrimeFactors(x):
    return


'''
#5 - repeatingPattern(canvas, rows, cols, size, showGrid)
Parameters: Tkinter canvas, int, int, int, bool
Returns: None
'''

def repeatingPattern(canvas, rows, cols, size, showGrid):
    return


'''
#6 - getSecretMessage(s, key)
Parameters: str, str
Returns: str
'''

def getSecretMessage(s, key):
    return


################################################################################
''' Test Functions '''

def runDrawIllusion():
    print("Testing drawIllusion()... check the screen!")
    root = tkinter.Tk()
    canvas = tkinter.Canvas(root, width=400, height=400)
    canvas.configure(bd=0, highlightthickness=0)
    canvas.pack()
    drawIllusion(canvas)
    root.mainloop()
    print("... drawIllusion() closed successfully.")

def testFactorial():
    print("Testing factorial()...", end="")
    assert(factorial(1) == 1)
    assert(factorial(2) == 2)
    assert(factorial(3) == 6)
    assert(factorial(4) == 24)
    assert(factorial(5) == 120)
    assert(factorial(6) == 720)
    assert(factorial(10) == 3628800)
    assert(factorial(0) == 1)
    print("... done!")

def testPrintTriangle():
    print("Testing printTriangle()...")
    printTriangle(1)
    print("---")
    printTriangle(3)
    print("---")
    printTriangle(5)
    print("---")
    printTriangle(7)
    print("---")
    printTriangle(9)
    print("... check your output to see if it looks correct!")

def testPrintPrimeFactors():
    print("Testing printPrimeFactors()...")
    printPrimeFactors(70) # 2, 5, 7
    print("---")
    printPrimeFactors(12) # 2 ** 2, 3
    print("---")
    printPrimeFactors(16) # 2 ** 4
    print("---")
    printPrimeFactors(600) # 2 ** 3, 3, 5 ** 2
    print("---")
    printPrimeFactors(36) # 2 ** 2, 3 ** 2
    print("---")
    printPrimeFactors(3289) # 11, 13, 23
    print("---")
    printPrimeFactors(17) # 17
    print("---")
    printPrimeFactors(2) # 2
    print("... check your output to see if it looks correct!")

def runRepeatingPattern():
    print("Testing repeatingPattern()... check the screen!")
    root = tkinter.Tk()
    canvas = tkinter.Canvas(root, width=400, height=400)
    canvas.configure(bd=0, highlightthickness=0)
    canvas.pack()
    repeatingPattern(canvas, 4, 4, 100, True)
    root.mainloop()

    root = tkinter.Tk()
    canvas = tkinter.Canvas(root, width=400, height=400)
    canvas.configure(bd=0, highlightthickness=0)
    canvas.pack()
    repeatingPattern(canvas, 4, 4, 100, False)
    root.mainloop()

    # Single cell
    root = tkinter.Tk()
    canvas = tkinter.Canvas(root, width=250, height=250)
    canvas.configure(bd=0, highlightthickness=0)
    canvas.pack()
    repeatingPattern(canvas, 1, 1, 250, True)
    root.mainloop()

    # Lots of cells
    root = tkinter.Tk()
    canvas = tkinter.Canvas(root, width=500, height=500)
    canvas.configure(bd=0, highlightthickness=0)
    canvas.pack()
    repeatingPattern(canvas, 10, 10, 50, False)
    root.mainloop()
    print("... repeatingPattern() closed successfully.")

def testGetSecretMessage():
    print("Testing getSecretMessage()...", end="")
    assert(getSecretMessage("orupqcrzypqomqmhcyqpwhhqutqtxtqeyeqrpa", "q") == "computer")
    assert(getSecretMessage("cowkscaoktbphakebakltvklmtkau", "k") == "stella")
    assert(getSecretMessage("xwuexoerxwdf", "x") == "wow")
    assert(getSecretMessage("faqfxwuexoerxw", "x") == "wow")
    assert(getSecretMessage("faqfxwuexoxwdf", "x") == "wow")
    assert(getSecretMessage("xwxoxw", "x") == "wow")
    assert(getSecretMessage("", "a") == "")
    print("... done!")

def testAll():
    runDrawIllusion()
    testFactorial()
    testPrintTriangle()
    testPrintPrimeFactors()
    runRepeatingPattern()
    testGetSecretMessage()

testAll()