Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • workers/base-worker
1 result
Show changes
Commits on Source (5)
......@@ -45,6 +45,3 @@ repos:
- repo: meta
hooks:
- id: check-useless-excludes
default_language_version:
python: python3.7
......@@ -36,6 +36,9 @@ class MagicDict(dict):
"{} object has no attribute '{}'".format(self.__class__.__name__, name)
)
def __setattr__(self, name, value):
return super().__setitem__(name, value)
def __delattr__(self, name):
try:
return super().__delattr__(name)
......
# -*- coding: utf-8 -*-
import uuid
from peewee import IntegrityError
......@@ -20,6 +21,9 @@ class ElementMixin(object):
Check that a corpus has a list of required element types,
and raise an exception if any of them are missing.
"""
assert isinstance(
corpus_id, (uuid.UUID, str)
), "Corpus ID should be a string or UUID"
assert len(type_slugs), "At least one element type slug is required."
assert all(
isinstance(slug, str) for slug in type_slugs
......
......@@ -12,6 +12,7 @@ class MetaType(Enum):
Location = "location"
# Element's original structure reference (intended to be indexed)
Reference = "reference"
Numeric = "numeric"
class MetaDataMixin(object):
......
......@@ -320,3 +320,9 @@ def test_open_image_resize_use_full_image_false(mocker):
assert open_mock.call_args == mocker.call(
"http://zoneurl/0,0,400,600/133,200/0/default.jpg"
)
def test_setattr_setitem():
element = Element({"name": "something"})
element.type = "page"
assert dict(element) == {"name": "something", "type": "page"}
......@@ -46,4 +46,4 @@ repos:
- id: check-useless-excludes
default_language_version:
python: python3.7
python: python3.9