Esempio n. 1
0
def test_one():
    expected = """This is a short story of {noun}'s life.

He {verb} to ASAC {adverb} with his family's {noun}. but When he has a conflict with his family, he goes by {noun}.
too bad that he felt {adjective} last {noun} because he went daily by his {noun}.

on the occasion of this short story of {noun}'s life; he still like programming.
"""
    actual = read_template(open('assets/text.txt'))
    assert expected.strip() == actual
Esempio n. 2
0
def test_list():
    actual = find_words("\{(.*?)\}", read_template('assets/madlib.txt'))
    expected = [
        'Adjective', 'Adjective', 'A First Name', 'Past Tense Verb',
        'A First Name', 'Adjective', 'Adjective', 'Plural Noun',
        'Large Animal', 'Small Animal', "A Girl's Name", 'Adjective',
        'Plural Noun', 'Adjective', 'Plural Noun', 'Number 1-50',
        "First Name's", 'Number', 'Plural Noun', 'Number', 'Plural Noun'
    ]
    assert actual == expected
Esempio n. 3
0
def test_read_template():
    actual = read_template('test.txt')
    expect = "This is a {test}"
    assert actual == expect
Esempio n. 4
0
def test_read_template_returns_stripped_string():
    actual = read_template("assets/dark_and_stormy_night.txt")
    expected = "It was a {Adjective} and {Adjective} {Noun}."
    assert actual == expected
Esempio n. 5
0
def test_read_template():
    actual = read_template('./madlib_cli/assets/test_text_template.txt')
    expected = "I am a {adjective} {adjective} test text file!"
    assert actual == expected
Esempio n. 6
0
def test_parse():
	actual = parse(read_template(testName))
	expect = ['{test}']
	assert actual == expect
Esempio n. 7
0
import pytest
from madlib_cli.madlib import read_template, parse_template, merge_template

open_sample_text = open("assets/sample.txt").read()
path = "assets/sample.txt"
string = read_template("assets/sample.txt")


def test_read_template():
    actual = read_template("assets/sample.txt")
    expected = open_sample_text.strip()
    assert actual == expected


def test_parse_template():
    actual_string, actual_list = parse_template(string)
    expected_string = "Make Me A Video Game!\n\nI the {} and {} {} have {}{}'s {} sister and plan to\nsteal her {} {}!\n\nWhat are a {} and backpacking {} to do? Before you can help {}, you'll have to collect \nthe {} {} and {} {} that open up the {} worlds connected to A {} Lair. \nThere are {} {} and {} {} in the game, along with hundreds of other goodies for you to find."
    expected_list = [
        "Adjective",
        "Adjective",
        "A First Name",
        "Past Tense Verb",
        "A First Name",
        "Adjective",
        "Adjective",
        "Plural Noun",
        "Large Animal",
        "Small Animal",
        "A Girl's Name",
        "Adjective",
        "Plural Noun",
Esempio n. 8
0
def testRead():
    expected = open('assets/template.txt','r').read()
    received = read_template()
    assert expected == received
Esempio n. 9
0
def test_read_template():
    actual = read_template('assets/test.txt')
    expected = 'This is a test\nhello\nwelcome'
    assert actual == expected
Esempio n. 10
0
def text_file_not_found_exception():
    with pytest.raises(FileNotFoundError):
        file_path = "madlib_cli"
        read_template(file_path)
Esempio n. 11
0
def test_read_template():
    file_path = "madlib_cli"
    assert "I am the {noun}" in read_template(file_path)
Esempio n. 12
0
def test_read_template():
    actual = read_template(path)
    expected = open_file.strip()
    assert actual == expected
Esempio n. 13
0
from madlib_cli.madlib import read_template, parse

import re

open_file = open('assets/game.txt').read()

path = 'assets/game.txt'

string_template = read_template('assets/game.txt')


def test_read_template():
    actual = read_template(path)
    expected = open_file.strip()
    assert actual == expected


def test_parse():
    actual = parse(string_template)
    expected = '''
    Make Me A Video Game!

    I the {} and {} {} have {}{}'s {} sister and plan to steal her {} {}!

    What are a {} and backpacking {} to do? Before you can help {}, you'll have to collect the {} {} and {} {} that open up the {} worlds connected to A {} Lair. There are {} {} and {} {} in the game, along with hundreds of other goodies for you to find.
    '''
    assert actual == expected
Esempio n. 14
0
def test_read_func():
    expected = open('../assets/template.txt','r').read()
    received = read_template()
    assert expected == received
Esempio n. 15
0
def test_parse_template():
    actual = parse_template(read_template('test.txt'))
    expect = ['test']
    assert actual == expect
Esempio n. 16
0
def test_read_with_placeholders():
    actual = read_template("assets/test_with_placeholders.txt")
    expected = "Hello there, this is {Name}, I am {Age} years old."
    assert actual == expected
Esempio n. 17
0
def test_read_template_raises_exception_with_bad_path():
    with pytest.raises(FileNotFoundError) as err:
        path = "missing.txt"
        read_template(path)
    assert str(err.value) == "File not found"
Esempio n. 18
0
def test_read_template_returns_stripped_string():
  actual = read_template("assets/video_game.txt")
  expected = "I the {Adjective} and {Adjective} {A First Name}"
  assert actual == expected
Esempio n. 19
0
print("""

****************************************************

Welcome. We are going to play Madlibs! 
You will be prompted with a series of prompts. 
Provde appropriate responses to complete the Madlib

****************************************************

""")

user_responses = []


def get_responses():
    adj1 = input("Provide an Adjective ")
    user_responses.append(adj1)
    adj2 = input("Provide another Adjective ")
    user_responses.append(adj2)
    noun1 = input("Provide a Noun ")
    user_responses.append(noun1)


madlib = read_template("assets/dark_and_stormy_night.txt")
parsed_text, words = parse_template(madlib)
parts = get_responses()
print(user_responses)
print(merge(parsed_text, user_responses))
Esempio n. 20
0
def test_read_template():
    actual = read_template(
        "/home/hamza/Desktop/401/labs/lab3/madlib-cli/textFiles/test.txt")
    expected = "Hello Gys I'm {first name} {last name} => hamza rashed"
    assert actual == expected
Esempio n. 21
0
def test_read_template():
    actual = read_template("assets/sample.txt")
    expected = open_sample_text.strip()
    assert actual == expected
Esempio n. 22
0
def test_read_files():
    expected = open('madlib-cli/files/story.txt', 'r').read()
    received = read_template()
    assert expected == received
Esempio n. 23
0
def test_read_template():
	actual = read_template(testName)
	expect = 'this is a {test}'
	assert actual == expect
Esempio n. 24
0
def testRead():
    actual = read_template()
    expected = open('assets/sample_template.txt', 'r').read()
    assert expected == actual
Esempio n. 25
0
def test_read_template():
    actual = isinstance(read_template('assets/madlib.txt'), str)
    expected = True
    assert actual == expected
Esempio n. 26
0
def test_read_empty():
    actual = read_template("assets/test_empty.txt")
    expected = ""
    assert actual == expected
def test_read_template_returns_stripped_string():
    actual = read_template("madlib_cli/assets/easy_peasy.txt")
    expected = "A {Adjective} and {Adjective} {Noun}."
    assert actual == expected
Esempio n. 28
0
def test_read_no_placeholders():
    actual = read_template("assets/test_no_placeholders.txt")
    expected = "Hello there, this is Batool."
    assert actual == expected
Esempio n. 29
0
def test_read_template_raises_exception_with_bad_path():

    with pytest.raises(FileNotFoundError):
        path = "missing.txt"
        read_template(path)
Esempio n. 30
0
def test_read_template():
    expected = "banana"
    actual = read_template("         banana      ")
    assert expected == actual