def test_play_student(self):
        student = lib.Student("Alice", 50)
        self.assertEqual(student.fat, 50)
        self.assertEqual(student.energy, 0)

        student.energy = 10
        student.play_games()
        self.assertNotEqual(student.energy, -1)
        self.assertNotEqual(student.energy, 11)
    def test_study_student(self):
        student = lib.Student("Alice", 50)
        student.energy = 10
        student.study()
        self.assertEqual(student.energy, 0)
        self.assertEqual(student.get_mood(), 'very bad')
        self.assertEqual(student.xp, 2)

        student.study()
        self.assertEqual(student.energy, 0)
        self.assertEqual(student.get_mood(), 'very bad')
        self.assertEqual(student.xp, 2)
    def test_eating_class(self):
        student = lib.Student("Alice", 50)
        food = lib.Food()
        self.assertEqual(student.fat, 50)
        self.assertEqual(student.energy, 0)

        student.eat()
        self.assertEqual(student.fat, 53)
        self.assertEqual(student.energy, 1)
        self.assertEqual(student.get_mood(), 'good')

        for _ in range(3):
            student.eat(food)
        self.assertEqual(student.fat, 62)
        self.assertEqual(student.energy, 4)
        self.assertEqual(student.get_mood(), 'very good')
Пример #4
0
def start():
    global student
    name = flask.request.args['name']
    weight = flask.request.args['weight']
    student = lib.Student(name, int(weight))
    return "Done"
Пример #5
0
import flask
import json
from server import lib
import tkinter
from server import checker

app = flask.Flask("Distance Learning Server")

student = lib.Student('Unknown', 0)

default_ip = "localhost:8000"
registered = False


@app.route('/start', methods=['POST'])
def start():
    global student
    name = flask.request.args['name']
    weight = flask.request.args['weight']
    student = lib.Student(name, int(weight))
    return "Done"


@app.route('/get_params', methods=['GET'])
def get_params():
    return json.dumps(
        list(
            map(str,
                [student.energy, student.fat,
                 student.get_mood(), student.xp])))