Beispiel #1
0
    def setUp(self):
        test_vet_peter = Vet("Peter", False)
        test_vet_mark = Vet("Mark", False)
        test_vet_paul = Vet("Paul", False)

        test_owner_david = Owner("David", "Edinburgh", False)
        test_owner_carl = Owner("Carl", "liverpool", False)
        test_owner_jamie = Owner("Jamie", "Glasgow", False)
        test_owner_sarah = Owner("Sarah", "London", False)

        self.test_animal_pepper = Animal("Pepper", "10/11/2015", "Horse",
                                         test_owner_david, test_vet_paul,
                                         False)
        self.test_animal_luna = Animal("Mika", "01/03/2012", "Cat",
                                       test_owner_david, test_vet_mark, False)
        self.test_animal_buddy = Animal("Buddy", "19/01/2014", "Rabbit",
                                        test_owner_carl, test_vet_peter, False)
        self.test_animal_snowy = Animal("Snowy", "17/02/2015", "Dog",
                                        test_owner_carl, test_vet_peter, False)
        self.test_animal_lola = Animal("Lola", "04/08/2018", "Cow",
                                       test_owner_jamie, test_vet_peter, False)
        self.test_animal_apollo = Animal("Apollo", "22/03/2016", "Dog",
                                         test_owner_jamie, test_vet_paul,
                                         False)
        self.test_animal_buster = Animal("Buster", "29/04/2019", "Dog",
                                         test_owner_sarah, test_vet_paul,
                                         False)
        self.test_animal_izzy = Animal("Izzy", "30/05/2020", "Cat",
                                       test_owner_sarah, test_vet_mark, False)
def create_vet():
    first_name = request.form['first_name']
    last_name = request.form['last_name']
    license = request.form['license']
    vet = Vet(first_name, last_name, license)
    vet_repository.save(vet)
    return redirect('/vets')
def update_vet(id):
    first_name = request.form['first_name']
    last_name = request.form['last_name']
    img_url = request.form['img_url'] if request.form['img_url'] else "static/images/no_img.jpg"
    updated_vet = Vet(first_name, last_name, img_url, id)
    vet_repository.update(updated_vet)
    return redirect(f'/vets/{updated_vet.id}')
def create_new_vet():
    first_name = request.form['first_name']
    last_name = request.form['last_name']
    img_url = request.form['img_url'] if request.form['img_url'] else "static/images/no_img.jpg"
    new_vet = Vet(first_name, last_name, img_url)
    vet_repository.save(new_vet)
    return redirect('/vets')
def create():
    first_name = request.form["first_name"]
    last_name = request.form["last_name"]
    max_animals = request.form["max_animals"]
    vet = Vet(first_name, last_name, max_animals)
    vet_repository.save(vet)
    return redirect("/vets")
Beispiel #6
0
 def setUp(self):
     self.vet_1 = Vet("John", "Smith")
     self.owner_1 = Owner("Cpt.", "Jack", "Harkness", "07411000000", True)
     self.animal_1 = Animal("Tigger", datetime.date(2019, 5, 1), "Tiger",
                            self.owner_1)
     self.animal_2 = Animal("Roger", datetime.date(2018, 7, 2), "Rabbit",
                            self.owner_1, self.vet_1)
def select_vet(id):
    sql = "SELECT * FROM vets WHERE id=%s"
    value = [id]
    result = run_sql(sql, value)[0]
    if result is not None:
        vet = Vet(result["name"], result["id"])
        return vet
def new():
    if request.method == 'GET':
        return render_template("vets/new.html.j2")
    if request.method == 'POST':
        name = request.form['name']
        deactivated = False
        if name != "":
            vet = Vet(name, deactivated)
            saved_vet = vet_repository.save(vet)
            if saved_vet.id != None:
                message = f"Success {saved_vet.name} added"
            else:
                message = "Failure"
            if request.form['action'] == "finish":
                return redirect(url_for("vets.index", message=message))
            elif request.form['action'] == "continue":
                return render_template("vets/new.html.j2", message=message)
            else:
                message = "Malformed URL"
            return redirect(url_for("vets.index", message=message))
        else:
            return redirect(url_for("vets.index"))
    else:
        message = "Error finding or displaying page"
        return redirect(url_for("index", message=message))
def update_vet(id):
    first_name = request.form['first_name']
    last_name = request.form['last_name']
    license = request.form ['license']
    vet = Vet(first_name, last_name, license, id)
    vet_repository.update(vet)
    return redirect('/vets')
 def setUp(self):
     self.vet = Vet("Dr. Daisuke Serizawa")
     self.kaiju_1 = Kaiju("Godzilla", "1954", "Sea monster",
                          "Oxygen Destroyer", self.vet, True)
     self.kaiju_2 = Kaiju("Shin_Godzilla", "2016", "Sea monster",
                          "Oral coagulant injection (10000 litres plus)",
                          self.vet, True)
def select(id):
    sql = 'SELECT * FROM vets WHERE id = %s'
    values = [id]
    result = run_sql(sql, values)[0]
    vet = Vet(result['first_name'], result['last_name'], result['license'],
              result['id'])
    return vet
def select_all_vets():
    results = run_sql("SELECT * FROM vets WHERE archived=%s", ["FALSE"])
    vets = []
    for result in results:
        vet = Vet(result["name"], result["id"])
        vets.append(vet)
    return vets
Beispiel #13
0
class TestVet(unittest.TestCase):
    def setUp(self):
        self.vet = Vet("Kevin", "Bacon", 5)

    def test_vet_has_first_name(self):
        expected = "Kevin"
        actual = self.vet.first_name
        self.assertEqual(expected, actual)

    def test_vet_has_last_name(self):
        expected = "Bacon"
        actual = self.vet.last_name
        self.assertEqual(expected, actual)

    def test_vet_has_None_as_id(self):
        actual = self.vet.id
        self.assertIsNone(actual)

    def test_vet_can_get_id(self):
        self.vet.id = 100
        expected = 100
        actual = self.vet.id
        self.assertEqual(expected, actual)

    def test_max_animals_is_5(self):
        expected = 5
        actual = self.vet.max_animals
        self.assertEqual(expected, actual)

    def test_animal_count_is_0(self):
        expected = 0
        actual = self.vet.animal_count
        self.assertEqual(expected, actual)

    def test_set_count(self):
        self.vet.set_count(6)
        expected = 6
        actual = self.vet.animal_count
        self.assertEqual(expected, actual)

    def test_vet_busy(self):
        expected = False
        actual = self.vet.busy
        self.assertEqual(expected, actual)

    def test_set_vet_busy(self):
        self.vet.set_busy()
        expected = True
        actual = self.vet.busy
        self.assertEqual(expected, actual)

    def test_set_vet_available(self):
        self.vet.set_busy()
        self.vet.set_available()
        expected = False
        actual = self.vet.busy
        self.assertEqual(expected, actual)
 def setUp(self):
     self.vet = Vet("Tim Sinnott")
     self.kaiju_1 = Kaiju(
         "Biollante", "1989",
         "Genetically-modified Rose/Crocodile/Ghost of a death girl kaiju hybrid",
         "Finding peace while simultaneously exploding", self.vet, True)
     self.kaiju_2 = Kaiju("Destoroyah", "1995", "Sea monster",
                          "Godzilla in meltdown mode", self.vet, False)
Beispiel #15
0
def select(id):
    vet = None
    sql = "SELECT * FROM vets WHERE id = %s"
    values = [id]
    results = run_sql(sql, values)[0]
    if results is not None:
        vet = Vet(results['name'], results['contact'], results['id'])
    return vet
Beispiel #16
0
def select_all():
    vets = []
    sql = "SELECT * FROM vets"
    results = run_sql(sql)
    for row in results:
        vet = Vet(row['name'], row['contact'], row['id'])
        vets.append(vet)
    return vets
def update(id):
    # vet = vet_repository.select(id)
    first_name = request.form["first_name"]
    last_name = request.form["last_name"]
    max_animals = request.form["max_animals"]
    vet = Vet(first_name, last_name, max_animals, id)
    vet_repository.update(vet)
    return redirect(f"/vets/{id}")
Beispiel #18
0
    def _select_vet(self, id):
        vet = None
        sql = "SELECT * FROM vets WHERE id = %s"
        values = [id]
        result = run_sql(sql, values)[0]

        if result is not None:
            vet = Vet(result["first_name"], result["last_name"], result['id'])
        return vet
def select_all():
    vets = []
    sql = 'SELECT * FROM vets'
    results = run_sql(sql)
    for result in results:
        vet = Vet(result['first_name'], result['last_name'], result['license'],
                  result['id'])
        vets.append(vet)
    return vets
    def select(self, id):
        vet = None
        sql = f"SELECT * FROM {self.table} " + "WHERE id = %s"
        values = [id]
        result = run_sql(sql, values)[0]

        if result is not None:
            vet = Vet(result["first_name"], result["last_name"], result['id'])
        return vet
def select_id(id):
    vet = None
    sql = "SELECT * FROM vets WHERE id = %s"
    values = [id]
    result = run_sql(sql, values)[0]

    if result is not None:
        vet = Vet(result['name'], result['deactivated'], result['id'])
    return vet
def select_all_active(deactivated=False):
    vets = []
    sql = "SELECT * FROM vets WHERE deactivated = %s"
    values = [deactivated]
    results = run_sql(sql, values)

    for row in results:
        vet = Vet(row['name'], row['deactivated'], row['id'])
        vets.append(vet)
    return vets
def select_all_vets():
    vet_list = []

    sql = "SELECT * FROM vets"
    results = run_sql(sql)

    for row in results:
        vet = Vet(row['name'], row['id'])
        vet_list.append(vet)
    return vet_list
 def setUp(self):
     owner = Owner('Jack',
                   'White',
                   '*****@*****.**',
                   '487239847',
                   True,
                   id=4)
     vet = Vet('White', 'Jack', 3)
     self.pet = Pet('Smokey', dt.date(2020, 7, 24), '', 'cat', owner, vet,
                    'randomString', 'dkfjd', 3)
Beispiel #25
0
def select(vet_id):
    sql = "SELECT * FROM vets WHERE id = %s"
    values = [vet_id]
    result = run_sql(sql, values)

    if result:
        vet_dict = result[0]
        vet = Vet(vet_dict['first_name'], vet_dict['last_name'],
                  vet_dict['img_url'], vet_dict['id'])
        return vet
def detail(action, id):
    vet = vet_repository.select_id(id)
    if request.method == 'GET':
        if action == "show":
            return render_template("vets/show.html.j2", vet=vet)
        elif action == "edit":
            return render_template("vets/edit.html.j2", vet=vet)
        else:
            message = "Error Malformed URL"
            return redirect(url_for("vets.index", message=message))
    if request.method == 'POST':
        if action == "delete":
            vet_repository.delete_id(request.form['id'])
            message = f"Vet: {vet.name} (id:{vet.id}) deleted"
            return redirect(url_for("vets.index", message=message))
        elif action == "edit":
            name = request.form['name']
            try:
                deactivated = request.form['deactivated']
                if len(animal_repository.select_all_by_vet_id(id)) > 0:
                    message = f"Vet: {vet.name} (id:{vet.id}) has animals assigned"
                    return redirect(url_for("vets.index", message=message))
            except:
                deactivated = False
            vet = Vet(name, deactivated, id)
            vet_repository.update(vet)
            message = f"Vet: {vet.name} (id:{vet.id}) updated"
            return redirect(url_for("vets.index", message=message))
        elif action == "deactivate":
            if len(animal_repository.select_all_by_vet_id(id)) == 0:
                vet = vet_repository.select_id(id)
                vet.deactivated = True
                vet_repository.update(vet)
                message = f"Vet: {vet.name} (id:{vet.id}) has been deactivated"
            else:
                message = f"Vet: {vet.name} (id:{vet.id}) has animals assigned, reassign these first"
            return redirect(url_for("vets.index", message=message))
        # elif action == "move_animals":
        #code to move all animals from one vet to another#
        else:
            message = "Error Malformed URL"
            return redirect(url_for("vets.index", message=message))
Beispiel #27
0
def select_all():
    vets = []
    sql = "SELECT * FROM vets"
    results = run_sql(sql)

    for row in results:
        vet = Vet(row['first_name'], row['last_name'], row['img_url'],
                  row['id'])
        vets.append(vet)

    return vets
    def select_all(self, sort=False):
        vets = []
        if sort:
            sql = f"SELECT * FROM {self.table} ORDER BY last_name ASC"
        else:
            sql = f"SELECT * FROM {self.table}"
        results = run_sql(sql)

        for row in results:
            vet = Vet(row["first_name"], row["last_name"], row['id'])
            vets.append(vet)
        return vets
Beispiel #29
0
def select(vet_id):
    # Create the SQL query, pass in the data and run it
    sql = "SELECT * FROM vet WHERE id = %s"
    values = [vet_id]
    result = run_sql(sql, values)

    # Create object if data is found in the database
    if len(result) > 0:
        new_vet = Vet(result[0]['first_name'], result[0]['last_name'],
                      result[0]['id'])

    return new_vet
 def setUp(self):
     owner = Owner('Jack',
                   'White',
                   '*****@*****.**',
                   '487239847',
                   True,
                   id=3)
     vet = Vet('White', 'Jack', 3)
     pet = Pet('dummy pet', dt.date(2020, 2, 2), '1', 'dog', owner, vet,
               'dkfj', 'what', 2)
     treatment = Treatment('kadjf', 'a description', 1)
     self.pet_treatment = PetTreatment(pet, treatment, 3)