예제 #1
0
    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
예제 #2
0
 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 = {}
예제 #3
0
 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='******')
예제 #4
0
    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
예제 #5
0
    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()
예제 #6
0
 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 = {}
예제 #7
0
 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)
예제 #8
0
 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
예제 #9
0
 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)
예제 #10
0
 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 = {}
예제 #11
0
 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)
예제 #12
0
    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)
예제 #13
0
파일: test_base.py 프로젝트: apache/allura
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',
    )
예제 #14
0
파일: test_tasks.py 프로젝트: apache/allura
 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
예제 #15
0
 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()
예제 #16
0
 def setUp(self):
     # need to create the "test" project so @td.with_wiki works
     setup_basic_test()
예제 #17
0
def setUp():
    setup_basic_test()
    setup_global_objects()
    h.set_context('test', neighborhood='Projects')
    c.project.install_app('blog', 'blog')
    g.set_app('blog')
예제 #18
0
 def setUp(self):
     setup_basic_test()
     self.setup_with_tools()
예제 #19
0
파일: test_app.py 프로젝트: 00mjk/allura
 def setUp(self):
     setup_basic_test()
예제 #20
0
 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)
예제 #21
0
 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()
예제 #22
0
 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()
예제 #23
0
 def setUp(self):
     setup_basic_test()
     ThreadLocalORMSession.close_all()
     setup_global_objects()
     self.provider = ProjectRegistrationProvider()
     self.parse = self.provider.project_from_url
예제 #24
0
 def setUp(self):
     setup_basic_test()
     ThreadLocalORMSession.close_all()
     setup_global_objects()
     self.provider = plugin.LocalAuthenticationProvider(Request.blank('/'))
예제 #25
0
 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()
예제 #28
0
 def setUp(self):
     setup_basic_test()
     setup_global_objects()
     ThreadLocalORMSession.flush_all()
     ThreadLocalORMSession.close_all()
예제 #29
0
파일: test_tasks.py 프로젝트: apache/allura
 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)
예제 #30
0
 def setUp(self):
     setup_basic_test()
     setup_global_objects()
     self.user = User.by_username('test-user-2')
     c.user = self.user
예제 #31
0
 def setUp(self):
     setup_basic_test()
     setup_global_objects()
     self.setup_with_tools()
예제 #32
0
def setUp():
    setup_basic_test()
    ThreadLocalORMSession.close_all()
    setup_global_objects()
예제 #33
0
def setUp(self):
    """Method called by nose before running each test"""
    setup_basic_test()
    setup_global_objects()
예제 #34
0
def setUp():
    setup_basic_test()
    setup_unit_test()
    setup_with_tools()
예제 #35
0
def setUp():
    setup_basic_test()
    setup_with_tools()
예제 #36
0
def setUp(self):
    """Method called by nose before running each test"""
    setup_basic_test()
예제 #37
0
 def setUp(self):
     setup_basic_test()
     setup_global_objects()
     ThreadLocalORMSession.flush_all()
     ThreadLocalORMSession.close_all()
     self.prefix = tg.config.get('scm.repos.root', '/')
예제 #38
0
def setUp():
    setup_basic_test()
    setup_global_objects()
    h.set_context('test', neighborhood='Projects')
    c.project.install_app('blog', 'blog')
    g.set_app('blog')
예제 #39
0
 def setUp(self):
     setup_basic_test()
     setup_global_objects()
예제 #40
0
 def setUp(self):
     setup_basic_test()
예제 #41
0
 def setUp(self):
     setup_basic_test()
     ThreadLocalORMSession.close_all()
     setup_global_objects()
     self.provider = plugin.LocalAuthenticationProvider(Request.blank('/'))
예제 #42
0
파일: test_lib.py 프로젝트: xmonader/allura
 def setUp(self):
     setup_basic_test()
     self.jinja2_env = AlluraJinjaRenderer.create(config,
                                                  g)['jinja'].jinja2_env
예제 #43
0
 def setUp(self):
     setup_basic_test()
     ThreadLocalORMSession.close_all()
     setup_global_objects()
     self.provider = ProjectRegistrationProvider()
     self.parse = self.provider.project_from_url
예제 #44
0
def setUp():
    setup_basic_test()
    ThreadLocalORMSession.close_all()
    setup_global_objects()
    M.MonQTask.query.remove({})
예제 #45
0
 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()
예제 #46
0
 def setUp(self):
     setup_basic_test()
     setup_global_objects()
     ThreadLocalORMSession.flush_all()
     ThreadLocalORMSession.close_all()
     self.prefix = tg.config.get('scm.repos.root', '/')
예제 #47
0
def setUp():
    setup_basic_test()
예제 #48
0
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()
예제 #49
0
 def setUp(self):
     setup_basic_test()
     setup_global_objects()
     self.setup_with_tools()
예제 #50
0
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(self):
     setup_basic_test()
     self.setup_with_tools()
예제 #52
0
def setUp():
    """Method called by nose before running each test"""
    setup_basic_test()
    setup_with_tools()
예제 #53
0
파일: test_tasks.py 프로젝트: apache/allura
 def setUp(self):
     setup_basic_test()
     setup_global_objects()
예제 #54
0
 def setUp(self):
     setup_basic_test()
     setup_global_objects()
     self.called_with = []