Rename ImagePermissions to ImageContentPermissions

Since we're going to need to distinguish this from API permissions.
This commit is contained in:
Peter Williams 2023-06-02 16:18:08 -04:00
Родитель 80276c9ad9
Коммит 6e8c1aa6a1
4 изменённых файлов: 20 добавлений и 21 удалений

Просмотреть файл

@ -1,20 +1,20 @@
ImagePermissions
================
ImageContentPermissions
=======================
.. currentmodule:: wwt_api_client.constellations.data
.. autoclass:: ImagePermissions
.. autoclass:: ImageContentPermissions
:show-inheritance:
.. rubric:: Methods Summary
.. autosummary::
~ImagePermissions.from_dict
~ImagePermissions.from_json
~ImagePermissions.schema
~ImagePermissions.to_dict
~ImagePermissions.to_json
~ImageContentPermissions.from_dict
~ImageContentPermissions.from_json
~ImageContentPermissions.schema
~ImageContentPermissions.to_dict
~ImageContentPermissions.to_json
.. rubric:: Methods Documentation

Просмотреть файл

@ -20,9 +20,9 @@ HandlePermissions
HandleSceneStats
HandleStats
HandleUpdate
ImageContentPermissions
ImageInfo
ImageDisplayInfo
ImagePermissions
ImageStorage
ImageSummary
ImageUpdate
@ -157,7 +157,7 @@ class ImageSummary:
@dataclass_json
@dataclass
class ImagePermissions:
class ImageContentPermissions:
copyright: str
credits: Optional[str]
license: str
@ -190,7 +190,7 @@ class ImageInfo:
handle: HandleInfo
creation_date: str # format: 2023-03-28T16:53:18.364Z
wwt: ImageWwt
permissions: ImagePermissions
permissions: ImageContentPermissions
storage: ImageStorage
note: str
@ -199,7 +199,7 @@ class ImageInfo:
@dataclass
class ImageUpdate:
note: Optional[str]
permissions: Optional[ImagePermissions]
permissions: Optional[ImageContentPermissions]
@dataclass_json

Просмотреть файл

@ -24,7 +24,7 @@ from .data import (
HandleStats,
HandleUpdate,
ImageWwt,
ImagePermissions,
ImageContentPermissions,
ImageStorage,
ImageSummary,
SceneContent,
@ -50,7 +50,7 @@ D2R = math.pi / 180
@dataclass
class AddImageRequest:
wwt: ImageWwt
permissions: ImagePermissions
permissions: ImageContentPermissions
storage: ImageStorage
note: str
@ -351,7 +351,7 @@ class HandleClient:
legacy_url_template=imageset.url,
)
permissions = ImagePermissions(
permissions = ImageContentPermissions(
copyright=copyright,
credits=imageset.credits,
license=license_spdx_id,

Просмотреть файл

@ -1,7 +1,7 @@
from license_expression import ExpressionError
import pytest
from ..constellations.data import ImagePermissions
from ..constellations.data import ImageContentPermissions
@pytest.fixture
@ -9,12 +9,12 @@ def valid_permissions_data():
return {
"copyright": "Some copyright information",
"credits": "<strong>Image Credit:</strong> Someone",
"license": "BSD-2-Clause"
"license": "BSD-2-Clause",
}
def test_valid_image_permissions(valid_permissions_data):
permissions = ImagePermissions(**valid_permissions_data)
permissions = ImageContentPermissions(**valid_permissions_data)
assert permissions.copyright == valid_permissions_data["copyright"]
assert permissions.credits == valid_permissions_data["credits"]
@ -25,15 +25,14 @@ def test_invalid_permissions_license(valid_permissions_data):
with pytest.raises(ExpressionError):
permissions_data = valid_permissions_data.copy()
permissions_data["license"] = "NO SUCH LICENSE"
ImagePermissions(**permissions_data)
ImageContentPermissions(**permissions_data)
def test_sanitize_permissions_html(valid_permissions_data):
permissions_data = valid_permissions_data.copy()
permissions_data["credits"] = "<script>Some JS here</script><a>Credits Link</a>"
permissions = ImagePermissions(**permissions_data)
permissions = ImageContentPermissions(**permissions_data)
assert permissions.copyright == permissions_data["copyright"]
assert permissions.license == permissions_data["license"]
assert permissions.credits == "<a>Credits Link</a>"