예제 #1
0
파일: tests.py 프로젝트: jstoebel/tree_id
    def test_guess_not_null(self):
        """
        pre: none
        post: confirms that a record may not be saved without a value for guess
        """
        n = Node(guess=None)

        with self.assertRaises(IntegrityError):
            n.save()
예제 #2
0
def populate_data():
    """
    pre: none
    post: resets the database back to the initial state as follows:
        according the data in initial_data.json
    """
    print 'populating data '
    with open('trees/initial_data.json', 'r') as data_file:
        data = json.load(data_file)

    for record in data:

        print "record is", record

        node = Node(id=record['id'],
                    guess=record['guess'],
                    edge=record['edge'],
                    parent_id=record['parent_id'],
                    question=record['question']
                    )
        node.save()

    print ' -> Done!'