def test_set_stack_group_fills_scale(default_kwargs): """Test that a stack group's scale is populated with a default when not explicitly given""" new_stack_group = 5 kwargs = dict(default_kwargs) del kwargs['stack_group_id'] catmaid_url = CatmaidUrl(**default_kwargs) catmaid_url.set_stack_group(new_stack_group) assert 'sg={}&sgs={}'.format(new_stack_group, SCALE) in str(catmaid_url)
def test_different_tool_ignores_active(default_kwargs): """Test that tool-specific arguments are ignored when using a different tool""" kwargs = dict(default_kwargs) kwargs['tool'] = 'not_tracingtool' url_str = str(CatmaidUrl(**kwargs)) assert 'active' not in url_str
def test_ignores_unfilled_coords(default_kwargs): """Test that if any of the 3 coords are missing, all are ignored, and a warning is raised""" kwargs = dict(default_kwargs) del kwargs['x'] with pytest.warns(UserWarning, match='ignoring'): url_str = str(CatmaidUrl(**kwargs)) for dim in 'xyz': assert dim + 'p' not in url_str
def test_from_catmaid(catmaid_mock, default_kwargs, default_url): """Test that a CatmaidUrl object instantiated from a CatmaidClient-like object is the same as using args""" kwargs = dict(default_kwargs) del kwargs['base_url'] del kwargs['project_id'] catmaid_url = CatmaidUrl.from_catmaid(catmaid_mock, **kwargs) assert str(catmaid_url) == str(default_url)
def test_instantiate(default_url): """Test that the object can be instantiated""" catmaid_url = CatmaidUrl(BASE_URL, PROJECT_ID, STACK_GROUP_ID, STACK_ID, SCALE, X, Y, Z, TOOL, ACTIVE_SKELETON_ID, ACTIVE_NODE_ID) assert str(catmaid_url) == str(default_url)
def default_url(default_kwargs): return CatmaidUrl(**default_kwargs)
def test_from_url(default_url): """Test that a CatmaidUrl object instantiated using from_str is the same as using the args""" from_str = CatmaidUrl.from_url(str(default_url)) assert str(default_url) == str(from_str)