Esempio n. 1
0
def add_Growth():
    # title, url, notes, date_added, date_edited
    name = request.json["Name"]
    Lname = request.json["LName"]
    head = request.json["head"]
    weight = request.json["weight"]
    hight = request.json["hight"]
    age = request.json["age"]
    gender = request.json["gender"]
    notes = request.json["notes"]
    date_added = request.json["date_added"]
    date_edited = request.json["date_edited"]

    cmd = commands.AddGrowthCommand(name, Lname, head, weight, hight, age,
                                    gender, notes, date_added, date_edited)
    bus.handle(cmd)
    return "OK", 201
Esempio n. 2
0
    def test_get_all_growth(self):
        bus = boostrap_test_app()

        nu: datetime = datetime(2021, 4, 15, 0, 0, 0, 0, tzinfo=timezone.utc)
        bus.handle(
            commands.AddGrowthCommand(
                85,
                f"John",  # Name
                f"Smith",  #Lname
                f"http://example.com",  # url
                35,  #head
                28,  #weight
                3,  #hight
                2,  #age
                f"boy",  #gender
                nu.isoformat(),  # date added
                nu.isoformat(),  # date edited
            ))

        nuto = nu + timedelta(days=2, hours=12)

        bus.handle(
            commands.AddgrowthCommand(
                85,
                f"Lisa",  # Name
                f"Davice",  #Lname
                f"http://example.com",  # url
                38,  #head
                35,  #weight
                3.5,  #hight
                4,  #age
                f"girl",  #gender
                nu.isoformat(),  # date added
                nu.isoformat(),  # date edited
            ))

        records = bus.uow.Growth.get_all()
        assert len(records) == 2
Esempio n. 3
0
    def test_get_growth_by_url(self):
        bus = boostrap_test_app()

        nu: datetime = datetime(2021, 4, 15, 0, 0, 0, 0, tzinfo=timezone.utc)

        # add one
        bus.handle(
            commands.AddGrowthCommand(
                85,
                f"John",  # Name
                f"Smith",  #Lname
                f"http://example.com",  # url
                35,  #head
                28,  #weight
                3,  #hight
                2,  #age
                f"boy",  #gender
                nu.isoformat(),  # date added
                nu.isoformat(),  # date edited
            ))

        assert bus.uow.Growth.get_by_url(f"http://example.com") is not None
        assert bus.uow.committed