Beispiel #1
0
def test_serialize_snapshot(user_factory):
    auth_user = user_factory()
    snapshot = model.Snapshot()
    snapshot.operation = snapshot.OPERATION_CREATED
    snapshot.resource_type = 'type'
    snapshot.resource_name = 'id'
    snapshot.user = user_factory(name='issuer')
    snapshot.data = {'complex': list('object')}
    snapshot.creation_time = datetime(1997, 1, 1)
    with patch('szurubooru.func.users.serialize_micro_user'):
        users.serialize_micro_user.return_value = 'mocked'
        assert snapshots.serialize_snapshot(snapshot, auth_user) == {
            'operation': 'created',
            'type': 'type',
            'id': 'id',
            'user': '******',
            'data': {'complex': list('object')},
            'time': datetime(1997, 1, 1),
        }
Beispiel #2
0
def test_serialize_snapshot(user_factory):
    auth_user = user_factory()
    snapshot = model.Snapshot()
    snapshot.operation = snapshot.OPERATION_CREATED
    snapshot.resource_type = "type"
    snapshot.resource_name = "id"
    snapshot.user = user_factory(name="issuer")
    snapshot.data = {"complex": list("object")}
    snapshot.creation_time = datetime(1997, 1, 1)
    with patch("szurubooru.func.users.serialize_micro_user"):
        users.serialize_micro_user.return_value = "mocked"
        assert snapshots.serialize_snapshot(snapshot, auth_user) == {
            "operation": "created",
            "type": "type",
            "id": "id",
            "user": "******",
            "data": {
                "complex": list("object")
            },
            "time": datetime(1997, 1, 1),
        }
Beispiel #3
0
def get_snapshots(ctx: rest.Context,
                  _params: Dict[str, str] = {}) -> rest.Response:
    auth.verify_privilege(ctx.user, 'snapshots:list')
    return _search_executor.execute_and_serialize(
        ctx, lambda snapshot: snapshots.serialize_snapshot(snapshot, ctx.user))
Beispiel #4
0
def get_snapshots(
        ctx: rest.Context, _params: Dict[str, str] = {}) -> rest.Response:
    auth.verify_privilege(ctx.user, 'snapshots:list')
    return _search_executor.execute_and_serialize(
        ctx, lambda snapshot: snapshots.serialize_snapshot(snapshot, ctx.user))
Beispiel #5
0
def get_snapshots(ctx, _params=None):
    auth.verify_privilege(ctx.user, 'snapshots:list')
    return _search_executor.execute_and_serialize(
        ctx, lambda snapshot: snapshots.serialize_snapshot(snapshot, ctx.user))