def test_SingleNodeValidator_transform_region_no_list(): """Test that there is no transformation if there is a region""" testsrc = redbaron.RedBaron("1+1") validator = reddel_server.SingleNodeValidator() expected = (testsrc, (1, 1), (1, 3)) assert expected == validator.transform(testsrc, start=reddel_server.Position(1, 1), end=reddel_server.Position(1, 3))
def test_SingleNodeValidator_region_valid(): """Test that the validator does not raise when there is one node in the region""" testsrc = redbaron.RedBaron("1+1\n2+2") validator = reddel_server.SingleNodeValidator() validator(testsrc, start=reddel_server.Position(2, 1), end=reddel_server.Position(2, 3))
def test_SingleNodeValidator_transform_no_region_no_list(): """Test that there is no transformation if there is no list""" testsrc = redbaron.RedBaron("1+1")[0] validator = reddel_server.SingleNodeValidator() assert (testsrc, None, None) == validator.transform(testsrc, start=None, end=None)
def test_SingleNodeValidator_region_invalid(): """Test that the validator raises when there is more than one node in the region""" testsrc = redbaron.RedBaron("1+1\n2+2") validator = reddel_server.SingleNodeValidator() with pytest.raises(reddel_server.ValidationException): validator(testsrc, start=reddel_server.Position(1, 1), end=reddel_server.Position(2, 3))
def test_SingleNodeValidator_no_region_single_node_valid(): """Test that the validator does not raise when there is one node and no region""" testsrc = redbaron.RedBaron("for i in range(10):\n\ta=1\n\tb=2")[0] validator = reddel_server.SingleNodeValidator() validator(testsrc)
def test_SingleNodeValidator_no_region_valid(): """Test that the validator does not raise when there is one node and no region""" testsrc = redbaron.RedBaron("1+1") validator = reddel_server.SingleNodeValidator() validator(testsrc)
def test_SingleNodeValidator_no_region_invalid(): """Test that the validator raises when there is more than one node and no region""" testsrc = redbaron.RedBaron("1+1\n2+2") validator = reddel_server.SingleNodeValidator() with pytest.raises(reddel_server.ValidationException): validator(testsrc)
def test_SingleNodeValidator_transform_no_region_list(): """Test the transformation when there is no region""" testsrc = redbaron.RedBaron("1+1") validator = reddel_server.SingleNodeValidator() expected = "1+1" assert expected == validator.transform(testsrc)[0].dumps()