Beispiel #1
0
def test_create_clutch(
    client: TestClient, superuser_token_headers: dict, db: Session
) -> None:
    snake = create_random_snake(db)
    father = create_random_snake(db)
    data = {
        "clutch_type": "egg",
        "laid_date": "2020-04-20",
        "egg_count": 8,
        "bad_egg_count": 3,
        "good_egg_count": 5,
        "snake_id": snake.id,
        "father_id": father.id
    }
    response = client.post(
        f"{settings.API_V1_STR}/clutches/", headers=superuser_token_headers, json=data,
    )
    assert response.status_code == 200
    content = response.json()
    assert content["clutch_type"] == data["clutch_type"]
    assert content["egg_count"] == data["egg_count"]
    assert content["good_egg_count"] == data["good_egg_count"]
    assert content["bad_egg_count"] == data["bad_egg_count"]
    assert content["father_id"] == data["father_id"]
    assert content["snake_id"] == data["snake_id"]
    assert "id" in content
    assert "created_at" in content
    assert "laid_date" in content
Beispiel #2
0
def test_get_clutch(db: Session) -> None:
    snake = create_random_snake(db)
    father = create_random_snake(db)

    clutch_type = 'egg'
    laid_date = "2020-04-20"
    due_date = "2020-06-20"
    egg_count = 8
    good_egg_count = 7
    bad_egg_count = 1

    clutch_in = ClutchCreate(clutch_type=clutch_type,
                             snake_id=snake.id,
                             father_id=father.id,
                             laid_date=laid_date,
                             due_date=due_date,
                             egg_count=egg_count,
                             good_egg_count=good_egg_count,
                             bad_egg_count=bad_egg_count)
    clutch = crud.clutch.create_with_snake(db=db, obj_in=clutch_in)
    stored_clutch = crud.clutch.get(db=db, id=clutch.id)
    assert clutch
    assert clutch.id == stored_clutch.id
    assert clutch.egg_count == stored_clutch.egg_count
    assert clutch.good_egg_count == stored_clutch.good_egg_count
    assert clutch.bad_egg_count == stored_clutch.bad_egg_count
    assert clutch.father_id == stored_clutch.father_id
    assert clutch.laid_date == stored_clutch.laid_date
    assert clutch.snake.id == stored_clutch.snake.id
Beispiel #3
0
def test_read_mating(client: TestClient, superuser_token_headers: dict,
                     db: Session) -> None:
    snake = create_random_snake(db)
    mate = create_random_snake(db)

    event = 'introduction'
    snake_id = snake.id
    mate_id = mate.id
    event_date = "2020-04-20"

    mate_in = MatingCreate(
        event=event,
        snake_id=snake_id,
        mate_id=mate_id,
        event_date=event_date,
    )
    mating = crud.mating.create_with_snake(db=db, obj_in=mate_in)

    response = client.get(
        f"{settings.API_V1_STR}/matings/{mating.id}",
        headers=superuser_token_headers,
    )
    assert response.status_code == 200
    content = response.json()
    assert content["event"] == mating.event
    assert content["mate_id"] == mating.mate_id
    assert content["snake_id"] == mating.snake_id
    assert content["id"] == mating.id
    assert content["created_at"] == mating.created_at.isoformat()
    assert content["event_date"] == "2020-04-20"
Beispiel #4
0
def test_update_clutch(db: Session) -> None:
    snake = create_random_snake(db)
    father = create_random_snake(db)

    clutch_type = 'egg'
    laid_date = "2020-04-20"
    egg_count = 8
    good_egg_count = 7
    bad_egg_count = 1

    clutch_in = ClutchCreate(clutch_type=clutch_type,
                             snake_id=snake.id,
                             father_id=father.id,
                             laid_date=laid_date,
                             egg_count=egg_count,
                             good_egg_count=good_egg_count,
                             bad_egg_count=bad_egg_count)
    clutch = crud.clutch.create_with_snake(db=db, obj_in=clutch_in)

    egg_count2 = 9
    bad_egg_count2 = 2
    clutch_update = ClutchUpdate(egg_count=egg_count2,
                                 bad_egg_count=bad_egg_count2)
    clutch2 = crud.clutch.update(db=db, db_obj=clutch, obj_in=clutch_update)
    assert clutch.id == clutch2.id
    assert clutch.laid_date == clutch2.laid_date
    assert clutch2.egg_count == egg_count2
    assert clutch2.bad_egg_count == bad_egg_count2
    assert snake.id == clutch2.snake.id
    assert clutch.father_id == clutch.father_id
Beispiel #5
0
def test_create_clutch(db: Session) -> None:
    snake = create_random_snake(db)
    father = create_random_snake(db)

    clutch_type = 'egg'
    laid_date = "2020-04-20"
    due_date = "2020-06-20"
    egg_count = 8
    good_egg_count = 7
    bad_egg_count = 1

    clutch_in = ClutchCreate(clutch_type=clutch_type,
                             snake_id=snake.id,
                             father_id=father.id,
                             laid_date=laid_date,
                             due_date=due_date,
                             egg_count=egg_count,
                             good_egg_count=good_egg_count,
                             bad_egg_count=bad_egg_count)
    clutch = crud.clutch.create_with_snake(db=db, obj_in=clutch_in)
    assert clutch.clutch_type == clutch_type
    assert clutch.egg_count == egg_count
    assert clutch.good_egg_count == good_egg_count
    assert clutch.bad_egg_count == bad_egg_count
    assert clutch.father_id == father.id
    assert clutch.laid_date == datetime.strptime(laid_date, '%Y-%m-%d')
    assert clutch.snake_id == snake.id
Beispiel #6
0
def test_get_feed(db: Session) -> None:
    prey = 'rat'
    prey_type = 'ft'
    prey_size = 'small'
    count = 1
    feed_date = "2020-04-20"

    # Create fake snake
    snake = create_random_snake(db)

    feed_in = FeedCreate(prey=prey,
                         prey_type=prey_type,
                         prey_size=prey_size,
                         count=count,
                         feed_date=feed_date,
                         snake_id=snake.id)
    feed = crud.feed.create_with_snake(db=db, obj_in=feed_in)
    stored_feed = crud.feed.get(db=db, id=feed.id)
    assert feed
    assert feed.id == stored_feed.id
    assert feed.prey == stored_feed.prey
    assert feed.prey_type == stored_feed.prey_type
    assert feed.prey_size == stored_feed.prey_size
    assert feed.count == stored_feed.count
    assert feed.feed_date == stored_feed.feed_date
    assert feed.snake.id == stored_feed.snake.id
Beispiel #7
0
def test_read_shed(client: TestClient, superuser_token_headers: dict,
                   db: Session) -> None:
    complete = False
    pre_lay = False
    shed_date = "2020-04-20"

    # Create fake snake
    snake = create_random_snake(db)

    shed_in = ShedCreate(complete=complete,
                         pre_lay=pre_lay,
                         shed_date=shed_date,
                         snake_id=snake.id)
    shed = crud.shed.create_with_snake(db=db, obj_in=shed_in)

    response = client.get(
        f"{settings.API_V1_STR}/sheds/{shed.id}",
        headers=superuser_token_headers,
    )
    assert response.status_code == 200
    content = response.json()
    assert content["complete"] == shed.complete
    assert content["pre_lay"] == shed.pre_lay
    assert content["snake_id"] == shed.snake_id
    assert content["id"] == shed.id
    assert content["created_at"] == shed.created_at.isoformat()
    assert content["shed_date"] == "2020-04-20"
def test_read_excretion(client: TestClient, superuser_token_headers: dict,
                        db: Session) -> None:
    urates = False
    feces = False
    notes = "test note"
    excretion_date = "2020-04-20"

    # Create fake snake
    snake = create_random_snake(db)

    excretion_in = ExcretionCreate(urates=urates,
                                   feces=feces,
                                   notes=notes,
                                   excretion_date=excretion_date,
                                   snake_id=snake.id)
    excretion = crud.excretion.create_with_snake(db=db, obj_in=excretion_in)

    response = client.get(
        f"{settings.API_V1_STR}/excretions/{excretion.id}",
        headers=superuser_token_headers,
    )
    assert response.status_code == 200
    content = response.json()
    assert content["urates"] == excretion.urates
    assert content["feces"] == excretion.feces
    assert content["notes"] == excretion.notes
    assert content["snake_id"] == excretion.snake_id
    assert content["id"] == excretion.id
    assert content["created_at"] == excretion.created_at.isoformat()
    assert content["excretion_date"] == "2020-04-20"
Beispiel #9
0
def test_read_cycle(client: TestClient, superuser_token_headers: dict,
                    db: Session) -> None:
    snake = create_random_snake(db)

    cycle_type = 'ovulation'
    notes = ""
    snake_id = snake.id
    cycle_date = "2020-04-20"

    cycle_in = CycleCreate(
        cycle_type=cycle_type,
        notes=notes,
        snake_id=snake.id,
        cycle_date=cycle_date,
    )
    cycle = crud.cycle.create_with_snake(db=db, obj_in=cycle_in)

    response = client.get(
        f"{settings.API_V1_STR}/cycles/{cycle.id}",
        headers=superuser_token_headers,
    )
    assert response.status_code == 200
    content = response.json()
    assert content["cycle_type"] == cycle.cycle_type
    assert content["notes"] == cycle.notes
    assert content["snake_id"] == cycle.snake_id
    assert content["id"] == cycle.id
    assert content["created_at"] == cycle.created_at.isoformat()
    assert content["cycle_date"] == "2020-04-20"
Beispiel #10
0
def test_update_feed(db: Session) -> None:
    prey = 'rat'
    prey_type = 'ft'
    prey_size = 'small'
    count = 1
    feed_date = "2020-04-20"

    # Create fake snake
    snake = create_random_snake(db)

    feed_in = FeedCreate(prey=prey,
                         prey_type=prey_type,
                         prey_size=prey_size,
                         count=count,
                         feed_date=feed_date,
                         snake_id=snake.id)
    feed = crud.feed.create_with_snake(db=db, obj_in=feed_in)

    count2 = 2
    prey_size2 = 'large'
    feed_update = FeedUpdate(count=count2, prey_size=prey_size2)
    feed2 = crud.feed.update(db=db, db_obj=feed, obj_in=feed_update)
    assert feed.id == feed2.id
    assert feed.feed_date == feed2.feed_date
    assert feed2.count == count2
    assert feed2.prey_size == prey_size2
    assert feed.snake.id == feed2.snake.id
Beispiel #11
0
def test_delete_feed(db: Session) -> None:
    prey = 'rat'
    prey_type = 'ft'
    prey_size = 'small'
    count = 1
    feed_date = "2020-04-20"

    # Create fake snake
    snake = create_random_snake(db)

    feed_in = FeedCreate(prey=prey,
                         prey_type=prey_type,
                         prey_size=prey_size,
                         count=count,
                         feed_date=feed_date,
                         snake_id=snake.id)

    feed = crud.feed.create_with_snake(db=db, obj_in=feed_in)
    feed2 = crud.feed.remove(db=db, id=feed.id)
    feed3 = crud.feed.get(db=db, id=feed.id)
    assert feed3 is None
    assert feed2.id == feed.id
    assert feed2.feed_date == datetime.strptime(feed_date, '%Y-%m-%d')
    assert feed2.count == count
    assert feed2.snake.id == snake.id
Beispiel #12
0
def test_update_shed(db: Session) -> None:
    urates = False
    feces = False
    notes = "test note"
    excretion_date = "2020-04-20"

    # Create fake snake
    snake = create_random_snake(db)

    excretion_in = ExcretionCreate(urates=urates,
                                   feces=feces,
                                   notes=notes,
                                   excretion_date=excretion_date,
                                   snake_id=snake.id)
    excretion = crud.excretion.create_with_snake(db=db, obj_in=excretion_in)

    urates2 = True
    excretion_update = ExcretionUpdate(urates=urates2)
    excretion2 = crud.excretion.update(db=db,
                                       db_obj=excretion,
                                       obj_in=excretion_update)
    assert excretion.id == excretion2.id
    assert excretion.excretion_date == excretion2.excretion_date
    assert excretion2.urates == urates2
    assert excretion.snake.id == excretion2.snake.id
Beispiel #13
0
def test_delete_shed(db: Session) -> None:
    urates = False
    feces = False
    notes = "test note"
    excretion_date = "2020-04-20"

    # Create fake snake
    snake = create_random_snake(db)

    excretion_in = ExcretionCreate(urates=urates,
                                   feces=feces,
                                   notes=notes,
                                   excretion_date=excretion_date,
                                   snake_id=snake.id)
    excretion = crud.excretion.create_with_snake(db=db, obj_in=excretion_in)
    excretion2 = crud.excretion.remove(db=db, id=excretion.id)
    excretion3 = crud.excretion.get(db=db, id=excretion.id)
    assert excretion3 is None
    assert excretion2.id == excretion.id
    assert excretion2.excretion_date == datetime.strptime(
        excretion_date, '%Y-%m-%d')
    assert excretion2.urates == urates
    assert excretion2.feces == feces
    assert excretion2.notes == notes
    assert excretion2.snake.id == snake.id
Beispiel #14
0
def test_create_feed(client: TestClient, superuser_token_headers: dict,
                     db: Session) -> None:
    snake = create_random_snake(db)
    data = {
        "prey": "rat",
        "prey_type": "ft",
        "prey_size": "small",
        "feed_date": "2020-04-20",
        "count": 1,
        "snake_id": snake.id,
    }
    response = client.post(
        f"{settings.API_V1_STR}/feeds/",
        headers=superuser_token_headers,
        json=data,
    )
    assert response.status_code == 200
    content = response.json()
    assert content["prey"] == data["prey"]
    assert content["prey_type"] == data["prey_type"]
    assert content["prey_size"] == data["prey_size"]
    assert content["count"] == data["count"]
    assert content["snake_id"] == data["snake_id"]
    assert "id" in content
    assert "created_at" in content
    assert "feed_date" in content
Beispiel #15
0
def test_read_shed(client: TestClient, superuser_token_headers: dict,
                   db: Session) -> None:
    prey = 'rat'
    prey_type = 'ft'
    prey_size = 'small'
    count = 1
    feed_date = "2020-04-20"

    # Create fake snake
    snake = create_random_snake(db)

    feed_in = FeedCreate(prey=prey,
                         prey_type=prey_type,
                         prey_size=prey_size,
                         count=count,
                         feed_date=feed_date,
                         snake_id=snake.id)
    feed = crud.feed.create_with_snake(db=db, obj_in=feed_in)

    response = client.get(
        f"{settings.API_V1_STR}/feeds/{feed.id}",
        headers=superuser_token_headers,
    )
    assert response.status_code == 200
    content = response.json()
    assert content["prey"] == feed.prey
    assert content["prey_type"] == feed.prey_type
    assert content["prey_size"] == feed.prey_size
    assert content["count"] == feed.count
    assert content["snake_id"] == feed.snake_id
    assert content["id"] == feed.id
    assert content["created_at"] == feed.created_at.isoformat()
    assert content["feed_date"] == "2020-04-20"
Beispiel #16
0
def test_create_mating(db: Session) -> None:
    snake = create_random_snake(db)
    mate = create_random_snake(db)

    event = 'introduction'
    mate_id = mate.id
    event_date = "2020-04-20"

    mate_in = MatingCreate(
        event=event,
        snake_id=snake.id,
        mate_id=mate_id,
        event_date=event_date,
    )
    mating = crud.mating.create_with_snake(db=db, obj_in=mate_in)
    assert mating.event == event
    assert mating.mate_id == mate_id
    assert mating.event_date == datetime.strptime(event_date, '%Y-%m-%d')
    assert mating.snake_id == snake.id
Beispiel #17
0
def test_get_mating(db: Session) -> None:
    snake = create_random_snake(db)
    mate = create_random_snake(db)

    event = 'introduction'
    mate_id = mate.id
    event_date = "2020-04-20"

    mate_in = MatingCreate(
        event=event,
        snake_id=snake.id,
        mate_id=mate_id,
        event_date=event_date,
    )

    mating = crud.mating.create_with_snake(db=db, obj_in=mate_in)
    stored_mating = crud.mating.get(db=db, id=mating.id)
    assert mating
    assert mating.id == stored_mating.id
    assert mating.mate_id == stored_mating.mate_id
    assert mating.event_date == stored_mating.event_date
    assert mating.snake.id == stored_mating.snake.id
Beispiel #18
0
def test_read_clutch(
    client: TestClient, superuser_token_headers: dict, db: Session
) -> None:
    snake = create_random_snake(db)
    father = create_random_snake(db)

    clutch_type = 'egg'
    laid_date = "2020-04-20"
    notes = ""
    egg_count = 8
    good_egg_count = 7
    bad_egg_count = 1

    clutch_in = ClutchCreate(
        clutch_type=clutch_type,
        snake_id=snake.id,
        father_id=father.id,
        laid_date=laid_date,
        egg_count=egg_count,
        good_egg_count=good_egg_count,
        bad_egg_count=bad_egg_count,
        notes=notes
    )
    clutch = crud.clutch.create_with_snake(db=db, obj_in=clutch_in)

    response = client.get(
        f"{settings.API_V1_STR}/clutches/{clutch.id}", headers=superuser_token_headers,
    )
    assert response.status_code == 200
    content = response.json()
    assert content["clutch_type"] == clutch.clutch_type
    assert content["egg_count"] == clutch.egg_count
    assert content["good_egg_count"] == clutch.good_egg_count
    assert content["bad_egg_count"] == clutch.bad_egg_count
    assert content["father_id"] == clutch.father_id
    assert content["snake_id"] == clutch.snake_id
    assert content["id"] == clutch.id
    assert content["created_at"] == clutch.created_at.isoformat()
    assert content["laid_date"] == "2020-04-20"
Beispiel #19
0
def test_create_mating(client: TestClient, superuser_token_headers: dict,
                       db: Session) -> None:
    snake = create_random_snake(db)
    mate = create_random_snake(db)
    data = {
        "event": "introduction",
        "event_date": "2020-04-20",
        "snake_id": snake.id,
        "mate_id": mate.id
    }
    response = client.post(
        f"{settings.API_V1_STR}/matings/",
        headers=superuser_token_headers,
        json=data,
    )
    assert response.status_code == 200
    content = response.json()
    assert content["event"] == data["event"]
    assert content["mate_id"] == data["mate_id"]
    assert content["snake_id"] == data["snake_id"]
    assert "id" in content
    assert "created_at" in content
    assert "event_date" in content
Beispiel #20
0
def test_create_weight(db: Session) -> None:
    weight = random_weight_int()
    weight_date = "2020-04-20"

    # Create fake snake
    snake = create_random_snake(db)

    weight_in = WeightCreate(weight=weight,
                             weight_date=weight_date,
                             snake_id=snake.id)
    weight_record = crud.weight.create_with_snake(db=db, obj_in=weight_in)
    assert weight_record.weight == weight
    assert weight_record.weight_date == datetime.strptime(
        weight_date, "%Y-%m-%d")
    assert weight_record.snake_id == snake.id
Beispiel #21
0
def test_update_mating(db: Session) -> None:
    snake = create_random_snake(db)
    mate = create_random_snake(db)

    event = 'introduction'
    mate_id = mate.id
    event_date = "2020-04-20"

    mate_in = MatingCreate(
        event=event,
        snake_id=snake.id,
        mate_id=mate_id,
        event_date=event_date,
    )
    mating = crud.mating.create_with_snake(db=db, obj_in=mate_in)

    event2 = 'breeding'
    mating_update = MatingUpdate(event=event2)
    mating2 = crud.mating.update(db=db, db_obj=mating, obj_in=mating_update)
    assert mating.id == mating2.id
    assert mating.event_date == mating2.event_date
    assert mating2.event == event2
    assert snake.id == mating2.snake.id
    assert mating.mate_id == mating2.mate_id
Beispiel #22
0
def test_create_weight(client: TestClient, superuser_token_headers: dict,
                       db: Session) -> None:
    snake = create_random_snake(db)
    data = {"weight": 100, "weight_date": "2020-04-20", "snake_id": snake.id}
    response = client.post(
        f"{settings.API_V1_STR}/weights/",
        headers=superuser_token_headers,
        json=data,
    )
    assert response.status_code == 200
    content = response.json()
    assert content["weight"] == data["weight"]
    assert content["snake_id"] == data["snake_id"]
    assert "id" in content
    assert "created_at" in content
    assert "weight_date" in content
Beispiel #23
0
def test_get_weight(db: Session) -> None:
    weight = random_weight_int()
    weight_date = "2020-04-20"

    # Create fake snake
    snake = create_random_snake(db)

    weight_in = WeightCreate(weight=weight,
                             weight_date=weight_date,
                             snake_id=snake.id)
    weight_record = crud.weight.create_with_snake(db=db, obj_in=weight_in)
    stored_weight = crud.weight.get(db=db, id=weight_record.id)
    assert stored_weight
    assert weight_record.id == stored_weight.id
    assert weight_record.weight == stored_weight.weight
    assert weight_record.weight_date == stored_weight.weight_date
    assert weight_record.snake.id == stored_weight.snake.id
Beispiel #24
0
def test_read_snake(client: TestClient, superuser_token_headers: dict,
                    db: Session) -> None:
    snake = create_random_snake(db)
    response = client.get(
        f"{settings.API_V1_STR}/snakes/{snake.id}",
        headers=superuser_token_headers,
    )
    assert response.status_code == 200
    content = response.json()
    assert content["name"] == snake.name
    assert content["description"] == snake.description
    assert content["id"] == snake.id
    assert content["owner_id"] == snake.owner_id
    assert content["created_at"] == snake.created_at.isoformat()
    assert content["hatch_date"] == '2020-04-20'
    assert content["sex"] == snake.sex
    assert content["produced_by"] == snake.produced_by
Beispiel #25
0
def test_create_shed(db: Session) -> None:
    complete = False
    pre_lay = False
    shed_date = "2020-04-20"

    # Create fake snake
    snake = create_random_snake(db)

    shed_in = ShedCreate(complete=complete,
                         pre_lay=pre_lay,
                         shed_date=shed_date,
                         snake_id=snake.id)
    shed = crud.shed.create_with_snake(db=db, obj_in=shed_in)
    assert shed.complete == complete
    assert shed.pre_lay == pre_lay
    assert shed.shed_date == datetime.strptime(shed_date, '%Y-%m-%d')
    assert shed.snake_id == snake.id
Beispiel #26
0
def test_create_cycle(db: Session) -> None:
    snake = create_random_snake(db)

    cycle_type = 'follicles'
    notes = ""
    cycle_date = "2020-04-20"

    cycle_in = CycleCreate(
        cycle_type=cycle_type,
        notes=notes,
        snake_id=snake.id,
        cycle_date=cycle_date,
    )
    cycle = crud.cycle.create_with_snake(db=db, obj_in=cycle_in)
    assert cycle.cycle_type == cycle_type
    assert cycle.notes == notes
    assert cycle.cycle_date == datetime.strptime(cycle_date, '%Y-%m-%d')
    assert cycle.snake_id == snake.id
Beispiel #27
0
def test_delete_weight(db: Session) -> None:
    weight = random_weight_int()
    weight_date = "2020-04-20"

    # Create Fake Snake
    snake = create_random_snake(db)

    weight_in = WeightCreate(weight=weight,
                             weight_date=weight_date,
                             snake_id=snake.id)

    weight_record = crud.weight.create_with_snake(db=db, obj_in=weight_in)
    weight_record2 = crud.weight.remove(db=db, id=weight_record.id)
    weight_record3 = crud.weight.get(db=db, id=weight_record.id)
    assert weight_record3 is None
    assert weight_record2.id == weight_record.id
    assert weight_record2.weight_date == datetime.strptime(
        weight_date, "%Y-%m-%d")
    assert weight_record2.weight == weight
    assert weight_record2.snake.id == snake.id
Beispiel #28
0
def test_get_shed(db: Session) -> None:
    complete = False
    pre_lay = False
    shed_date = "2020-04-20"

    # Create fake snake
    snake = create_random_snake(db)

    shed_in = ShedCreate(complete=complete,
                         pre_lay=pre_lay,
                         shed_date=shed_date,
                         snake_id=snake.id)
    shed = crud.shed.create_with_snake(db=db, obj_in=shed_in)
    stored_shed = crud.shed.get(db=db, id=shed.id)
    assert shed
    assert shed.id == stored_shed.id
    assert shed.complete == stored_shed.complete
    assert shed.pre_lay == stored_shed.pre_lay
    assert shed.shed_date == stored_shed.shed_date
    assert shed.snake.id == stored_shed.snake.id
Beispiel #29
0
def test_create_excretion(db: Session) -> None:
    urates = False
    feces = False
    notes = "test note"
    excretion_date = "2020-04-20"

    # Create fake snake
    snake = create_random_snake(db)

    excretion_in = ExcretionCreate(urates=urates,
                                   feces=feces,
                                   notes=notes,
                                   excretion_date=excretion_date,
                                   snake_id=snake.id)
    excretion = crud.excretion.create_with_snake(db=db, obj_in=excretion_in)
    assert excretion.urates == urates
    assert excretion.feces == feces
    assert excretion.excretion_date == datetime.strptime(
        excretion_date, '%Y-%m-%d')
    assert excretion.snake_id == snake.id
Beispiel #30
0
def test_create_shed(client: TestClient, superuser_token_headers: dict,
                     db: Session) -> None:
    snake = create_random_snake(db)
    data = {
        "complete": True,
        "pre_lay": False,
        "shed_date": "2020-04-20",
        "snake_id": snake.id
    }
    response = client.post(
        f"{settings.API_V1_STR}/sheds/",
        headers=superuser_token_headers,
        json=data,
    )
    assert response.status_code == 200
    content = response.json()
    assert content["complete"] == data["complete"]
    assert content["snake_id"] == data["snake_id"]
    assert "id" in content
    assert "created_at" in content
    assert "shed_date" in content