Esempio n. 1
0
def test_questions():
    the_json = helpers.ensure_valid_json('resources/troubleshooter/data.json')

    questions = the_json['questions']
    askiffixed_question = the_json['askiffixed_question']
    check_question('askiffixed_question', askiffixed_question)

    for id_, question_data in questions.items():
        check_question(id_, question_data)
Esempio n. 2
0
def test_questions():
    the_json = helpers.ensure_valid_json('resources/troubleshooter/data.json')

    questions = the_json['questions']
    askiffixed_question = the_json['askiffixed_question']
    check_question('askiffixed_question', askiffixed_question)

    for id_, question_data in questions.items():
        check_question(id_, question_data)
Esempio n. 3
0
def test_data_file():
    data = helpers.ensure_valid_json("resources/2016/teams.json")

    data_previous = helpers.ensure_valid_json("resources/2015/teams.json")

    for tla, info in data.items():
        assert "URL" in info
        assert "name" in info
        assert "rookie" in info

        url = info["URL"]
        assert len(url) > 0
        scheme, loc, _, _, _, _ = urlparse.urlparse(url)
        assert len(scheme) > 0
        assert len(loc) > 0

        name = info["name"]
        assert len(name) > 0

        rookie = info["rookie"]
        assert isinstance(rookie, bool)
        if rookie:
            assert tla not in data_previous
Esempio n. 4
0
def test_data_file():
    data = helpers.ensure_valid_json('resources/2016/teams.json')

    data_previous = helpers.ensure_valid_json('resources/2015/teams.json')

    for tla, info in data.items():
        assert 'URL' in info
        assert 'name' in info
        assert 'rookie' in info

        url = info['URL']
        assert len(url) > 0
        scheme, loc, _, _, _, _ = urlparse.urlparse(url)
        assert len(scheme) > 0
        assert len(loc) > 0

        name = info['name']
        assert len(name) > 0

        rookie = info['rookie']
        assert isinstance(rookie, bool)
        if rookie:
            assert tla not in data_previous
Esempio n. 5
0
def test_nextquestion():
    the_json = helpers.ensure_valid_json('resources/troubleshooter/data.json')

    questions = the_json['questions']

    next_questions = set()

    for id_, question_data in questions.items():
        assert 'answers' in question_data, id_
        answers = question_data['answers']

        for ans_data in answers:
            if 'nextquestion' in ans_data:
                next_questions.add(ans_data['nextquestion'])

    all_questions = set(questions.keys())
    missing = next_questions - all_questions

    assert missing == set(), "Some questions link to missing questions"

    # Also remove the 'root' question, which has an empty id
    unlinked = all_questions - next_questions - set([""])

    assert unlinked == set(), "Some questions are never used"
Esempio n. 6
0
def test_nextquestion():
    the_json = helpers.ensure_valid_json('resources/troubleshooter/data.json')

    questions = the_json['questions']

    next_questions = set()

    for id_, question_data in questions.items():
        assert 'answers' in question_data, id_
        answers = question_data['answers']

        for ans_data in answers:
            if 'nextquestion' in ans_data:
                next_questions.add(ans_data['nextquestion'])

    all_questions = set(questions.keys())
    missing = next_questions - all_questions

    assert missing == set(), "Some questions link to missing questions"

    # Also remove the 'root' question, which has an empty id
    unlinked = all_questions - next_questions - set([""])

    assert unlinked == set(), "Some questions are never used"
Esempio n. 7
0
def test_data_file():
    the_json = helpers.ensure_valid_json('resources/troubleshooter/data.json')
    assert 'askiffixed_question' in the_json
    assert 'questions' in the_json
Esempio n. 8
0
def test_data_file():
    the_json = helpers.ensure_valid_json('resources/troubleshooter/data.json')
    assert 'askiffixed_question' in the_json
    assert 'questions' in the_json