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

import math
import tkinter

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

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

def drawIllusion(canvas):
    return


'''
#2 - partialProduct(x)
Parameters: int, int
Returns: int
'''

def partialProduct(n, x):
    return


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

def printSigns(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 testPartialProduct():
    print("Testing partialProduct()...", end="")
    assert(partialProduct(1, 1) == 1)
    assert(partialProduct(1, 2) == 2)
    assert(partialProduct(1, 3) == 6)
    assert(partialProduct(3, 4) == 12)
    assert(partialProduct(3, 5) == 60)
    assert(partialProduct(2, 6) == 720)
    assert(partialProduct(7, 10) == 5040)
    assert(partialProduct(4, 10) == 604800)
    assert(partialProduct(10, 10) == 10)
    assert(partialProduct(0, 0) == 0)
    print("... done!")

def testPrintSigns():
    print("Testing printSigns()...")
    print("Triangle of size 1")
    printSigns(1)
    print("---")
    print("Triangle of size 3")
    printSigns(3)
    print("---")
    print("Triangle of size 5")
    printSigns(5)
    print("---")
    print("Triangle of size 7")
    printSigns(7)
    print("---")
    print("Triangle of size 9")
    printSigns(9)
    print("---")
    print("... check your output to see if it looks correct!")

def testPrintPrimeFactors():
    print("Testing printPrimeFactors()...")
    print("Factors of the number 70:")
    printPrimeFactors(70) # 2, 5, 7
    print("---")
    print("Factors of the number 12:")
    printPrimeFactors(12) # 2 ** 2, 3
    print("---")
    print("Factors of the number 16:")
    printPrimeFactors(16) # 2 ** 4
    print("---")
    print("Factors of the number 600:")
    printPrimeFactors(600) # 2 ** 3, 3, 5 ** 2
    print("---")
    print("Factors of the number 36:")
    printPrimeFactors(36) # 2 ** 2, 3 ** 2
    print("---")
    print("Factors of the number 3289:")
    printPrimeFactors(3289) # 11, 13, 23
    print("---")
    print("Factors of the number 17:")
    printPrimeFactors(17) # 17
    print("---")
    print("Factors of the number 2:")
    printPrimeFactors(2) # 2
    print("---")
    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()
    testPartialProduct()
    testPrintSigns()
    testPrintPrimeFactors()
    runRepeatingPattern()
    testGetSecretMessage()

testAll()