Ejemplo n.º 1
0
def test_file_output():
    file_output = get_file_output()

    if (len(file_output) >= 2) and (file_output[-2:] == ['PLEASEORDERAPIZZA','ITISEXPENSIVE']):
        passed()
    else:
        failed(message='Please reload the file and try again')
Ejemplo n.º 2
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    addition = placeholders[0]
    subtraction = placeholders[1]
    multiplication = placeholders[2]
    division = placeholders[3]
    answers = get_file_output()
    if answers == ['6 6 6 6.0']:
        passed()
    else:
        failed("Check your answers. At least one of them does not equal 6.")
    if '+' in addition:
        passed()
    else:
        failed("Did you use + in your addition?")
    if '-' in subtraction:
        passed()
    else:
        failed("Did you use - in your subtraction?")
    if '*' in multiplication:
        passed()
    else:
        failed("Did you use * in your multiplication?")
    if '/' in division:
        passed()
    else:
        failed("Did you use / in your division?")
Ejemplo n.º 3
0
def test_answer_placeholders():
    placeholders = get_file_output()
    placeholder = placeholders[-1]
    if placeholder == "Congrats, you win!":
        passed()
    else:
        failed("The program should end with us winning")
Ejemplo n.º 4
0
def test_output():
    answers = [
        "1, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "1, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "1, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "1, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "1, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "1, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "1, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "1, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "1, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "1, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "1, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "1, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "1, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "1, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "1, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "1, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "1, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "1, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "1, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "1, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "0, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)"
    ]

    output = get_file_output()

    if all(elem in output for elem in answers) and all(elem in answers
                                                       for elem in output):
        passed()
    else:
        failed("Try using an early trigger with the AfterWatermark trigger.")
Ejemplo n.º 5
0
def test_answer_placeholders():
    placeholders = get_file_output()
    placeholder = placeholders[0]
    if placeholder == "[1.0, 3.0, 5.0, 7.0, 9.0, 11.0, 13.0, 15.0, 17.0, 19.0, 21.0, 23.0, 25.0, 27.0, 29.0, 31.0]":  # TODO: your condition here
        passed()
    else:
        failed("Make sure your value are all floats. Do not change the odd_integers list")
Ejemplo n.º 6
0
def test_answer_placeholders():
    answers = get_file_output()
    answer = answers[0]
    if answer == "['google', 'facebook', 'youtube', 'amazon', 'twitter', 'ebay', 'reddit']":
        passed()
    else:
        failed("Did you remove the last entry (blank)?")
Ejemplo n.º 7
0
def test_answer_placeholders():
    answers = get_file_output()
    answer = answers[0]
    if answer == "['natasha', 'nautical', 'numbat', 'nitrogen', 'no']":
        passed()
    else:
        failed("You haven't removed all the non-n words")
Ejemplo n.º 8
0
def test_output():
    output = get_file_output()

    if len(output) == 1 and 'Hello Beam' in output:
        passed()
    else:
        failed('The input element should contain "Hello Beam"')
Ejemplo n.º 9
0
def test_outputs():

    outputs = get_file_output()
    if len(outputs) >= 3 and outputs[-3:] == ['IT IS STILL SNOWING', 'SHOULD WE GO SLEDDING', 'I CANNOT FIND MY BOOTS']:
        passed()
    else:
        failed(message='Please try again.')
Ejemplo n.º 10
0
def test_answer_placeholders():
    answers = get_file_output()
    answer = answers[0]
    if answer == "The most popular websites are google, facebook, youtube, amazon, twitter, ebay, reddit":
        passed()
    else:
        failed("The sentence isn't exactly as written.")
Ejemplo n.º 11
0
def test_output():
    output = get_file_output()
    index = output.index('''\"Süß\" ist ein Eis.''')
    if index > 0:
        if len(output) > index + 2:
            failed("Ausgabe in einer Zeile")
    passed()
Ejemplo n.º 12
0
def test_answer_placeholders():
    placeholders = get_file_output()
    placeholder = placeholders[0]
    if placeholder == "oh my goodness a secret message":
        passed()
    else:
        failed("You should only have the digits removed.")
Ejemplo n.º 13
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    addition = placeholders[0]
    subtraction = placeholders[1]
    multiplication = placeholders[2]
    division = placeholders[3]
    answers = get_file_output()
    if answers == ['10 10 10 10']:
        passed()
    else:
        failed("One of your answers isn't equal to 10!")
    if '+' in addition:
        passed()
    else:
        failed("Check your addition. Did you use + ?")
    if '-' in subtraction:
        passed()
    else:
        failed("Check your subtraction. Did you use - ? ")
    if '*' in multiplication:
        passed()
    else:
        failed("Check your multiplication. Did you use * ?")
    if '/' in division:
        passed()
    else:
        failed("Check your division. Did you use / ?")
Ejemplo n.º 14
0
def test_output():
    output = get_file_output()
    index = output.index('''\"Sweet\" is an ice-cream''')
    if index > 0:
        if len(output) > index + 2:
            failed("Print output in one line")
    passed()
Ejemplo n.º 15
0
def test_output():
    answers = [
        "1, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "2, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "3, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "4, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "5, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "6, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "7, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "8, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "9, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "10, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "11, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "12, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "13, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "14, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "15, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "16, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "17, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "18, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "19, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)",
        "20, window(start=2021-03-01T00:00:00Z, end=2021-03-02T00:00:00Z)"
    ]

    output = get_file_output()

    if all(elem in output for elem in answers) and all(elem in answers
                                                       for elem in output):
        passed()
    else:
        failed("Try using a count early trigger, with accumulating mode.")
Ejemplo n.º 16
0
def test_window2():
    window = get_answer_placeholders()[1]
    output = get_file_output()
    if len(output) > 1 and output[1] == "Das ist ein rotes Auto.":
        passed()
    else:
        failed("Setze die Farbe für das zweite Car-Objekt")
Ejemplo n.º 17
0
def test_window2():
    window = get_answer_placeholders()[1]
    output = get_file_output()
    if len(output) > 1 and output[1] == "This is a red car.":
        passed()
    else:
        failed("Change color using assignment to the car2.color")
Ejemplo n.º 18
0
def test_output():
    output = get_file_output()
    index = output.index('''\"Sweet\" is an ice-cream''')
    if index > 0:
        if len(output) > index + 2:
            failed("Print output in one line")
    passed()
Ejemplo n.º 19
0
def check_answers():
    answers = get_file_output()
    t_rex1 = answers[0]
    t_rex2 = answers[1]
    t_rex3 = answers[2]
    t_rex4 = answers[5]
    t_rex5 = answers[8]
    if t_rex1 == "In today's society, knowing a little about computers can go a long way!":
        passed()
    else:
        failed("First line is not correct")

    if t_rex2 == "They're not magic boxes. In fact, the more you learn about them the less magical they'll be!":
        passed()
    else:
        failed("Second line is not correct - did you just capitalize the first sentence?")

    if t_rex3 == "Soon you'll be staring at an obscure compiler error and no magic will be left in the world!":
        passed()
    else:
        failed("Third line is not correct")

    if t_rex4 == "I thought I'd actually start with logic gates, and build up to simple machine languages from that?":
        passed()
    else:
        failed("Sixth line is not correct - is I'd written correctly?")

    if t_rex5 == "NO, DON'T SAY THAT!":
        passed()
    else:
        failed("Last line not correct - is it all uppercase?")
Ejemplo n.º 20
0
def testout():
    out = get_file_output()
    if out[0] =="I had such a amazing day. It was awesome so good sigh. It could not have been better but actually though such a great amazing awesome good day. ":
        passed()
    elif out[0] == "I had such a amazing day. It was awesome so good sigh. It could not have been better but actually though such a great amazing awesome good day.":
        passed()
    else:
        failed()
Ejemplo n.º 21
0
def test_file_output():
    file_output = get_file_output()

    if (len(file_output) >= 2) and (file_output[-2:]
                                    == ['PLEASEORDERAPIZZA', 'ITISEXPENSIVE']):
        passed()
    else:
        failed(message='Please reload the file and try again')
Ejemplo n.º 22
0
def test_current_date():
    output = get_file_output()
    import datetime
    now = str(datetime.datetime.today())[:10]
    if output[0].startswith(now):
        passed()
    else:
        failed("Print the current date")
Ejemplo n.º 23
0
def test_current_date():
    output = get_file_output()
    import datetime
    now = str(datetime.datetime.today())[:10]
    if output[0].startswith(now):
        passed()
    else:
        failed("Print the current date")
Ejemplo n.º 24
0
def test_output():
    output = get_file_output()

    answers = ['Apache', 'Beam', 'Unified', 'Batch', 'and', 'Streaming']

    if all(num in output for num in answers):
        passed()
    else:
        failed("Incorrect output. Break each sentence into words.")
Ejemplo n.º 25
0
def test_output():
    numbers = ['0', '2', '4', '6', '8']
    output = get_file_output()
    if len(output) > 4:
        output = output[4:]
    if any(number in output for number in numbers):
        failed("Print only odd the numbers")
    else:
        passed()
Ejemplo n.º 26
0
def test_output():
    output = get_file_output()

    answers = ['15']

    if all(num in output for num in answers):
        passed()
    else:
        failed("Incorrect output. Sum all the numbers.")
Ejemplo n.º 27
0
def test_window():
    window = get_answer_placeholders()[0]
    output = get_file_output()
    if "datetime" not in window:
        failed("Benutze das datetime-Modul")
    elif len(output) > 0 and "<" not in output[0]:
        passed()
    else:
        failed("Gib das aktuelle Datum aus")
Ejemplo n.º 28
0
def test_output():
    output = get_file_output()

    answers = ['Hello', 'Beam', 'It', 'is', 'awesome']

    if all(num in output for num in answers):
        passed()
    else:
        failed("Incorrect output. Break each sentence into words.")
Ejemplo n.º 29
0
def test_window():
    window = get_answer_placeholders()[0]
    output = get_file_output()
    if "datetime" not in window:
        failed("Use datetime module")
    elif len(output) > 0 and "<" not in output[0]:
        passed()
    else:
        failed("Print the current date")
Ejemplo n.º 30
0
def test_output():
    output = get_file_output()

    answers = ['2', '4', '6', '8', '10']

    if all(num in output for num in answers):
        passed()
    else:
        failed("Incorrect output. Filter out the odd numbers.")
Ejemplo n.º 31
0
def test_window():
    window = get_answer_placeholders()[0]
    output = get_file_output()
    if "datetime" not in window:
        failed("Use datetime module")
    elif len(output) > 0 and "<" not in output[0]:
        passed()
    else:
        failed("Print the current date")
Ejemplo n.º 32
0
def test_output():
    output = get_file_output()

    answers = ['50', '100', '150', '200', '250']

    if all(num in output for num in answers):
        passed()
    else:
        failed("Incorrect output. Multiply each element by 5.")
Ejemplo n.º 33
0
def test_output():
    output = get_file_output()

    answers = ['1', '3', '5', '7', '9']

    if all(num in output for num in answers):
        passed()
    else:
        failed("Incorrect output. Filter out the even numbers.")
Ejemplo n.º 34
0
def test_output():
    output = get_file_output()

    answers = ['55']

    if all(num in output for num in answers):
        passed()
    else:
        failed("Incorrect output. Calculate the sum of all elements.")
Ejemplo n.º 35
0
def test_output():
    output = get_file_output()

    answers = ['10', '20', '30', '40', '50', '60', '70', '80', '90', '100']

    if all(num in output for num in answers):
        passed()
    else:
        failed("Incorrect output. Extract the numbers and multiply each by 10.")
Ejemplo n.º 36
0
def test_output():
    output = get_file_output()

    answers = ['ball', 'book', 'bow', 'apple', 'ant', 'arrow']

    if all(num in output for num in answers):
        passed()
    else:
        failed("Incorrect output. Flatten both PCollection into one.")
Ejemplo n.º 37
0
def test_output():
    output = get_file_output()

    answers = ['10']

    if all(num in output for num in answers):
        passed()
    else:
        failed("Incorrect output. Use Count.")
Ejemplo n.º 38
0
def test_file_output():
    file_output = get_file_output()
    if len(file_output) < 3:
        failed(message="Please reload the task and try again")
        return

    if file_output[-3:] == ['HELLO WORLD', 'HE PURCHASED THREE ITEMS BREAD EGGS AND MILK', 'DOES HE HAVE THE TICKETS']:
        passed()
    else:
        failed(message="File output did not match the expected values. Please try again.")
Ejemplo n.º 39
0
def test_outputs():

    outputs = get_file_output()
    if len(outputs) >= 3 and outputs[-3:] == [
            'IT IS STILL SNOWING', 'SHOULD WE GO SLEDDING',
            'I CANNOT FIND MY BOOTS'
    ]:
        passed()
    else:
        failed(message='Please try again.')
Ejemplo n.º 40
0
def test_output():
    output = get_file_output()

    answers = ['[10, 9]']

    if all(num in output for num in answers):
        passed()
    else:
        failed(
            "Incorrect output. Calculate a list of the largest two elements.")
Ejemplo n.º 41
0
def test_outputs():

    outputs = get_file_output()
    if len(outputs) < 3:
        failed(message='Please reset the file and try again')

    if outputs[-3:] == ['R LIWVIVW VRTSG KRAAZH', 'DV ZIV VCKVXGRMT TFVHGH', 'GSVB OLEV KRAAZ']:
        passed()
    else:
        failed(message='Please try again.')
Ejemplo n.º 42
0
Archivo: tests.py Proyecto: nielm/beam
def test_output():
    output = get_file_output()

    # Remove warning line about docker and Python versions
    output = [x for x in output if not x.startswith("WARNING")]

    if len(output) == 1 and 'Hello Beam' in output:
        passed()
    else:
        failed('The input element should contain "Hello Beam"')
Ejemplo n.º 43
0
def test_outputs():

    outputs = get_file_output()
    if len(outputs) < 3:
        failed(message='Please reset the file and try again')

    if outputs[-3:] == ['J PSEFSFE FJHIU QJAABT', 'YG CTG GZRGEVKPI IWGUVU', 'SGDX KNUD OHYYZ']:
        passed()
    else:
        failed(message='Please try again.')
Ejemplo n.º 44
0
def test_output():
    x = get_file_output()

    output = x.split('\n')
    if len(output) != 2:
        failed("There needs to be 2 print statments")
    else:
        if output[1] != "Erik is the best":
            failed("You have to print Erik is the best, cause he is")
        else:
            passed("Erik is indeed the best")
Ejemplo n.º 45
0
def test_file_output():
    file_output = get_file_output()
    final_outputs = file_output[-2:]

    # check the two cases, where key=1, key=3, respectively
    decrypted_message_case_one = ''.join([word[1] for word in final_outputs[0].split(' ')])
    decrypted_message_case_two = ''.join([word[3] for word in final_outputs[1].split(' ')])
    if decrypted_message_case_one == DECRYPTED_MESSAGE and decrypted_message_case_two == DECRYPTED_MESSAGE:
        passed()
    else:
        failed(message='Please try again.')
Ejemplo n.º 46
0
def test_output():
    output = get_file_output()
    if "Finished" not in output:
        failed()
    border = output.index("Finished")
    user_squares = output[border + 1:]
    correct_answer = list(map(str, [x * x for x in range(1, 10)]))
    if correct_answer == user_squares:
        passed()
    else:
        failed("Sorry, this answer is wrong")
Ejemplo n.º 47
0
def test_output():
    output = get_file_output()

    answers = ['apple:2', 'banana:4', 'grape:1', 'orange:2', 'papaya:1']

    if all(wordCount in output for wordCount in answers):
        passed()
    else:
        failed(
            'Incorrect output. Count number of each word in "word:count" format.'
        )
Ejemplo n.º 48
0
def test_output():
    output = get_file_output()

    answers = ["('a', ['apple', 'ant'])",
               "('b', ['ball', 'bear'])",
               "('c', ['car', 'cheetah'])"]

    if all(num in output for num in answers):
        passed()
    else:
        failed("Incorrect output. Use GroupByKey.")
Ejemplo n.º 49
0
def test_window2():
    default_error = "Use 'readline' method"
    window = get_answer_placeholders()[1]
    output = list(filter(lambda x: x != "", get_file_output()))
    if len(output) == 2 and output[1] == "My first line":
        passed()
        return
    if "print" not in window:
        failed("Don't forget to print the line")
        return
    failed(default_error)
Ejemplo n.º 50
0
def test_output():
    correct = "Countdown,5,4,3,2,1,blast off".split(",")
    actual = get_file_output()
    if len(actual) != len(correct):
        failed("Output should be " + str(len(correct)) + " lines, not " +
               str(len(actual)))
        return
    for i in range(len(correct)):
        if correct[i] != actual[i]:
            failed("Output line " + str(i + 1) + " should be " + correct[i])
    passed()
Ejemplo n.º 51
0
def test_answer_placeholders():
    answers = get_file_output()
    mississippi = answers[0]
    flies = answers[1]
    if mississippi == "There are 4 i's in mississippi":
        passed()
    else:
        failed("Something is wrong with the mississippi count")
    if flies == "There are 2 flies in that sentence":
        passed()
    else:
        failed("Something is wrong with the number of flies")
Ejemplo n.º 52
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    favnum = placeholders[0]
    answers = get_file_output()
    if answers[1] != 'My favourite number is 5':
        passed()
    else:
        failed("Are you sure you changed the value of the variable?")
    if favnum == 'fav_number':
        passed()
    else:
        failed("Did you put the variable, fav_number, in the placeholder?")
Ejemplo n.º 53
0
def test_answer_placeholders():
    answers = get_file_output()
    hey_jude = answers[0]
    batman = answers[1]
    if hey_jude == "na na na na na na na na na na na hey jude":
        passed()
    else:
        failed("Something's wrong with hey jude")
    if batman == "na na na na na na na na na na na na na na na na batman":
        passed()
    else:
        failed("Something's wrong with batman")
Ejemplo n.º 54
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    swapcase = placeholders[0]
    replace = placeholders[1]
    answers = get_file_output()
    if answers[0] == 'wE WaNt to SWaP THE CAsE Of EACh LettEr':
        passed()
    else:
        failed("Check your use of swapcase().")
    if answers[1] == 'Mr. McBride is the Head of School at Stratford Hall.':
        passed()
    else:
        failed("Mr. McBride is the new head of school. Does that help?")
Ejemplo n.º 55
0
def test_window1():
    windows = get_answer_placeholders()

    if windows[1].isdigit():
        passed()
        return
    else:
        output = get_file_output()
        if len(output) > 1:
            import re

            p = re.compile("I'm (\d*) years old")
            if p.match(output[1]) is not None:
                passed()
                return
    failed("Print digit")
Ejemplo n.º 56
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    exponent1 = placeholders[0]
    exponent2 = placeholders[1]
    answers = get_file_output()
    if answers == ['16 16']:
        passed()
    else:
        failed("Check your answers. At least one of them does not equal 16.")
    if '**' in exponent1:
        passed()
    else:
        failed("Did you use ** in exponent1?")
    if '**' in exponent2:
        passed()
    else:
        failed("Did you use ** in exponent2?")
Ejemplo n.º 57
0
def test_answer_placeholders():
    placeholders = get_answer_placeholders()
    exponentiation = placeholders[0]
    modulo = placeholders[1]
    answers = get_file_output()
    if answers == ['8 8']:
        passed()
    else:
        failed("One of your answers isn't equal to 8!")
    if '**' in exponentiation:
        passed()
    else:
        failed("Check exponentiation. Did you use ** ?")
    if '%' in modulo:
        passed()
    else:
        failed("Check modulo. Did you use % ? ")