def setUp(self):
     self.api = TH.configure_functional_oauth_app(main.main)
     self.user = make_user(
         oauth=[dict(client_id=None, token='token-value')],
         password='******')
     self.api.authorize('token-value')
     content1 = '\n'.join([
         'id,name,email',
         'r1,Example1,[email protected]',
         'r2,Example2,[email protected]',
         'r3,Example3,[email protected]',
         'r4,Example4,[email protected]'])
     content2 = '\n'.join([
         's1,Example1,[email protected]',
         's2,Example2,[email protected]',
         's3,Example3,[email protected]',
         's4,Example4,[email protected]'])
     f1 = make_file(
         self.user, 'test.csv',
         content=content1)
     f2 = make_file(
         self.user, 'test.csv',
         content=content2)
     self.lst1 = TH.make_list(
         self.user, f1,
         mapping=dict(header=True, sheet=0, email=2))
     self.lst2 = TH.make_list(
         self.user, f2,
         mapping=dict(header=False, sheet=0, email=2))
 def test_append_list_nohdr(self):
     content = '\n'.join([
         '0,A,B,C,D',
         '1,a,b,c,d',
         '2,a,b,c,d',
         '3,a,b,c,d',
         '4,a,b,c,d',
     ])
     f = make_file(
         self.user, 'test-appended.csv',
         content=content)
     self.api.post(
         str('/1.0/list/%s/' % self.lst2._id),
         params=json.dumps(dict(file_nonce=f.metadata.nonce)),
         status=200)
     res = self.api.get(
         str('/1.0/list/%s/appended.csv' % self.lst2._id),
         status=200)
     self.assertEqual(
         res.body,
         '0,A,B,C,D\r\n'
         '1,a,b,c,d,s1,Example1,[email protected]\r\n'
         '2,a,b,c,d,s2,Example2,[email protected]\r\n'
         '3,a,b,c,d,s3,Example3,[email protected]\r\n'
         '4,a,b,c,d,s4,Example4,[email protected]\r\n')
 def test_list_from_url(self):
     f = make_file(
         self.user, 'test.csv',
         '[email protected]\n')
     mapping = dict(header=False, sheet=0, email=0)
     res = self.api.post(
         '/1.0/list/',
         params=json.dumps(dict(
             file_nonce=f.metadata.nonce,
             mapping=mapping)),
         status=201)
     self.assertEqual(res.json['mapping'], mapping)