示例#1
0
    def test_user_docs_activity(self, fetch_user_feed):
        if not settings.DEKIWIKI_ENDPOINT:
            # Skip this, if MindTouch API not available.
            raise SkipTest()

        fetch_user_feed.return_value = (open(USER_DOCS_ACTIVITY_FEED_XML,
                                             'r').read())
        feed = UserDocsActivityFeed(username="******")
        items = feed.items

        eq_(100, len(items))

        for item in items:

            ok_(hasattr(item, 'rc_id'))
            ok_(hasattr(item, 'rc_comment'))
            ok_(hasattr(item, 'rc_title'))
            ok_(hasattr(item, 'rc_timestamp'))

            ok_(isinstance(item.rc_timestamp, datetime))
            ok_(type(item.rc_revision) is int)

            if 'EDIT' == item.rc_type:
                ok_(item.edit_url is not None)
            if 'NEW' == item.rc_type:
                ok_(item.history_url is None)
                ok_(item.diff_url is None)
            if 'MOVE' == item.rc_type:
                eq_(item.rc_moved_to_title, item.current_title)
示例#2
0
    def test_bug715923_feed_parsing_errors(self, fetch_user_feed):
        fetch_user_feed.return_value = """
            THIS IS NOT EVEN XML, SO BROKEN
        """
        if not settings.DEKIWIKI_ENDPOINT:
            # Skip this, if MindTouch API not available.
            raise SkipTest()

        try:
            feed = UserDocsActivityFeed(username="******")
            items = feed.items
            eq_(False, items, "On error, items should be False")
        except Exception, e:
            ok_(False, "There should be no exception %s" % e)
示例#3
0
    def test_profile_view(self):
        """A user profile can be viewed"""
        profile = UserProfile.objects.get(user__username='******')
        user = profile.user
        url = reverse('devmo.views.profile_view', args=(user.username, ))
        r = self.client.get(url, follow=True)
        doc = pq(r.content)

        eq_(profile.user.username,
            doc.find('#profile-head.vcard .nickname').text())
        eq_(profile.fullname, doc.find('#profile-head.vcard .fn').text())
        eq_(profile.title, doc.find('#profile-head.vcard .title').text())
        eq_(profile.organization, doc.find('#profile-head.vcard .org').text())
        eq_(profile.location, doc.find('#profile-head.vcard .loc').text())
        eq_('IRC: ' + profile.irc_nickname,
            doc.find('#profile-head.vcard .irc').text())
        eq_(profile.bio, doc.find('#profile-head.vcard .bio').text())

        if not settings.DEKIWIKI_ENDPOINT:
            # The rest of this test relies on MindTouch API data.
            # TODO: Properly rewrite to use Kuma data
            return

        # There should be 15 doc activity items in the page.
        feed_trs = doc.find('#docs-activity table.activity tbody tr')
        eq_(15, feed_trs.length)

        # Check to find all the items expected from the feed
        feed = UserDocsActivityFeed(username="******")
        for idx in range(0, 15):
            item = feed.items[idx]
            item_el = feed_trs.eq(idx)
            eq_(item.current_title, item_el.find('h3').text())
            eq_(item.view_url, item_el.find('h3 a').attr('href'))
            if item.edit_url:
                eq_(item.edit_url,
                    item_el.find('.actions a.edit').attr('href'))
            if item.diff_url:
                eq_(item.diff_url,
                    item_el.find('.actions a.diff').attr('href'))
            if item.history_url:
                eq_(item.history_url,
                    item_el.find('.actions a.history').attr('href'))
示例#4
0
 def test_user_docs_activity_url(self):
     """Can build the API URL for a user docs activity feed"""
     username = "******"
     url = UserDocsActivityFeed(username=username).feed_url_for_user()
     ok_(url.endswith('/@api/deki/users/=%s/feed?format=raw' % username))
示例#5
0
 def test_activity_url_bug689203(self):
     try:
         username = u"She\xeappy"
         UserDocsActivityFeed(username=username).feed_url_for_user()
     except KeyError:
         ok_(False, "No KeyError should be thrown")
示例#6
0
 def test_user_docs_activity_url(self):
     """Can build the API URL for a user docs activity feed"""
     username = "******"
     url = UserDocsActivityFeed(username=username).feed_url_for_user()
     ok_(url.endswith('/@api/deki/users/=%s/feed?format=raw' % username))