Changeset View
Changeset View
Standalone View
Standalone View
swh/graphql/tests/unit/resolvers/test_scalars.py
# Copyright (C) 2022 The Software Heritage developers | # Copyright (C) 2022 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU General Public License version 3, or any later version | # License: GNU General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import datetime | import datetime | ||||
import pytest | import pytest | ||||
from swh.graphql.errors import InvalidInputError | from swh.graphql.errors import InvalidInputError | ||||
from swh.graphql.resolvers import scalars | from swh.graphql.resolvers import scalars | ||||
def test_serialize_id(): | def test_serialize_id(): | ||||
assert scalars.serialize_id("test") == "74657374" | assert scalars.serialize_id("test") == "test" | ||||
assert scalars.serialize_id(b"test") == "74657374" | assert scalars.serialize_id(b"test") == "74657374" | ||||
def test_validate_swhid_invalid(): | def test_validate_swhid_invalid(): | ||||
with pytest.raises(InvalidInputError): | with pytest.raises(InvalidInputError): | ||||
scalars.validate_swhid("invalid") | scalars.validate_swhid("invalid") | ||||
Show All 12 Lines |