diff --git a/core/src/zeit/connector/models.py b/core/src/zeit/connector/models.py index ec906f7fbf..ade1844e3b 100644 --- a/core/src/zeit/connector/models.py +++ b/core/src/zeit/connector/models.py @@ -90,12 +90,6 @@ class DevelopmentCommonMetadata: access = mapped_column(Unicode, index=True, info={'namespace': 'document', 'name': 'access'}) -class DevelopmentZeitWeb: - overscrolling_enabled = mapped_column( - Boolean, info={'namespace': 'document', 'name': 'overscrolling'} - ) - - class ContentBase: __abstract__ = True __tablename__ = 'properties' @@ -229,6 +223,8 @@ def from_webdav(self, props): continue if ns == INTERNAL_PROPERTY: continue + if isinstance(v, datetime): + continue unsorted[ns.replace(self.NS, '', 1)][k] = v self.unsorted = unsorted @@ -299,7 +295,6 @@ class DevelopmentContent( PublishInfo, SemanticChange, DevelopmentCommonMetadata, - DevelopmentZeitWeb, ): lock_class = 'LockWithMetadataColumns' diff --git a/core/src/zeit/connector/tests/test_contract.py b/core/src/zeit/connector/tests/test_contract.py index fb6467ea84..1a8e2a1954 100644 --- a/core/src/zeit/connector/tests/test_contract.py +++ b/core/src/zeit/connector/tests/test_contract.py @@ -889,23 +889,29 @@ class ContractZopeSQL( class ContractProperties: def setUp(self): super().setUp() - FEATURE_TOGGLES.set('read_metadata_columns', 'True') - FEATURE_TOGGLES.set('write_metadata_columns', 'True') + FEATURE_TOGGLES.set('read_metadata_columns', True) + FEATURE_TOGGLES.set('write_metadata_columns', True) self.repository['testcontent'] = ExampleContentType() def test_converts_scalar_types_on_read(self): + example_date = datetime(2010, 1, 1, 0, 0, tzinfo=pytz.UTC) self.repository.connector.changeProperties( 'http://xml.zeit.de/testcontent', - {('overscrolling', 'http://namespaces.zeit.de/CMS/document'): True}, + {('date_created', 'http://namespaces.zeit.de/CMS/document'): example_date}, + ) + self.assertEqual( + example_date, + zeit.cms.workflow.interfaces.IModified(self.repository['testcontent']).date_created, ) - self.assertIs(True, self.repository['testcontent'].overscrolling) def test_converts_scalar_types_on_write(self): + example_date = datetime(2010, 1, 1, 0, 0, tzinfo=pytz.UTC) with checked_out(self.repository['testcontent']) as co: - co.overscrolling = True + zeit.cms.workflow.interfaces.IModified(co).date_created = example_date resource = self.repository.connector['http://xml.zeit.de/testcontent'] - self.assertIs( - True, resource.properties[('overscrolling', 'http://namespaces.zeit.de/CMS/document')] + self.assertEqual( + example_date, + resource.properties[('date_created', 'http://namespaces.zeit.de/CMS/document')], ) diff --git a/core/src/zeit/connector/tests/test_postgresql.py b/core/src/zeit/connector/tests/test_postgresql.py index 7d305be418..a7bf35dfa1 100644 --- a/core/src/zeit/connector/tests/test_postgresql.py +++ b/core/src/zeit/connector/tests/test_postgresql.py @@ -356,100 +356,6 @@ def test_search_looks_in_columns_or_unsorted_depending_on_toggle(self): self.assertEqual(res.id, unique_id) -class ChannelsColumnTest(zeit.connector.testing.SQLTest): - layer = zeit.connector.testing.SQL_CONTENT_LAYER - - def setUp(self): - super().setUp() - FEATURE_TOGGLES.set('read_metadata_columns', True) - FEATURE_TOGGLES.set('write_metadata_columns', True) - - def _make_resource(self, channels): - res = self.add_resource('foo', properties={('channels', DOCUMENT_SCHEMA_NS): channels}) - return self.connector._get_content(res.id) - - def assert_channels(self, channels, expected_channels, expected_dav_channels): - self.assertEqual(channels, expected_channels) - res = self.connector['http://xml.zeit.de/testing/foo'] - self.assertEqual(expected_dav_channels, res.properties[('channels', DOCUMENT_SCHEMA_NS)]) - - def test_modify_channels(self): - content = self._make_resource('channel1;channel2 sub1 sub2') - self.assertEqual(content.channels, {'channel1': [], 'channel2': ['sub1', 'sub2']}) - self.connector.changeProperties( - content.uniqueid, {('channels', DOCUMENT_SCHEMA_NS): 'channel2'} - ) - content = self.connector._get_content(content.uniqueid) - self.assertEqual(content.channels, {'channel2': []}) - - def test_empty_input(self): - channels = '' - content = self._make_resource(channels) - self.assert_channels(content.channels, {}, channels) - - def test_single_channel(self): - channels = 'channel1' - content = self._make_resource(channels) - self.assert_channels(content.channels, {'channel1': []}, channels) - - def test_multiple_channels(self): - channels = 'channel1;channel2;channel3' - content = self._make_resource(channels) - self.assert_channels( - content.channels, {'channel1': [], 'channel2': [], 'channel3': []}, channels - ) - - def test_single_channel_with_subchannels(self): - channels = 'channel1 sub1 sub2' - content = self._make_resource(channels) - self.assert_channels(content.channels, {'channel1': ['sub1', 'sub2']}, channels) - - def test_same_channel_with_subchannels(self): - channels = 'channel1 sub1;channel1 sub2 sub3;channel1 sub4' - content = self._make_resource(channels) - self.assert_channels( - content.channels, - {'channel1': ['sub1', 'sub2', 'sub3', 'sub4']}, - 'channel1 sub1 sub2 sub3 sub4', - ) - - def test_multiple_channels_with_subchannels(self): - channels = 'channel1 sub1;channel2 sub2 sub3;channel3 sub4' - content = self._make_resource(channels) - self.assert_channels( - content.channels, - {'channel1': ['sub1'], 'channel2': ['sub2', 'sub3'], 'channel3': ['sub4']}, - channels, - ) - - def test_whitespace_handling(self): - channels = ' channel1 sub1 ; channel2 sub2 sub3 ; channel3 sub4 ' - content = self._make_resource(channels) - self.assert_channels( - content.channels, - {'channel1': ['sub1'], 'channel2': ['sub2', 'sub3'], 'channel3': ['sub4']}, - 'channel1 sub1;channel2 sub2 sub3;channel3 sub4', - ) - - def test_trailing_semicolon(self): - channels = 'channel1;channel2;' - content = self._make_resource(channels) - self.assert_channels(content.channels, {'channel1': [], 'channel2': []}, channels[:-1]) - - def test_leading_semicolon(self): - channels = ';channel1;channel2' - content = self._make_resource(channels) - self.assert_channels(content.channels, {'channel1': [], 'channel2': []}, channels[1:]) - - def test_multiple_semicolons(self): - content = self._make_resource('channel1;;channel2;;;channel3') - self.assert_channels( - content.channels, - {'channel1': [], 'channel2': [], 'channel3': []}, - 'channel1;channel2;channel3', - ) - - class WorkflowColumnsTest(zeit.connector.testing.SQLTest): layer = zeit.connector.testing.SQL_CONTENT_LAYER