Exemple #1
0
 def test__fetch_feed_channel_information_no_channel(self):
     feeduri = "http://example.org/p"
     mock = self.mox.CreateMock(SPARQLQueryProcessor)
     expectedarg = r"SELECT.+\<%s\>.+" % re.escape(feeduri)
     mock.execute_query(Regex(expectedarg, flags=re.DOTALL))
     bindings = []
     fakeresults = {'results': {'bindings': bindings}}
     self.finder.processor = mock
     self.mox.ReplayAll()
     self.finder.processor.results = fakeresults
     channel = self.finder._fetch_feed_channel_information(feeduri)
     self.mox.VerifyAll()
     self.assertEqual(None, channel)
Exemple #2
0
 def test__fetch_feeduris_no_bindings(self):
     unversionedsourceuri = "http://example.org/p"
     mock = self.mox.CreateMock(SPARQLQueryProcessor)
     expectedarg = r"SELECT.+\<%s\>.+" % re.escape(unversionedsourceuri)
     mock.execute_query(Regex(expectedarg, flags=re.DOTALL))
     bindings = []
     fakeresults = {'results': {'bindings': bindings}}
     self.finder.processor = mock
     self.mox.ReplayAll()
     self.finder.processor.results = fakeresults
     feeds = self.finder._fetch_feeduris(unversionedsourceuri)
     self.mox.VerifyAll()
     self.assertEqual(0, len(feeds))
Exemple #3
0
 def test__fetch_feeditems(self):
     feeduri = "http://example.org/p"
     mock = self.mox.CreateMock(SPARQLQueryProcessor)
     expectedarg = r"SELECT.+\<%s\>.+" % re.escape(feeduri)
     mock.execute_query(Regex(expectedarg, flags=re.DOTALL))
     binding1 = {'title': {'value': "title1"}, 'link': {'value': "link1"}}
     binding2 = {'title': {'value': "title2"}}
     bindings = [binding1, binding2]
     fakeresults = {'results': {'bindings': bindings}}
     self.finder.processor = mock
     self.mox.ReplayAll()
     self.finder.processor.results = fakeresults
     items = self.finder._fetch_feeditems(feeduri)
     self.mox.VerifyAll()
     self.assertEqual(2, len(items))
     self.assertEqual("title1", items[0]['title'])
     self.assertEqual("link1", items[0]['link'])
     self.assertEqual("title2", items[1]['title'])
     self.assertEqual(None, items[1]['link'])
Exemple #4
0
 def test__fetch_seealso_uris(self):
     sourcename = "pkg"
     unversionedsourceuri = "base/source/%s" % sourcename
     mock = self.mox.CreateMock(SPARQLQueryProcessor)
     expectedarg = \
         r".+SELECT\s*\?uri.+\<%s\>\sa\sdeb:UnversionedSource\s*;\s*rdfs:seeAlso\s\?uri" % \
         re.escape(unversionedsourceuri)
     mock.execute_query(Regex(expectedarg, flags=re.DOTALL))
     binding1 = {'uri': {'value': "http://example.org/1"}}
     binding2 = {'uri': {'value': "http://example.org/2"}}
     bindings = [binding1, binding2]
     fakeresults = {'results': {'bindings': bindings}}
     self.finder.processor = mock
     self.mox.ReplayAll()
     self.finder.processor.results = fakeresults
     uris = self.finder._fetch_seealso_uris(unversionedsourceuri)
     self.mox.VerifyAll()
     self.assertEqual(2, len(uris))
     self.assertTrue("http://example.org/1" in uris)
     self.assertTrue("http://example.org/2" in uris)