Exemple #1
0
    def test_getlist_sorting(self):
        """getlist should also accept sorting parameters


        """
        taglist = TagManager.get_list(order_by=Tag.name, order=model.ORDER_DESC)
        self.assertEquals(taglist[0].name, 'python')

        taglist = TagManager.get_list(order_by=Tag.name)
        self.assertEquals(taglist[0].name, 'php')

        taglist = TagManager.get_list(order_by=Tag.id)
        self.assertEquals(taglist[0].id, 1)
Exemple #2
0
    def test_getlist(self):
        """The getlist should return a list of tags 
        
        and abide by the limit option
        
        """

        log.debug(meta.metadata.tables)
        taglist = TagManager.get_list()

        self.assertEquals(len(taglist), 3)

        taglist2 = TagManager.get_list(limit=2)
        self.assertEquals(len(taglist2), 2)
Exemple #3
0
    def test_getlist_byname(self):
        """Test that given a list of names we can get a list of objects back"""
        taglist = TagManager.get_list(tag_names=['pylons', 'php'])
        self.assertEquals(len(taglist), 2)

        for t in taglist:
            self.assertTrue(t.name in ['pylons', 'php'])
Exemple #4
0
    def test_new_tag_saved(self):
        """Verify that if we parse tags with a tag not in the system it's stored

        """
        tag_string = "python bookie soccer"

        tag_list = TagManager.parse(tag_string)
        meta.Session.commit()

        for tag in tag_list:
            self.assertTrue(isinstance(tag, Tag))

        # and we should now have the base three tags in the system + the two new
        # ones
        count = meta.Session.execute("SELECT COUNT(id) as ct FROM TAGS").fetchall()
        print count
        self.assertEqual(5, count[0][0])
Exemple #5
0
    def posts_add(self):
        """ Delicious API for posts/add

        :param url: (required) the url of the item.
        :param description: (required) the description of the item.
        :param extended: (optional) notes for the item.
        :param tags:  (optional) tags for the item (space delimited).
        :param dt: CCYY-MM-DDThh:mm:ssZ (optional) datestamp of the item
        :param replace: (optional) don't replace post if given url has already been posted.
        :param shared: no (optional) make the item private

        """

        log.debug(request.params)
        bmark = Bookmark(request.params['url'])
        tag_list = TagManager.parse(request.params['tags'], store=True)

        bmark.tags = tag_list
        meta.Session.add(bmark)
        meta.Session.commit()

        return '<result code="done" />'
Exemple #6
0
    def posts_add(self):
        """ Delicious API for posts/add

        :param url: (required) the url of the item.
        :param description: (required) the description of the item.
        :param extended: (optional) notes for the item.
        :param tags:  (optional) tags for the item (space delimited).
        :param dt: CCYY-MM-DDThh:mm:ssZ (optional) datestamp of the item
        :param replace: (optional) don't replace post if given url has already been posted.
        :param shared: no (optional) make the item private

        """

        log.debug(request.params)
        bmark = Bookmark(request.params['url'])
        tag_list = TagManager.parse(request.params['tags'], store=True)

        bmark.tags = tag_list
        meta.Session.add(bmark)
        meta.Session.commit()

        return '<result code="done" />'