Skip to content

Commit 6998e09

Browse files
committed
test: add empty context test
1 parent 3426a49 commit 6998e09

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

xblock/test/test_field_data.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ def setup_method(self):
4040
Scope.content: self.content,
4141
Scope.settings: self.settings
4242
})
43+
self.split_empty = SplitFieldData({
44+
Scope.content: self.content,
45+
Scope.settings: self.settings,
46+
Scope.user_state: None,
47+
})
4348
self.runtime = TestRuntime(services={'field-data': self.split})
4449
self.block = TestingBlock(
4550
runtime=self.runtime,
@@ -76,6 +81,18 @@ def test_invalid_scope(self):
7681
with pytest.raises(InvalidScopeError):
7782
self.split.get(self.block, 'user_state')
7883

84+
def test_empty_scope(self):
85+
with pytest.raises(InvalidScopeError):
86+
self.split_empty.get(self.block, 'user_state')
87+
88+
def test_empty_scope_set_many(self):
89+
self.split_empty.set_many(
90+
self.block,
91+
{'content': 'new content', 'settings': 'new settings', 'user_state': 'new user state'},
92+
)
93+
self.content.set_many.assert_called_once_with(self.block, {'content': 'new content'})
94+
self.settings.set_many.assert_called_once_with(self.block, {'settings': 'new settings'})
95+
7996
def test_default(self):
8097
self.split.default(self.block, 'content')
8198
self.content.default.assert_called_once_with(self.block, 'content')

0 commit comments

Comments
 (0)