def setUp(self): setup_basic_test() self.blob1 = Mock() self.blob1.name = 'Home.md' self.blob1.data_stream.read.return_value = '# test message' self.blob2 = Mock() self.blob2.name = 'Home2.creole' self.blob2.data_stream.read.return_value = '**test message**' self.blob3 = Mock() self.blob3.name = 'Home3.rest' self.blob3.data_stream.read.return_value = 'test message' self.commit1 = Mock() self.commit1.tree.blobs = [self.blob1] self.commit1.committed_date = 1256301446 self.commit2 = Mock() blobs = [self.blob1, self.blob2, self.blob3] self.commit2.tree.blobs = blobs self.commit2.tree.__contains__ = lambda _, item: item in [ self.blob1.name, self.blob2.name, self.blob3.name] self.commit2.tree.traverse.return_value = blobs self.commit2.committed_date = 1256291446
def setUp(self): setup_basic_test() setup_global_objects() self.repo = mock.Mock( name='repo', _commits=OrderedDict(), _last_commit=None, spec=M.Repository) self.repo.paged_diffs.return_value = { 'added': [], 'removed': [], 'copied': [], 'renamed': [], 'changed': [], 'total': 0, } self.repo.shorthand_for_commit = lambda _id: _id[:6] self.repo.rev_to_commit_id = lambda rev: rev self.repo.log = self._log self._changes = defaultdict(list) self.repo.get_changes = lambda _id: self._changes[_id] self._last_commits = [(None, set())] self.repo._get_last_commit = lambda i, p: self._last_commits.pop() lcids = M.repository.RepositoryImplementation.last_commit_ids.__func__ self.repo.last_commit_ids = lambda *a, **k: lcids(self.repo, *a, **k) c.lcid_cache = {}
def setUp(self, *a, **kw): super(TestGCTrackerImporter, self).setUp(*a, **kw) setup_basic_test() self.empty_issue = self._make_extractor(open(pkg_resources.resource_filename('forgeimporters', 'tests/data/google/empty-issue.html')).read()) self.test_issue = self._make_extractor(open(pkg_resources.resource_filename('forgeimporters', 'tests/data/google/test-issue.html')).read()) c.project = self.project = M.Project.query.get(shortname='test') c.user = self.user = M.User.query.get(username='******')
def setUp(self): from allura.model import User setup_basic_test() setup_global_objects() self.user = User.by_username("test-user-2") c.user = self.user
def setUp(self): super(TestGitCommit, self).setUp() setup_basic_test() user = User.by_username('test-admin') user.set_password('testpassword') addr = M.EmailAddress.upsert('*****@*****.**') user.claim_address('*****@*****.**') self.setup_with_tools()
def setUp(self): setup_basic_test() setup_global_objects() self.repo = mock.Mock('repo', _commits=OrderedDict(), _last_commit=None) self.repo.shorthand_for_commit = lambda _id: _id[:6] self.repo.commits = self._commits lcids = M.repository.RepositoryImplementation.last_commit_ids.__func__ self.repo.last_commit_ids = lambda *a, **k: lcids(self.repo, *a, **k) c.lcid_cache = {}
def setUp(self): setup_basic_test() setup_global_objects() self.mr = M.MergeRequest( app_config=mock.Mock(_id=ObjectId()), downstream={'commit_id': '12345'}, request_number=1, ) self._set_mr_mock_attrs(self.mr)
def test_compound_error(self): '''test_compound_exception -- make sure our multi-exception return works OK ''' setup_basic_test() setup_global_objects() t = raise_exc.post() self.assertRaises(CompoundError, t) for x in range(10): assert ('assert %d' % x) in t.result
def setUp(self): setup_basic_test() setup_global_objects() self.mr = M.MergeRequest( app_config=mock.Mock(_id=ObjectId()), downstream={'commit_id': '12345'}, ) self.mr.app = mock.Mock(forkable=True) self.mr.app.repo.commit.return_value = mock.Mock(_id='09876') self.mr.merge_allowed = mock.Mock(return_value=True)
def setUp(self): setup_basic_test() setup_global_objects() self.repo = mock.Mock('repo', _commits=OrderedDict(), _last_commit=None) self.repo.shorthand_for_commit = lambda _id: _id[:6] self.repo.rev_to_commit_id = lambda rev: rev self.repo.log = self._log self._changes = defaultdict(list) self.repo.get_changes = lambda _id: self._changes[_id] self._last_commits = [(None, set())] self.repo._get_last_commit = lambda i, p: self._last_commits.pop() lcids = M.repository.RepositoryImplementation.last_commit_ids.__func__ self.repo.last_commit_ids = lambda *a, **k: lcids(self.repo, *a, **k) c.lcid_cache = {}
def setUp(self): setup_basic_test() self.patches = self.monkey_patch() for p in self.patches: p.start() self.setup_with_tools() self.project = M.Project.query.get(shortname=test_project_with_repo) self.git = self.project.app_instance('src') self.wh = M.Webhook( type='repo-push', app_config_id=self.git.config._id, hook_url='http://httpbin.org/post', secret='secret') session(self.wh).flush(self.wh)
def setUp(self): setup_basic_test() self.options = mock.Mock() self.options.dump_dir = '/tmp/w2m_test' # monkey-patch MySQLExtractor for test def pages(self): yield {'page_id': 1, 'title': 'Test title'} yield {'page_id': 2, 'title': 'Main_Page'} yield {'page_id': 3, 'title': 'Test'} def history(self, page_id): data = { 1: [ {'timestamp': 1, 'text': "Test", 'username': '******'}, {'timestamp': 2, 'text': "Test Text", 'username': '******'} ], 2: [ {'timestamp': 1, 'text': "Main_Page", 'username': '******'}, {'timestamp': 2, 'text': "Main_Page text", 'username': '******'} ], 3: [ {'timestamp': 1, 'text': "Some test text", 'username': ''}, {'timestamp': 2, 'text': "", 'username': ''} ] } revisions = data[page_id] for rev in revisions: yield rev def talk(self, page_title): return { 'text': 'Talk for page %s.' % page_title, 'timestamp': 1, 'username': '******' } def attachments(self, *args, **kwargs): # make 'empty' iterator if False: yield MySQLExtractor._pages = pages MySQLExtractor._history = history MySQLExtractor._talk = talk MySQLExtractor._attachments = attachments self.extractor = MySQLExtractor(self.options)
def test_import_tool_failed(g, ToolImporter, format_exc): setup_basic_test() format_exc.return_value = 'my traceback' importer = mock.Mock(source='importer_source', tool_label='importer_tool_label') importer.import_tool.side_effect = RuntimeError('my error') ToolImporter.return_value = importer with assert_raises(RuntimeError): base.import_tool('forgeimporters.base.ToolImporter', project_name='project_name') g.post_event.assert_called_once_with( 'import_tool_task_failed', error=str(importer.import_tool.side_effect), traceback='my traceback', importer_source='importer_source', importer_tool_label='importer_tool_label', project_name='project_name', )
def test_compound_error(self): '''test_compound_exception -- make sure our multi-exception return works OK ''' setup_basic_test() setup_global_objects() t = raise_exc.post() with LogCapture(level=logging.ERROR) as l, \ mock.patch.dict(tg.config, {'monq.raise_errors': False}): # match normal non-test behavior t() # l.check() would be nice, but string is too detailed to check assert_equal(l.records[0].name, 'allura.model.monq_model') msg = l.records[0].getMessage() assert_in("AssertionError('assert 0',)", msg) assert_in("AssertionError('assert 5',)", msg) assert_in(' on job <MonQTask ', msg) assert_in(' (error) P:10 allura.tests.test_tasks.raise_exc ', msg) for x in range(10): assert ('assert %d' % x) in t.result
def setUp(self): setup_basic_test() self.provider = plugin.AuthenticationProvider(Request.blank('/')) self.pwd_updated = dt.datetime.utcnow() - dt.timedelta(days=100) self.provider.get_last_password_updated = lambda u: self.pwd_updated self.user = Mock()
def setUp(self): # need to create the "test" project so @td.with_wiki works setup_basic_test()
def setUp(): setup_basic_test() setup_global_objects() h.set_context('test', neighborhood='Projects') c.project.install_app('blog', 'blog') g.set_app('blog')
def setUp(self): setup_basic_test() self.setup_with_tools()
def setUp(self): setup_basic_test()
def setUp(self): setup_basic_test() setup_global_objects() project = M.Project.query.get(shortname='test') shutil.rmtree(project.bulk_export_path(tg.config['bulk_export_path']), ignore_errors=True)
def setUp(self): setup_basic_test() self.setup_with_tools() if asbool(tg.config.get('smtp.mock')): self.smtp_mock = mock.patch('allura.lib.mail_util.smtplib.SMTP') self.smtp_mock.start()
def setUp(self): setup_basic_test() ThreadLocalORMSession.close_all() setup_global_objects() self.provider = ProjectRegistrationProvider() self.parse = self.provider.project_from_url
def setUp(self): setup_basic_test() ThreadLocalORMSession.close_all() setup_global_objects() self.provider = plugin.LocalAuthenticationProvider(Request.blank('/'))
def setUp(self): setup_basic_test() self.provider = plugin.LdapAuthenticationProvider(Request.blank('/'))
def setUp(self): """Method called by nose before running each test""" #setup_basic_test(app_name='main_with_amqp') setup_basic_test() setup_global_objects()
def setUp(): setup_basic_test()
def setUp(self): setup_basic_test() setup_global_objects() ThreadLocalORMSession.flush_all() ThreadLocalORMSession.close_all()
def setUp(self): setup_basic_test() setup_global_objects() self.user = User.by_username('test-user-2') c.user = self.user
def setUp(self): setup_basic_test() setup_global_objects() self.setup_with_tools()
def setUp(): setup_basic_test() ThreadLocalORMSession.close_all() setup_global_objects()
def setUp(self): """Method called by nose before running each test""" setup_basic_test() setup_global_objects()
def setUp(): setup_basic_test() setup_unit_test() setup_with_tools()
def setUp(): setup_basic_test() setup_with_tools()
def setUp(self): """Method called by nose before running each test""" setup_basic_test()
def setUp(self): setup_basic_test() setup_global_objects() ThreadLocalORMSession.flush_all() ThreadLocalORMSession.close_all() self.prefix = tg.config.get('scm.repos.root', '/')
def setUp(self): setup_basic_test() setup_global_objects()
def setUp(self): setup_basic_test() self.jinja2_env = AlluraJinjaRenderer.create(config, g)['jinja'].jinja2_env
def setUp(): setup_basic_test() ThreadLocalORMSession.close_all() setup_global_objects() M.MonQTask.query.remove({})
def setUp(self): setup_basic_test() self.setup_with_tools() if asbool(tg.config.get("smtp.mock")): self.smtp_mock = mock.patch("allura.lib.mail_util.smtplib.SMTP") self.smtp_mock.start()
def setUp(): """Method called by nose once before running the package. Some functions need it run again to reset data""" setup_basic_test() setup_unit_test() setup_with_tools()
def setUp(): """Method called by nose before running each test""" setup_basic_test() setup_with_tools()
def setUp(self): setup_basic_test() setup_global_objects() self.called_with = []