Example #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'
Example #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')
Example #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'
Example #4
0
 def test_if_parse_throws_type_error_when_id_not_string(self):
     parser = NamespaceIdParser()
     with pytest.raises(TypeError):
         parser.parse(1)
Example #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'
Example #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')
Example #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'
Example #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'
Example #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'
Example #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'
Example #11
0
 def test_if_parse_throws_type_error_when_id_not_string(self):
     parser = NamespaceIdParser()
     with pytest.raises(TypeError):
         parser.parse(1)
Example #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'