Exemple #1
0
 def test_unset_favorite_item(self):
     ctrl = Controller()
     req = Request(url='http://localhost/foo', form=dict(id='abcdef'))
     ans = unset_favorite_item(ctrl, req)
     self.assertDictEqual(ans, {})
     removed_obj = plugins.runtime.USER_ITEMS.instance.deleted_items[0]
     self.assertEqual(removed_obj, 'abcdef')
Exemple #2
0
 def test_set_favorite_item(self):
     ctrl = Controller()
     req = Request(url='http://localhost/first_form',
                   form=dict(corpora=['intercorp_en', 'intercorp_cs'],
                             subcorpus_id='my_subc1',
                             corpname='intercorp_en'))
     ans = set_favorite_item(ctrl, req)
     self.assertTrue('id' in ans)
     added_obj = plugins.runtime.USER_ITEMS.instance.added_items[0].to_dict(
     )
     self.assertTrue(added_obj['id'] == ans['id'])
     self.assertEqual(added_obj['size'], 4000)
     self.assertEqual(added_obj['size_info'], '4k')
     self.assertEqual(added_obj['name'],
                      'intercorp_en + intercorp_cs : my_subc1')
     self.assertEqual(added_obj['subcorpus_id'], 'my_subc1')
     self.assertDictEqual(
         added_obj['corpora'][0],
         dict(canonical_id='intercorp_en',
              name='intercorp_en',
              id='intercorp_en'))
     self.assertDictEqual(
         added_obj['corpora'][1],
         dict(canonical_id='intercorp_cs',
              name='intercorp_cs',
              id='intercorp_cs'))