def test_retrieve_multiple_errors(mongo_service: MongoService,
                                  request_user_1: User, monkeypatch):
    mongo_service.create(
        request_user_1,
        deepcopy(celebrimbor),
    )
    mongo_service.create(request_user_1, deepcopy(legolas))
    mongo_service.create(request_user_1, deepcopy(galadriel))
    mongo_service.create(request_user_1, deepcopy(elrond))
    with pytest.raises(TypeError,
                       match="`sort` argument must be of type list"):
        mongo_service.retrieve_multiple(request_user_1, sort=None)
Пример #2
0
def test_order_by_key(mongo_service: MongoService, request_user_1: User, monkeypatch):
    mongo_service.create(
            request_user_1,
            deepcopy(celebrimbor),
        )
    mongo_service.create(request_user_1, deepcopy(legolas))
    mongo_service.create(request_user_1, deepcopy(galadriel))
    mongo_service.create(request_user_1, deepcopy(elrond))
    elves = list(mongo_service.retrieve_multiple(request_user_1, sort="name", order=1))

    assert len(elves) == 4
    equal_dicts(celebrimbor, elves[0], ignore_keys)
    equal_dicts(elrond, elves[1], ignore_keys)
    equal_dicts(galadriel, elves[2], ignore_keys)
    equal_dicts(legolas, elves[3], ignore_keys)
Пример #3
0
def test_create_ordering(mongo_service: MongoService, request_user_1: User, monkeypatch):
    with freeze_time(mock_times[0], tz_offset=-4, auto_tick_seconds=15):
        mongo_service.create(
            request_user_1,
            deepcopy(celebrimbor),
        )
        mongo_service.create(request_user_1, deepcopy(legolas))
        mongo_service.create(request_user_1, deepcopy(galadriel))
        mongo_service.create(request_user_1, deepcopy(elrond))

        elves = list(mongo_service.retrieve_multiple(request_user_1))

        assert len(elves) == 4
        equal_dicts(elrond, elves[0], ignore_keys)
        equal_dicts(galadriel, elves[1], ignore_keys)
        equal_dicts(legolas, elves[2], ignore_keys)
        equal_dicts(celebrimbor, elves[3], ignore_keys)