Closed jaclark5 closed 6 months ago
How can I add unit tests for features in a Jupyter notebook?
Hi @jaclark5, good question, and I don't think we have a good way to explicitly tests those (the visualization). Currently, the py3dmol and nglview tests basically just try to make sure that we can create the visualization object without error. So in this case, I think you can just add a simple test case (maybe a box of CG beads or something that you have ready) and make sure there's no error pops up.
@pytest.mark.skipif(not has_py3Dmol, reason="Py3Dmol is not installed")
def test_visualize_py3dmol(self, ethane):
py3Dmol = import_("py3Dmol")
vis_object = ethane._visualize_py3dmol()
assert isinstance(vis_object, py3Dmol.view)
@pytest.mark.skipif(not has_nglview, reason="NGLView is not installed")
def test_visualize_nglview(self, ethane):
nglview = import_("nglview")
vis_object = ethane._visualize_nglview()
assert isinstance(
vis_object.component_0, nglview.component.ComponentViewer
)
And those tests are currently located in test_compound.py
All modified and coverable lines are covered by tests :white_check_mark:
Comparison is base (
c684f92
) 87.18% compared to head (1dcb209
) 87.18%.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
PR Summary:
Fixes #1157
Allow a user to adjust the bead size in Jupyter notebook visualization. This is especially useful for CG models where the default bead size may be too small.
PR Checklist