-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store YBlob as bytes, not base64-encoded string (#209)
* Store YBlob as bytes, not base64-encoded string * Add test * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Automatic application of license header --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
947c46e
commit fc99cca
Showing
4 changed files
with
34 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,3 +147,5 @@ jupyter_ydoc/_version.py | |
!.yarn/versions | ||
docs/source/api | ||
docs/source/changelog.md | ||
# pixi environments | ||
.pixi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright (c) Jupyter Development Team. | ||
# Distributed under the terms of the Modified BSD License. | ||
|
||
from jupyter_ydoc import YBlob | ||
|
||
|
||
def test_yblob(): | ||
yblob = YBlob() | ||
assert yblob.get() == b"" | ||
yblob.set(b"012") | ||
assert yblob.get() == b"012" | ||
changes = [] | ||
|
||
def callback(topic, event): | ||
print(topic, event) | ||
changes.append((topic, event)) | ||
|
||
yblob.observe(callback) | ||
yblob.set(b"345") | ||
assert len(changes) == 1 | ||
topic, event = changes[0] | ||
assert topic == "source" | ||
assert event.keys["bytes"]["oldValue"] == b"012" | ||
assert event.keys["bytes"]["newValue"] == b"345" |