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_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_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_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_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_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_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_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_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')