Exemplo n.º 1
0
    def test_google_reader_import(self):
        self.client.login(username='******', password='******')
        user = User.objects.get(username='******')
        f = open(
            os.path.join(os.path.dirname(__file__),
                         'fixtures/google_reader.xml'))
        xml = f.read()
        f.close()

        reader_importer = GoogleReaderImporter(user, xml=xml)
        reader_importer.import_feeds()

        subs = UserSubscription.objects.filter(user=user)
        self.assertEquals(subs.count(), 66)

        usf = UserSubscriptionFolders.objects.get(user=user)
        # print json.decode(usf.folders)
        self.assertEquals(json.decode(usf.folders), [{
            u'Tech': [
                4, 5, 2, 9, 10, 12, 13, 14, 20, 23, 24, 26, 27, 28, 31, 32, 33,
                34, 48, 49, 62, 64
            ]
        }, 1, 2, 3, 6, {
            u'Blogs':
            [1, 3, 25, 29, 30, 39, 40, 41, 50, 55, 57, 58, 59, 60, 66]
        }, {
            u'Blogs \u2014 Tumblrs': [5, 21, 37, 38, 53, 54, 63, 65]
        }, {
            u'Blogs \u2014 The Bloglets': [6, 16, 22, 35, 51, 56]
        }, {
            u'New York': [7, 8, 17, 18, 19, 36, 45, 47, 52, 61]
        }, {
            u'Cooking': [11, 15, 42, 43, 46]
        }, 44])
Exemplo n.º 2
0
    def test_google_reader_import(self):
        self.client.login(username="******", password="******")
        user = User.objects.get(username="******")
        f = open(os.path.join(os.path.dirname(__file__), "fixtures/google_reader.xml"))
        xml = f.read()
        f.close()

        reader_importer = GoogleReaderImporter(user, xml=xml)
        reader_importer.import_feeds()

        subs = UserSubscription.objects.filter(user=user)
        self.assertEquals(subs.count(), 66)

        usf = UserSubscriptionFolders.objects.get(user=user)
        print json.decode(usf.folders)
        self.assertEquals(
            json.decode(usf.folders),
            [
                {u"Tech": [4, 5, 2, 9, 10, 12, 13, 14, 20, 23, 24, 26, 27, 28, 31, 32, 33, 34, 48, 49, 62, 64]},
                1,
                2,
                3,
                6,
                {u"Blogs": [1, 3, 25, 29, 30, 39, 40, 41, 50, 55, 57, 58, 59, 60, 66]},
                {u"Blogs \u2014 Tumblrs": [5, 21, 37, 38, 53, 54, 63, 65]},
                {u"Blogs \u2014 The Bloglets": [6, 16, 22, 35, 51, 56]},
                {u"New York": [7, 8, 17, 18, 19, 36, 45, 47, 52, 61]},
                {u"Cooking": [11, 15, 42, 43, 46]},
                44,
            ],
        )
Exemplo n.º 3
0
    def run(self, user_id, auto_active=False):
        user = User.objects.get(pk=user_id)
        logging.user(user, "~FR~SBGoogle Reader import (task) starting...")

        importer = GoogleReaderImporter(user=user)
        importer.import_feeds(auto_active=auto_active)
        importer.import_starred_items(count=10)
        
        feed_count = UserSubscription.objects.filter(user=user).count()
        user.profile.send_import_reader_finished_email(feed_count)
        logging.user(user, "~FR~SBGoogle Reader import (task): ~SK%s~SN~SB~FR feeds" % (feed_count))
Exemplo n.º 4
0
def import_from_google_reader(request):
    code = 0

    if request.user.is_authenticated():
        reader_importer = GoogleReaderImporter(request.user)
        reader_importer.import_feeds()
        reader_importer.import_starred_items()
        code = 1
        if 'import_from_google_reader' in request.session:
            del request.session['import_from_google_reader']

    return dict(code=code)
Exemplo n.º 5
0
    def run(self, user_id, auto_active=False):
        user = User.objects.get(pk=user_id)
        logging.user(user, "~FR~SBGoogle Reader import (task) starting...")

        importer = GoogleReaderImporter(user=user)
        importer.import_feeds(auto_active=auto_active)
        importer.import_starred_items(count=10)

        feed_count = UserSubscription.objects.filter(user=user).count()
        user.profile.send_import_reader_finished_email(feed_count)
        logging.user(
            user, "~FR~SBGoogle Reader import (task): ~SK%s~SN~SB~FR feeds" %
            (feed_count))
Exemplo n.º 6
0
    def test_google_reader_import(self):
        self.client.login(username='******', password='******')
        user = User.objects.get(username='******')
        f = open(os.path.join(os.path.dirname(__file__), 'fixtures/google_reader.xml'))
        xml = f.read()
        f.close()
        
        reader_importer = GoogleReaderImporter(user, xml=xml)
        reader_importer.import_feeds()

        subs = UserSubscription.objects.filter(user=user)
        self.assertEquals(subs.count(), 66)
        
        usf = UserSubscriptionFolders.objects.get(user=user)
        self.assertEquals(json.decode(usf.folders), [{'Blogs \xe2\x80\x94 The Bloglets': [6, 16, 22, 35, 51, 56]}, {'Blogs': [1, 3, 25, 29, 30, 39, 40, 41, 50, 55, 57, 58, 59, 60, 66]}, {'Cooking': [11, 15, 42, 43, 46]}, {'New York': [7, 8, 17, 18, 19, 36, 45, 47, 52, 61]}, {'Tech': [2, 4, 9, 10, 12, 13, 14, 20, 23, 24, 26, 27, 28, 31, 32, 33, 34, 48, 49, 62, 64]}, {'Blogs \xe2\x80\x94 Tumblrs': [5, 21, 37, 38, 53, 54, 63, 65]}, 44])
Exemplo n.º 7
0
def import_from_google_reader(request):
    code = 0

    if request.user.is_authenticated():
        reader_importer = GoogleReaderImporter(request.user)
        try:
            reader_importer.import_feeds()
            reader_importer.import_starred_items()
        except AssertionError:
            code = -1
        else:
            code = 1
        if 'import_from_google_reader' in request.session:
            del request.session['import_from_google_reader']

    return dict(code=code)
Exemplo n.º 8
0
def import_from_google_reader(request):
    code = 0
    feed_count = 0
    
    if request.user.is_authenticated():
        reader_importer = GoogleReaderImporter(request.user)
        auto_active = bool(request.REQUEST.get('auto_active') or False)
        try:
            reader_importer.import_feeds(auto_active=auto_active)
            reader_importer.import_starred_items()
        except AssertionError:
            code = -1
        else:
            code = 1
        if 'import_from_google_reader' in request.session:
            del request.session['import_from_google_reader']
    
        feed_count = UserSubscription.objects.filter(user=request.user).count()
        
    return dict(code=code, feed_count=feed_count)
Exemplo n.º 9
0
def import_from_google_reader(request):
    code = 0
    feed_count = 0
    
    if request.user.is_authenticated():
        reader_importer = GoogleReaderImporter(request.user)
        auto_active = bool(request.REQUEST.get('auto_active') or False)
        try:
            reader_importer.import_feeds(auto_active=auto_active)
            reader_importer.import_starred_items()
        except AssertionError:
            code = -1
        else:
            code = 1
        if 'import_from_google_reader' in request.session:
            del request.session['import_from_google_reader']
    
        feed_count = UserSubscription.objects.filter(user=request.user).count()
        
    return dict(code=code, feed_count=feed_count)