def test_populate_from_json():
    _model = model.Model()
    _model.populate_from_json(
        pkg_resources.resource_filename("resources", "tods_test_sample.json"))
    assert len(_model.get_all_categories()) == 2
    assert len(_model.get_all_questions()) == 8
    assert len(_model.get_questions_of_type_and_category('Truth', 2)) == 2
def test_get_questions_of_type():
    _model = model.Model()
    _model.add_question("Question 1", "Truth", "Category 1")
    _model.add_question("Question 2", "Truth", "Category 2")
    _model.add_question("Question 3", "Dare", "Category 3")
    assert len(_model.get_questions_of_type("Truth")) == 2
    assert len(_model.get_questions_of_type("Dare")) == 1
def test_create_db():
    db = model.Model().create_db()
    cursor = db.cursor()
    cursor.execute("SELECT * FROM categories")
    assert cursor.fetchone() is None
    cursor.execute("SELECT * FROM questions")
    assert cursor.fetchone() is None
def test_add_question():
    _model = model.Model()
    assert _model.add_question("Question 1", "Truth", "Category 1") == (1, 1)
    assert _model.add_question("Question 2", "Truth", "Category 1") == (2, 1)
    assert _model.add_question("Question 3", "Truth", "Category 2") == (3, 2)
    assert _model.add_question("Question 3", "Truth", "Category 2") == (3, 2)
    assert _model.add_question("Question 3", "Truth", "Category 3") == (3, 2)
    assert _model.add_question("Question 4", "Truth", None) is None
def test_get_questions_of_type_and_category():
    _model = model.Model()
    _model.add_question("Question 1", "Truth", "Category 1")
    _model.add_question("Question 2", "Truth", "Category 1")
    _model.add_question("Question 3", "Truth", "Category 2")
    _model.add_question("Question 3", "Truth", "Category 2")
    _model.add_question("Question 3", "Truth", "Category 3")
    _model.add_question("Question 4", "Truth", "Category 2")
    _model.add_question("Question 5", "Dare", "Category 2")
    assert len(_model.get_questions_of_type_and_category("Truth", 2)) == 2
    assert len(_model.get_questions_of_type_and_category("Dare", 2)) == 1
    assert len(_model.get_questions_of_type_and_category("Dare", 1)) == 0
def test_get_question_with_id():
    _model = model.Model()
    _model.add_question("Question 1", "Truth", "Category 1")
    assert _model.get_question_with_id(0) is None
    assert _model.get_question_with_id(1)[3] == 1
def test_get_question_id():
    _model = model.Model()
    assert not _model.get_question_id("Question 1")
    _model.add_question("Question 1", "Truth", "Category 1")
    assert _model.get_question_id("Question 1") == 1
def test_get_category_id():
    _model = model.Model()
    assert not _model.get_category_id("category1")
    _model.add_category("category1")
    assert _model.get_category_id("category1") == 1
def test_get_all_categories():
    _model = model.Model()
    assert len(_model.get_all_categories()) == 0
    _model.add_category("category1")
    assert len(_model.get_all_categories()) == 1
def test_add_category():
    _model = model.Model()
    assert _model.add_category(None) is None
    assert _model.add_category("category1") == 1
    assert _model.add_category("category2") == 2
    assert _model.add_category("category2") == 2
Esempio n. 11
0
import pkg_resources
from tod import model

ALEXA_SKILL_ID = ""
with open(pkg_resources.resource_filename("resources", "alexa_skill_id.txt"),
          'r') as alexa_skill_id_file:
    ALEXA_SKILL_ID = alexa_skill_id_file.read().strip()
TOD_MODEL = model.Model()
TOD_MODEL.populate_from_json(
    pkg_resources.resource_filename("resources", "tods.json"))
WELCOME_SPEECH = "Welcome to the Truth or Dare game. " \
                 "If you want to hear the game rules, say: give me the rules. " \
                 "If you want me to list the different categories, say: give me the categories."
WELCOME_REPROMPT = "If you want to hear the game rules, say: give me the rules. " \
                   "If you want me to list the different categories, say: give me the categories."
END_SPEECH = "Thank you for trying the Truth or Dare game. Have a nice day!"
DEFAULT_SPEECH = "Just Ask"
RULES_SPEECH = "In the game of Truth or Dare each participant has the choice in whether they would like to complete " \
               "a challenge, or express a truth. Dares are challenges that must be completed by the participant that " \
               "they were given to. If a dare is not completed, there will be a penalty that will be decided by all " \
               "participants in the game. For example, if someone refuses to do a dare, the group may decide that " \
               "player cannot blink until next round.  If a participant chooses Truth, he or she must answer the " \
               "given question truthfully. The players may decide if there were will be limited or unlimited amount " \
               "of truths for each player. In the game of Truth or Dare, it is no fun if people pick truth every " \
               "single time."
HELP_SPEECH = "Here are some things you can say: give me the categories, give me the rules, give me a dare from the " \
              "category kids, play category kids. You can also say, stop, if you're done. So, how can I help?"


def lambda_handler(event, context=None):