def test_head(self): fp = FeedPipe().cat(['tests/eg.xml']).head(2) a = fp.as_atom_obj() self.assertEqual(a.entries[0].title.text, 'Migrating My Blog from Linode to CloudFront') self.assertEqual(a.entries[1].title.text, 'UCSPI') self.assertEqual(fp.count(), 2)
def test_reverse(self): fp = FeedPipe().cat(['tests/eg.xml']).reverse() a = fp.as_atom_obj() self.assertEqual(a.entries[0].title.text, 'Dream On Dreamer') self.assertEqual(a.entries[1].title.text, 'PID Namespaces in Linux')
def test_grep(self): fp = FeedPipe() \ .cat(['./tests/eg.xml']) \ .grep(lambda e: 'e' in e.title.text) a = fp.as_atom_obj() self.assertEqual(a.entries[0].title.text, 'Migrating My Blog from Linode to CloudFront') self.assertEqual(a.entries[1].title.text, 'Checking sudoers with visudo in SaltStack') self.assertEqual(fp.count(), 5)
def test_map(self): def prepend_name(e): e.title = '[STATION] ' + e.title.text return e fp = FeedPipe().cat(['tests/eg.xml']).map(prepend_name) a = fp.as_atom_obj() self.assertEqual( a.entries[0].title.text, '[STATION] Migrating My Blog from Linode to CloudFront') self.assertEqual(a.entries[1].title.text, '[STATION] UCSPI')
def test_map(self): def prepend_name(e): e.title = '[STATION] ' + e.title.text return e fp = FeedPipe().cat(['tests/eg.xml']).map(prepend_name) a = fp.as_atom_obj() self.assertEqual( a.entries[0].title.text, '[STATION] Migrating My Blog from Linode to CloudFront' ) self.assertEqual( a.entries[1].title.text, '[STATION] UCSPI' )
def test_grep(self): fp = FeedPipe() \ .cat(['./tests/eg.xml']) \ .grep(lambda e: 'e' in e.title.text) a = fp.as_atom_obj() self.assertEqual( a.entries[0].title.text, 'Migrating My Blog from Linode to CloudFront' ) self.assertEqual( a.entries[1].title.text, 'Checking sudoers with visudo in SaltStack' ) self.assertEqual(fp.count(), 5)
def test_sort(self): fp = FeedPipe().cat(['tests/eg.xml']) \ .sort(key=lambda e: e.title.text, reverse=False) a = fp.as_atom_obj() self.assertEqual(a.entries[0].title.text, 'Announcing cgid') self.assertEqual(a.entries[1].title.text, 'Checking sudoers with visudo in SaltStack') fp.sort() a = fp.as_atom_obj() self.assertEqual(a.entries[0].title.text, 'Migrating My Blog from Linode to CloudFront') self.assertEqual(a.entries[1].title.text, 'UCSPI')
def test_tail(self): fp = FeedPipe().cat(['tests/eg.xml']).tail(2) a = fp.as_atom_obj() self.assertEqual(a.entries[0].title.text, 'PID Namespaces in Linux') self.assertEqual(a.entries[1].title.text, 'Dream On Dreamer') self.assertEqual(fp.count(), 2)
def test_xml(self): self.assertEqual(type(FeedPipe().cat([ATOM10, RSS10]).as_xml()), type("station"))
def test_atom03(self): self._check_feed(FeedPipe().cat([ATOM03]))
def test_atom10(self): self._check_feed(FeedPipe().cat([ATOM10]))
def test_rss20_dc(self): self._check_feed(FeedPipe().cat([RSS20_DC]))
def test_rss10(self): self._check_feed(FeedPipe().cat([RSS10]))
def test_count(self): self.assertEqual(FeedPipe().cat([ATOM10, RSS10]).count(), 2)