class TestSplitFieldData: """ Tests of :ref:`SplitFieldData`. """ # pylint: disable=attribute-defined-outside-init def setup_method(self): """ Setup for each test case in this class. """ self.content = Mock() self.settings = Mock() self.split = SplitFieldData({ Scope.content: self.content, Scope.settings: self.settings }) self.runtime = TestRuntime(services={'field-data': self.split}) self.block = TestingBlock( runtime=self.runtime, scope_ids=Mock(), ) # pylint: enable=attribute-defined-outside-init def test_get(self): self.split.get(self.block, 'content') self.content.get.assert_called_once_with(self.block, 'content') assert not self.settings.get.called def test_set(self): self.split.set(self.block, 'content', 'foo') self.content.set.assert_called_once_with(self.block, 'content', 'foo') assert not self.settings.set.called def test_delete(self): self.split.delete(self.block, 'content') self.content.delete.assert_called_once_with(self.block, 'content') assert not self.settings.delete.called def test_has(self): self.split.has(self.block, 'content') self.content.has.assert_called_once_with(self.block, 'content') assert not self.settings.has.called def test_set_many(self): self.split.set_many(self.block, {'content': 'new content', 'settings': 'new settings'}) self.content.set_many.assert_called_once_with(self.block, {'content': 'new content'}) self.settings.set_many.assert_called_once_with(self.block, {'settings': 'new settings'}) def test_invalid_scope(self): with pytest.raises(InvalidScopeError): self.split.get(self.block, 'user_state') def test_default(self): self.split.default(self.block, 'content') self.content.default.assert_called_once_with(self.block, 'content') assert not self.settings.default.called
class TestSplitFieldData(object): """ Tests of :ref:`SplitFieldData`. """ def setUp(self): self.content = Mock() self.settings = Mock() self.split = SplitFieldData({ Scope.content: self.content, Scope.settings: self.settings }) self.block = TestingBlock( runtime=Mock(), field_data=self.split, scope_ids=Mock(), ) def test_get(self): self.split.get(self.block, 'content') self.content.get.assert_called_once_with(self.block, 'content') assert_false(self.settings.get.called) def test_set(self): self.split.set(self.block, 'content', 'foo') self.content.set.assert_called_once_with(self.block, 'content', 'foo') assert_false(self.settings.set.called) def test_delete(self): self.split.delete(self.block, 'content') self.content.delete.assert_called_once_with(self.block, 'content') assert_false(self.settings.delete.called) def test_has(self): self.split.has(self.block, 'content') self.content.has.assert_called_once_with(self.block, 'content') assert_false(self.settings.has.called) def test_set_many(self): self.split.set_many(self.block, { 'content': 'new content', 'settings': 'new settings' }) self.content.set_many.assert_called_once_with( self.block, {'content': 'new content'}) self.settings.set_many.assert_called_once_with( self.block, {'settings': 'new settings'}) def test_invalid_scope(self): with assert_raises(InvalidScopeError): self.split.get(self.block, 'user_state') def test_default(self): self.split.default(self.block, 'content') self.content.default.assert_called_once_with(self.block, 'content') assert_false(self.settings.default.called)
class TestSplitFieldData(object): """ Tests of :ref:`SplitFieldData`. """ # pylint: disable=attribute-defined-outside-init def setup_method(self): """ Setup for each test case in this class. """ self.content = Mock() self.settings = Mock() self.split = SplitFieldData({ Scope.content: self.content, Scope.settings: self.settings }) self.runtime = TestRuntime(services={'field-data': self.split}) self.block = TestingBlock( runtime=self.runtime, scope_ids=Mock(), ) # pylint: enable=attribute-defined-outside-init def test_get(self): self.split.get(self.block, 'content') self.content.get.assert_called_once_with(self.block, 'content') assert not self.settings.get.called def test_set(self): self.split.set(self.block, 'content', 'foo') self.content.set.assert_called_once_with(self.block, 'content', 'foo') assert not self.settings.set.called def test_delete(self): self.split.delete(self.block, 'content') self.content.delete.assert_called_once_with(self.block, 'content') assert not self.settings.delete.called def test_has(self): self.split.has(self.block, 'content') self.content.has.assert_called_once_with(self.block, 'content') assert not self.settings.has.called def test_set_many(self): self.split.set_many(self.block, {'content': 'new content', 'settings': 'new settings'}) self.content.set_many.assert_called_once_with(self.block, {'content': 'new content'}) self.settings.set_many.assert_called_once_with(self.block, {'settings': 'new settings'}) def test_invalid_scope(self): with pytest.raises(InvalidScopeError): self.split.get(self.block, 'user_state') def test_default(self): self.split.default(self.block, 'content') self.content.default.assert_called_once_with(self.block, 'content') assert not self.settings.default.called
class TestSplitFieldData(object): """ Tests of :ref:`SplitFieldData`. """ def setUp(self): self.content = Mock() self.settings = Mock() self.split = SplitFieldData({ Scope.content: self.content, Scope.settings: self.settings }) self.block = TestingBlock( runtime=Mock(), field_data=self.split, scope_ids=Mock(), ) def test_get(self): self.split.get(self.block, 'content') self.content.get.assert_called_once_with(self.block, 'content') assert_false(self.settings.get.called) def test_set(self): self.split.set(self.block, 'content', 'foo') self.content.set.assert_called_once_with(self.block, 'content', 'foo') assert_false(self.settings.set.called) def test_delete(self): self.split.delete(self.block, 'content') self.content.delete.assert_called_once_with(self.block, 'content') assert_false(self.settings.delete.called) def test_has(self): self.split.has(self.block, 'content') self.content.has.assert_called_once_with(self.block, 'content') assert_false(self.settings.has.called) def test_set_many(self): self.split.set_many(self.block, {'content': 'new content', 'settings': 'new settings'}) self.content.set_many.assert_called_once_with(self.block, {'content': 'new content'}) self.settings.set_many.assert_called_once_with(self.block, {'settings': 'new settings'}) def test_invalid_scope(self): with assert_raises(InvalidScopeError): self.split.get(self.block, 'user_state') def test_default(self): self.split.default(self.block, 'content') self.content.default.assert_called_once_with(self.block, 'content') assert_false(self.settings.default.called)