def update_nurse(id): nurse = nurse_repository.select(id) name = request.form["name"] nurse = Nurse(name) nurse.id = id nurse_repository.update(nurse) return redirect("/nurses/index")
def select_all(): nurses = [] sql = "SELECT * FROM nurses" results = run_sql(sql) for result in results: nurse = Nurse(result["name"], result["id"]) nurses.append(nurse) return nurses
def select(id): nurse = None sql = "SELECT * FROM nurses WHERE id = %s" values = [id] result = run_sql(sql, values)[0] if result is not None: nurse = Nurse(result['name'], result['id']) return nurse
def select_all(): nurses = [] sql = "SELECT * FROM nurses" results = run_sql(sql) for row in results: nurse = Nurse(row['name'], row['specialisation'], row['id']) nurses.append(nurse) return nurses
import pdb from models.nurse import Nurse from models.pokemon import Pokemon from models.trainer import Trainer import repositories.nurse_repository as nurse_repository import repositories.pokemon_repository as pokemon_repository import repositories.trainer_repository as trainer_repository # pokemon_repository.delete_all() # nurse_repository.delete_all() # trainer_repository.delete_all() nurse_1 = Nurse("Joy", "Fire") nurse_repository.save(nurse_1) trainer = Trainer("Simon", 12345) trainer_repository.save(trainer) pokemon = Pokemon('Seed Backman', 'Bulbasaur', 'Grass', '25/09/1990', trainer , 'burned') pokemon.assign_nurse(nurse_1) pokemon_repository.save(pokemon) trainer.name = 'Simondovich' trainer_repository.update(trainer)
def edit_nurse(id): name = request.form['name'] specialisation = request.form['specialisation'] nurse = Nurse(name, specialisation, id) nurse_repository.update(nurse) return redirect('/staff')
def add_nurse(): name = request.form['name'] specialisation = request.form['specialisation'] nurse = Nurse(name, specialisation) nurse_repository.save(nurse) return redirect('/staff')
def setUp(self): self.nurse_1 = Nurse('Joy')
def setUp(self): self.nurse = Nurse("Joy", "fire")
def create_nurse(): name = request.form["name"] new_nurse = Nurse(name) nurse_repository.save(new_nurse) return redirect("/nurses/index")
from models.pokemon import Pokemon from models.trainer import Trainer from models.nurse import Nurse import repositories.pokemon_repository as pokemon_repository import repositories.trainer_repository as trainer_repository import repositories.nurse_repository as nurse_repository pokemon_repository.delete_all() nurse_repository.delete_all() # trainer_repository.delete_all() # trainer_1 = Trainer('Ash', '2 Pallet Town', 32356) # trainer_2 = Trainer('Misty', 'Cerulean Gym', 78232) nurse_1 = Nurse('Joy') nurse_2 = Nurse('Joye') pokemon_1 = Pokemon('Sparky', 'trainer_1', 'Pikachu', '15/6/2017', nurse_1, "Crushed by Snorlax") pokemon_2 = Pokemon('Frankie', 'trainer_2', 'Psyduck', '12/1/2016', nurse_1, "Burnt by Charizard") pokemon_3 = Pokemon('Sally', 'trainer_2', 'Seel', '15/8/2015', nurse_2, "Shocked by Pikachu") #assign nurse to pokemon before running console.py # trainer_repository.save(trainer_1) # trainer_repository.save(trainer_2) nurse_repository.save(nurse_1) nurse_repository.save(nurse_2) pokemon_repository.save(pokemon_1)
def test_get_nurse_name(self): nurse = Nurse('Joy', 'fire') self.pokemon.assign_nurse(nurse) self.assertEqual('Joy', self.pokemon.nurse.name)
def test_assign_nurse(self): nurse = Nurse('Joy', 'fire') self.pokemon.assign_nurse(nurse) self.assertEqual(nurse, self.pokemon.nurse)