Exemple #1
0
    def test_multiple_items(self):
        entry_list = [{'title': 'First'}, {'title': 'Second'}]
        atom_xml = atom_formatter.format_atom(entries=entry_list)

        root_elem = ElementTree.fromstring(atom_xml)
        entries = root_elem.findall('{http://www.w3.org/2005/Atom}entry')

        self.assertEqual(2, len(entries))
Exemple #2
0
    def test_include_single_item(self):
        entry_list = [{'title': 'Title', 'link': '/link/', 'updated': '2013-03-14T00:00:00+01:00'}]

        atom_xml = atom_formatter.format_atom(title='Feed Title', entries=entry_list)
        root_elem = ElementTree.fromstring(atom_xml)
        entry_elem = root_elem.find('{http://www.w3.org/2005/Atom}entry')

        self.assertEqual('Title', entry_elem.find('{http://www.w3.org/2005/Atom}title').text)

        link_elem = entry_elem.find('{http://www.w3.org/2005/Atom}link')
        self.assertEqual('/link/', link_elem.get('href'))
Exemple #3
0
    def get(self):
        word_lists = yield gen.Task(self.list_db.get_lists)
        entry_list = []
        for word_list in word_lists:
            entry = {'title': word_list.get('title'),
                     'link': '/list/%s' % make_stub(word_list.get('id'),
                                                    word_list.get('stub'))}
            entry_list.append(entry)

        self.write(atom_formatter.format_atom(title='CiHui',
                                              entries=entry_list))
        self.finish()
Exemple #4
0
    def get(self):
        word_lists = yield gen.Task(self.list_db.get_lists)
        entry_list = []
        for word_list in word_lists:
            entry = {
                'title':
                word_list.get('title'),
                'link':
                '/list/%s' %
                make_stub(word_list.get('id'), word_list.get('stub'))
            }
            entry_list.append(entry)

        self.write(
            atom_formatter.format_atom(title='CiHui', entries=entry_list))
        self.finish()
Exemple #5
0
    def test_set_title(self):
        atom_xml = atom_formatter.format_atom(title=u'大 feed title')
        root_elem = ElementTree.fromstring(atom_xml)
        title_elem = root_elem.find('{http://www.w3.org/2005/Atom}title')

        self.assertEqual(u'大 feed title', title_elem.text)
Exemple #6
0
 def test_empty_list(self):
     self.assertIn(b'http://www.w3.org/2005/Atom', atom_formatter.format_atom())