def test_if_parse_get_namespace_based_on_provided_separator_with_multiple_chars( self): parser = NamespaceIdParser(separator='__') ret = parser.parse('namespace__key') assert ret.namespace == 'namespace' assert ret.id == 'key'
def test_if_parse_raises_error_when_more_then_one_ocurance_of_separator( self): parser = NamespaceIdParser(separator=';') with pytest.raises(FormatError): parser.parse('to;many;separators')
def test_if_parse_get_key_when_simple_id_provided(self): parser = NamespaceIdParser(separator=';') ret = parser.parse('key') assert ret.namespace is None assert ret.id == 'key'
def test_if_parse_throws_type_error_when_id_not_string(self): parser = NamespaceIdParser() with pytest.raises(TypeError): parser.parse(1)
def test_if_parse_get_namespace_based_on_provided_separator(self): parser = NamespaceIdParser(separator=';') ret = parser.parse('namespace;key') assert ret.namespace == 'namespace' assert ret.id == 'key'
def test_if_parse_raises_error_when_more_then_one_ocurance_of_separator(self): parser = NamespaceIdParser(separator=';') with pytest.raises(FormatError): parser.parse('to;many;separators')
def test_parse_namespace_from_id(self): parser = NamespaceIdParser(separator=':') ret = parser.parse('namespace:key') assert ret.namespace == 'namespace' assert ret.id == 'key'
def test_if_parse_get_namespace_based_on_provided_separator_with_multiple_chars(self): parser = NamespaceIdParser(separator='__') ret = parser.parse('namespace__key') assert ret.namespace == 'namespace' assert ret.id == 'key'