[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/pim/krss/resources/libkrssresource/tests
From:       Dmitry Ivanov <vonami () gmail ! com>
Date:       2009-04-04 8:29:23
Message-ID: 1238833763.745440.23796.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 948985 by divanov:

Test tags too


 M  +54 -10    importopmljobtest.cpp  


--- trunk/playground/pim/krss/resources/libkrssresource/tests/importopmljobtest.cpp \
#948984:948985 @@ -19,6 +19,7 @@
 #include "importopmljob.h"
 #include "krssinterface.h"
 #include "libkrss/resourcemanager.h"
+#include "libkrss/tagprovider.h"
 
 #include <KDE/Akonadi/CollectionFetchJob>
 #include <akonadi/qtest_akonadi.h>
@@ -55,6 +56,19 @@
     QVERIFY( reply.isValid() );
     QVERIFY( reply.value().value( "error" ).toInt() == 0 );
 
+    TagProviderRetrieveJob *tjob = new TagProviderRetrieveJob();
+    QVERIFY( tjob->exec() );
+    const TagProvider * const tagProvider = tjob->tagProvider();
+    const QHash<TagId, Tag> allTags = tagProvider->tags();
+    QCOMPARE( allTags.size(), 6 );
+    QHashIterator<TagId, Tag> it( allTags );
+    QStringList tagLabels;
+    while ( it.hasNext() ) {
+        it.next();
+        tagLabels.append( it.value().label() );
+    }
+    compareLists( tagLabels, QStringList() << "Imported" << "Linux" << "Planets" << \
"Ubuntu" << "News" << "Technology" ); +
     CollectionFetchJob * job = new CollectionFetchJob( Collection::root(), \
CollectionFetchJob::Recursive, this );  job->setResource( \
"akonadi_opml_rss_resource_0" );  QVERIFY( job->exec() );
@@ -76,8 +90,14 @@
             QCOMPARE( feed.htmlUrl(), QString( "http://planet.freedesktop.org" ) );
             QCOMPARE( feed.description(), QString( "planet.freedesktop.org - \
http://planet.freedesktop.org" ) );  QCOMPARE( feed.feedType(), QString( "rss" ) );
-            // TODO(dmitry): proper tag handling
-            //compareLists( feed.tags(), QStringList() << "Imported" << "Linux" << \
"Planets" ); +            const QList<TagId> tagIds = feed.tags();
+            QCOMPARE( tagIds.count(), 3 );
+            QStringList tagLabels;
+            Q_FOREACH( const TagId& tagId, tagIds ) {
+                QVERIFY( allTags.contains( tagId ) );
+                tagLabels.append( allTags.value( tagId ).label() );
+            }
+            compareLists( tagLabels, QStringList() << "Imported" << "Linux" << \
"Planets" );  }
         // verifies that 'category=Linux,Ubuntu' is parsed correctly and
         // tag 'Linux' is set only once
@@ -86,8 +106,14 @@
             QCOMPARE( feed.htmlUrl(), QString( "http://planet.ubuntu.com/" ) );
             QCOMPARE( feed.description(), QString( "Planet Ubuntu - \
http://planet.ubuntu.com/" ) );  QCOMPARE( feed.feedType(), QString( "rss" ) );
-            // TODO(dmitry): proper tag handling
-            //compareLists( feed.tags(), QStringList() << "Imported" << "Linux" << \
"Planets" << "Ubuntu" ); +            const QList<TagId> tagIds = feed.tags();
+            QCOMPARE( tagIds.count(), 4 );
+            QStringList tagLabels;
+            Q_FOREACH( const TagId& tagId, tagIds ) {
+                QVERIFY( allTags.contains( tagId ) );
+                tagLabels.append( allTags.value( tagId ).label() );
+            }
+            compareLists( tagLabels, QStringList() << "Imported" << "Linux" << \
"Planets" << "Ubuntu" );  }
         // this time without any tags except the defaultTag
         else if ( feed.xmlUrl() == "http://www.jwz.org/cheesegrater/RSS/apod.rss" ) \
{ @@ -95,8 +121,14 @@
             QCOMPARE( feed.htmlUrl(), QString( "http://antwrp.gsfc.nasa.gov/apod/" ) \
                );
             QCOMPARE( feed.description(), QString( "A different image or photograph \
of our fascinating universe" ) );  QCOMPARE( feed.feedType(), QString( "rss" ) );
-            // TODO(dmitry): proper tag handling
-            //compareLists( feed.tags(), QStringList() << "Imported" );
+            const QList<TagId> tagIds = feed.tags();
+            QCOMPARE( tagIds.count(), 1 );
+            QStringList tagLabels;
+            Q_FOREACH( const TagId& tagId, tagIds ) {
+                QVERIFY( allTags.contains( tagId ) );
+                tagLabels.append( allTags.value( tagId ).label() );
+            }
+            compareLists( tagLabels, QStringList() << "Imported" );
         }
         // verify that category="/Linux/News,/Technology" is parsed correctly
         else if ( feed.xmlUrl() == "http://lwn.net/headlines/newrss" ) {
@@ -104,8 +136,14 @@
             QCOMPARE( feed.htmlUrl(), QString( "http://lwn.net" ) );
             QCOMPARE( feed.description(), QString( "LWN.net is a comprehensive \
source of news and opinions from and about the Linux community" ) );  QCOMPARE( \
                feed.feedType(), QString( "rss" ) );
-            // TODO(dmitry): proper tag handling
-            //compareLists( feed.tags(), QStringList() << "Imported" << "Linux" << \
"News" << "Technology" ); +            const QList<TagId> tagIds = feed.tags();
+            QCOMPARE( tagIds.count(), 4 );
+            QStringList tagLabels;
+            Q_FOREACH( const TagId& tagId, tagIds ) {
+                QVERIFY( allTags.contains( tagId ) );
+                tagLabels.append( allTags.value( tagId ).label() );
+            }
+            compareLists( tagLabels, QStringList() << "Imported" << "Linux" << \
"News" << "Technology" );  }
         // make sure that a single tag in category=/News is parsed correctly
         else if ( feed.xmlUrl() == \
"http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml" ) { @@ \
                -113,8 +151,14 @@
             QCOMPARE( feed.htmlUrl(), QString( \
                "http://news.bbc.co.uk/go/rss/-/2/hi/default.stm" ) );
             QCOMPARE( feed.description(), QString( "Visit BBC News for \
up-to-the-minute news" ) );  QCOMPARE( feed.feedType(), QString( "rss" ) );
-            // TODO(dmitry): proper tag handling
-            //compareLists( feed.tags(), QStringList() << "Imported" << "News" );
+            const QList<TagId> tagIds = feed.tags();
+            QCOMPARE( tagIds.count(), 2 );
+            QStringList tagLabels;
+            Q_FOREACH( const TagId& tagId, tagIds ) {
+                QVERIFY( allTags.contains( tagId ) );
+                tagLabels.append( allTags.value( tagId ).label() );
+            }
+            compareLists( tagLabels, QStringList() << "Imported" << "News" );
         }
         else {
             QFAIL( "I didn't expect to see this feed in the test data" );


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic