Skip to content

Commit

Permalink
☔ Add unit tests for sockets from ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
FabienRoger committed Jan 9, 2022
1 parent 993430d commit f85de67
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tests/unit/scene/test_ipynb_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"""Unit tests for the conversion from and to ipynb."""

from typing import OrderedDict
from typing import List, OrderedDict
from pytest_mock import MockerFixture
import pytest_check as check
import json
Expand Down Expand Up @@ -71,7 +71,7 @@ def check_conversion_coherence(ipynb_data: OrderedDict, ipyg_data: OrderedDict):
2. the right amount of code blocks and edges
3. blocks and sockets with unique ids
4. edges with existing ids
5. code blocks that always have a source
5. code blocks that always have a source and two sockets
6. markdown blocks that always have text
"""

Expand Down Expand Up @@ -109,10 +109,17 @@ def check_conversion_coherence(ipynb_data: OrderedDict, ipyg_data: OrderedDict):
check.equal(edge["source"]["socket"] in socket_id_set, True)
check.equal(edge["destination"]["socket"] in socket_id_set, True)

# code blocks always have a source and markdown blocks always have a text
# code blocks always have a source and two sockets
# markdown blocks always have a text
for block in ipyg_data["blocks"]:
if block["block_type"] == BLOCK_TYPE_TO_NAME["code"]:
check.equal("source" in block and type(block["source"]) == str, True)
check.equal("source" in block, True)
check.equal(type(block["source"]), str)

check.equal("sockets" in block, True)
check.equal(type(block["sockets"]), list)
check.equal(len(block["sockets"]), 2)

if block["block_type"] == BLOCK_TYPE_TO_NAME["markdown"]:
check.equal("text" in block and type(block["text"]) == str, True)

Expand Down

0 comments on commit f85de67

Please sign in to comment.