Ejemplo n.º 1
0
    def get(self, endpoint, **kwargs):
        # Remove nullable values from the kwargs, and slugify the values.
        kwargs = dict((k, utils.slugify(v)) for k, v in kwargs.items() if v)

        try:
            pattern = self.endpoints[endpoint]
            return pattern.format(root=self._root, **kwargs)
        except KeyError as e:
            msg = "Cannot get {endpoint} endpoint, {field} is missing"
            raise KintoException(
                msg.format(endpoint=endpoint, field=','.join(e.args)))
Ejemplo n.º 2
0
    def get(self, endpoint, **kwargs):
        # Remove nullable values from the kwargs, and slugify the values.
        kwargs = dict((k, utils.slugify(v))
                      for k, v in iteritems(kwargs) if v)

        try:
            pattern = self.endpoints[endpoint]
            return pattern.format(root=self._root, **kwargs)
        except KeyError as e:
            msg = "Cannot get {endpoint} endpoint, {field} is missing"
            raise KintoException(msg.format(endpoint=endpoint,
                                 field=','.join(e.args)))
Ejemplo n.º 3
0
 def test_slugify_replaces_spaces_by_hyphens(self):
     assert utils.slugify(u"text with spaces") == "text-with-spaces"
Ejemplo n.º 4
0
 def test_slugify_do_no_modify_valid_ids(self):
     for value in ["en-US", "en_GB"]:
         assert utils.slugify(value) == value
Ejemplo n.º 5
0
 def test_slugify_converts_integers(self):
     assert utils.slugify(1) == "1"
Ejemplo n.º 6
0
 def test_slugify_removes_unknown_characters(self):
     assert utils.slugify(u"chars!") == "chars"
Ejemplo n.º 7
0
 def test_slugify_replaces_equivalent_chars(self):
     assert utils.slugify(u"chârs") == "chars"
Ejemplo n.º 8
0
 def test_slugify_removes_unknown_characters(self):
     assert utils.slugify(u'chars!') == 'chars'
Ejemplo n.º 9
0
 def test_slugify_do_no_modify_valid_ids(self):
     for value in ['en-US', 'en_GB']:
         assert utils.slugify(value) == value
Ejemplo n.º 10
0
 def test_slugify_converts_integers(self):
     assert utils.slugify(1) == '1'
Ejemplo n.º 11
0
 def test_slugify_do_no_modify_valid_ids(self):
     for value in ['en-US', 'en_GB']:
         assert utils.slugify(value) == value
Ejemplo n.º 12
0
 def test_slugify_replaces_equivalent_chars(self):
     assert utils.slugify(u'chârs') == 'chars'
Ejemplo n.º 13
0
 def test_slugify_removes_unknown_characters(self):
     assert utils.slugify(u'chars!') == 'chars'
Ejemplo n.º 14
0
 def test_slugify_replaces_spaces_by_hyphens(self):
     assert utils.slugify(u'text with spaces') == 'text-with-spaces'