예제 #1
0
파일: test_tasks.py 프로젝트: 00mjk/allura
 def test_bulk_export(self, zipdir, shutil):
     M.MonQTask.query.remove()
     export_tasks.bulk_export(['wiki'])
     temp = '/tmp/bulk_export/p/test/test'
     zipfn = '/tmp/bulk_export/p/test/test.zip'
     zipdir.assert_called_with(temp, zipfn)
     shutil.rmtree.assert_called_once_with(six.ensure_binary(temp))
     # check notification
     tasks = M.MonQTask.query.find(
         dict(task_name='allura.tasks.mail_tasks.sendsimplemail')).all()
     assert_equal(len(tasks), 1)
     assert_equal(tasks[0].kwargs['subject'],
                  'Bulk export for project test completed')
     assert_equal(tasks[0].kwargs['fromaddr'], '"Allura" <noreply@localhost>')
     assert_equal(tasks[0].kwargs['reply_to'], g.noreply)
     text = tasks[0].kwargs['text']
     assert_in('The bulk export for project test is completed.', text)
     assert_in('The following tools were exported:\n- wiki', text)
     assert_in('Sample instructions for test', text)
예제 #2
0
파일: test_tasks.py 프로젝트: apache/allura
 def test_bulk_export(self, wiki_bulk_export, zipdir, shutil):
     M.MonQTask.query.remove()
     export_tasks.bulk_export([u'wiki'])
     assert_equal(wiki_bulk_export.call_count, 1)
     temp = '/tmp/bulk_export/p/test/test'
     zipfn = '/tmp/bulk_export/p/test/test.zip'
     zipdir.assert_called_with(temp, zipfn)
     shutil.rmtree.assert_called_once_with(temp)
     # check notification
     tasks = M.MonQTask.query.find(
         dict(task_name='allura.tasks.mail_tasks.sendsimplemail')).all()
     assert_equal(len(tasks), 1)
     assert_equal(tasks[0].kwargs['subject'],
                  'Bulk export for project test completed')
     assert_equal(tasks[0].kwargs['fromaddr'], '"Allura" <noreply@localhost>')
     assert_equal(tasks[0].kwargs['reply_to'], g.noreply)
     text = tasks[0].kwargs['text']
     assert_in('The bulk export for project test is completed.', text)
     assert_in('The following tools were exported:\n- wiki', text)
     assert_in('Sample instructions for test', text)
예제 #3
0
 def test_bulk_export(self, wiki_bulk_export, zipdir, shutil, project_json):
     M.MonQTask.query.remove()
     export_tasks.bulk_export([u'wiki'])
     wiki_bulk_export.assert_called_once()
     project_json.assert_called_once()
     temp = '/tmp/bulk_export/p/test/test'
     zipfn = '/tmp/bulk_export/p/test/test.zip'
     zipdir.assert_called_with(temp, zipfn)
     shutil.rmtree.assert_called_once_with(temp)
     # check notification
     M.MonQTask.run_ready()
     tasks = M.MonQTask.query.find(
         dict(task_name='allura.tasks.mail_tasks.sendmail')).all()
     assert_equal(len(tasks), 1)
     assert_equal(tasks[0].kwargs['subject'], 'Bulk export for project test completed')
     assert_equal(tasks[0].kwargs['fromaddr'], '*****@*****.**')
     assert_equal(tasks[0].kwargs['reply_to'], '*****@*****.**')
     text = tasks[0].kwargs['text']
     assert_in('The bulk export for project test is completed.', text)
     assert_in('The following tools were exported:\n- wiki', text)
     assert_in('Sample instructions for test', text)
예제 #4
0
 def test_bulk_export(self, log, wiki_bulk_export, zipdir, shutil,
                      project_json):
     M.MonQTask.query.remove()
     export_tasks.bulk_export([u'wiki'])
     log.info.assert_any_call('Exporting wiki...')
     wiki_bulk_export.assert_called_once()
     project_json.assert_called_once()
     temp = '/tmp/bulk_export/p/test/test'
     zipfn = '/tmp/bulk_export/p/test/test.zip'
     zipdir.assert_called_with(temp, zipfn)
     shutil.rmtree.assert_called_once_with(temp)
     # check notification
     M.MonQTask.run_ready()
     tasks = M.MonQTask.query.find(
         dict(task_name='allura.tasks.mail_tasks.sendmail')).all()
     assert_equal(len(tasks), 1)
     assert_equal(tasks[0].kwargs['subject'],
                  'Bulk export for project test completed')
     assert_equal(tasks[0].kwargs['fromaddr'], '*****@*****.**')
     assert_equal(tasks[0].kwargs['reply_to'], '*****@*****.**')
     text = tasks[0].kwargs['text']
     assert_in('The bulk export for project test is completed.', text)
     assert_in('The following tools were exported:\n- wiki', text)
     assert_in('Sample instructions for test', text)
예제 #5
0
 def test_bulk_export_not_exportable_tool(self, mail_tasks, app, log):
     app.return_value.exportable = False
     export_tasks.bulk_export([u'bugs', u'blog'])
     log.info.assert_any_call('Tool bugs is not exportable. Skipping.')
     log.info.assert_any_call('Tool blog is not exportable. Skipping.')
예제 #6
0
 def test_bulk_export_invalid_tool(self, log):
     export_tasks.bulk_export([u'bugs', u'blog'])
     log.info.assert_any_call('Can not load app for bugs mount point. Skipping.')
     log.info.assert_any_call('Can not load app for blog mount point. Skipping.')
예제 #7
0
 def test_bulk_export_not_exportable_tool(self, mail_tasks, app, log):
     app.return_value.exportable = False
     export_tasks.bulk_export([u'bugs', u'blog'])
     log.info.assert_any_call('Tool bugs is not exportable. Skipping.')
     log.info.assert_any_call('Tool blog is not exportable. Skipping.')
예제 #8
0
 def test_bulk_export_invalid_tool(self, log):
     export_tasks.bulk_export([u'bugs', u'blog'])
     log.info.assert_any_call(
         'Can not load app for bugs mount point. Skipping.')
     log.info.assert_any_call(
         'Can not load app for blog mount point. Skipping.')