示例#1
0
    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'
示例#2
0
 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')
示例#3
0
    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'
示例#4
0
 def test_if_parse_throws_type_error_when_id_not_string(self):
     parser = NamespaceIdParser()
     with pytest.raises(TypeError):
         parser.parse(1)
示例#5
0
    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'
示例#6
0
 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')
示例#7
0
    def test_parse_namespace_from_id(self):
        parser = NamespaceIdParser(separator=':')
        ret = parser.parse('namespace:key')

        assert ret.namespace == 'namespace'
        assert ret.id == 'key'
示例#8
0
    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'
示例#9
0
    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'
示例#10
0
    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'
示例#11
0
 def test_if_parse_throws_type_error_when_id_not_string(self):
     parser = NamespaceIdParser()
     with pytest.raises(TypeError):
         parser.parse(1)
示例#12
0
    def test_parse_namespace_from_id(self):
        parser = NamespaceIdParser(separator=':')
        ret = parser.parse('namespace:key')

        assert ret.namespace == 'namespace'
        assert ret.id == 'key'