예제 #1
0
    def test_save_calls_runtime_save_block(self):
        """
        Make sure that when block.save() is called, ScopedStorageMixin will let
        the runtime know that the entire block should be saved.
        """
        class SaveTestBlock(XBlock):
            """ Block for this test """
            field_a = Integer(scope=Scope.settings)

        runtime = TestRuntime(services={'field-data': DictFieldData({})})
        runtime.save_block = mock.Mock()
        block = SaveTestBlock(runtime, scope_ids=mock.Mock(spec=ScopeIds))
        block.field_a = 15
        runtime.save_block.assert_not_called()
        block.save()
        runtime.save_block.assert_called_once_with(block)