Exemplo n.º 1
0
 def test_invalid(self):
     with td.raises(Invalid):
         GoogleCodeProjectNameValidator()._to_python('http://code.google.com/')
     with td.raises(Invalid):
         GoogleCodeProjectNameValidator()._to_python('http://foobar.com/p/gmapcatcher')
     with td.raises(Invalid):
         GoogleCodeProjectNameValidator()._to_python('http://code.google.com/p/asdf_asdf')
     with td.raises(Invalid):
         GoogleCodeProjectNameValidator()._to_python('http://code.google.com/x/y/z')
Exemplo n.º 2
0
def test_project():
    assert_equals(type(c.project.sidebar_menu()), list)
    assert_in(c.project.script_name, c.project.url())
    old_proj = c.project
    h.set_context('test/sub1', neighborhood='Projects')
    assert_equals(type(c.project.sidebar_menu()), list)
    assert_equals(type(c.project.sitemap()), list)
    assert_equals(c.project.sitemap()[1].label, 'Admin')
    assert_in(old_proj, list(c.project.parent_iter()))
    h.set_context('test', 'wiki', neighborhood='Projects')
    adobe_nbhd = M.Neighborhood.query.get(name='Adobe')
    p = M.Project.query.get(
        shortname='adobe-1', neighborhood_id=adobe_nbhd._id)
    # assert 'http' in p.url() # We moved adobe into /adobe/, not
    # http://adobe....
    assert_in(p.script_name, p.url())
    assert_equals(c.project.shortname, 'test')
    assert_in('<p>', c.project.description_html)
    c.project.uninstall_app('hello-test-mount-point')
    ThreadLocalORMSession.flush_all()

    c.project.install_app('Wiki', 'hello-test-mount-point')
    c.project.support_page = 'hello-test-mount-point'
    assert_equals(c.project.app_config('wiki').tool_name, 'wiki')
    ThreadLocalORMSession.flush_all()
    with td.raises(ToolError):
        # already installed
        c.project.install_app('Wiki', 'hello-test-mount-point')
    ThreadLocalORMSession.flush_all()
    c.project.uninstall_app('hello-test-mount-point')
    ThreadLocalORMSession.flush_all()
    with td.raises(ToolError):
        # mount point reserved
        c.project.install_app('Wiki', 'feed')
    with td.raises(ToolError):
        # mount point too long
        c.project.install_app('Wiki', 'a' * 64)
    with td.raises(ToolError):
        # mount point must begin with letter
        c.project.install_app('Wiki', '1')
    # single letter mount points are allowed
    c.project.install_app('Wiki', 'a')
    # Make sure the project support page is reset if the tool it was pointing
    # to is uninstalled.
    assert c.project.support_page == ''
    app_config = c.project.app_config('hello')
    app_inst = c.project.app_instance(app_config)
    app_inst = c.project.app_instance('hello')
    app_inst = c.project.app_instance('hello2123')
    c.project.breadcrumbs()
    c.app.config.breadcrumbs()
Exemplo n.º 3
0
def test_project():
    assert_equals(type(c.project.sidebar_menu()), list)
    assert_in(c.project.script_name, c.project.url())
    old_proj = c.project
    h.set_context('test/sub1', neighborhood='Projects')
    assert_equals(type(c.project.sidebar_menu()), list)
    assert_equals(type(c.project.sitemap()), list)
    assert_equals(c.project.sitemap()[1].label, 'Admin')
    assert_in(old_proj, list(c.project.parent_iter()))
    h.set_context('test', 'wiki', neighborhood='Projects')
    adobe_nbhd = M.Neighborhood.query.get(name='Adobe')
    p = M.Project.query.get(shortname='adobe-1',
                            neighborhood_id=adobe_nbhd._id)
    # assert 'http' in p.url() # We moved adobe into /adobe/, not
    # http://adobe....
    assert_in(p.script_name, p.url())
    assert_equals(c.project.shortname, 'test')
    assert_in('<p>', c.project.description_html)
    c.project.uninstall_app('hello-test-mount-point')
    ThreadLocalORMSession.flush_all()

    c.project.install_app('Wiki', 'hello-test-mount-point')
    c.project.support_page = 'hello-test-mount-point'
    assert_equals(c.project.app_config('wiki').tool_name, 'wiki')
    ThreadLocalORMSession.flush_all()
    with td.raises(ToolError):
        # already installed
        c.project.install_app('Wiki', 'hello-test-mount-point')
    ThreadLocalORMSession.flush_all()
    c.project.uninstall_app('hello-test-mount-point')
    ThreadLocalORMSession.flush_all()
    with td.raises(ToolError):
        # mount point reserved
        c.project.install_app('Wiki', 'feed')
    with td.raises(ToolError):
        # mount point too long
        c.project.install_app('Wiki', 'a' * 64)
    with td.raises(ToolError):
        # mount point must begin with letter
        c.project.install_app('Wiki', '1')
    # single letter mount points are allowed
    c.project.install_app('Wiki', 'a')
    # Make sure the project support page is reset if the tool it was pointing
    # to is uninstalled.
    assert c.project.support_page == ''
    app_config = c.project.app_config('hello')
    app_inst = c.project.app_instance(app_config)
    app_inst = c.project.app_instance('hello')
    app_inst = c.project.app_instance('hello2123')
    c.project.breadcrumbs()
    c.app.config.breadcrumbs()
Exemplo n.º 4
0
def test_project():
    assert_equals(type(c.project.sidebar_menu()), list)
    assert_in(c.project.script_name, c.project.url())
    old_proj = c.project
    h.set_context("test/sub1", neighborhood="Projects")
    assert_equals(type(c.project.sidebar_menu()), list)
    assert_equals(type(c.project.sitemap()), list)
    assert_equals(c.project.sitemap()[1].label, "Admin")
    assert_in(old_proj, list(c.project.parent_iter()))
    h.set_context("test", "wiki", neighborhood="Projects")
    adobe_nbhd = M.Neighborhood.query.get(name="Adobe")
    p = M.Project.query.get(shortname="adobe-1", neighborhood_id=adobe_nbhd._id)
    # assert 'http' in p.url() # We moved adobe into /adobe/, not
    # http://adobe....
    assert_in(p.script_name, p.url())
    assert_equals(c.project.shortname, "test")
    assert_in("<p>", c.project.description_html)
    c.project.uninstall_app("hello-test-mount-point")
    ThreadLocalORMSession.flush_all()

    c.project.install_app("Wiki", "hello-test-mount-point")
    c.project.support_page = "hello-test-mount-point"
    assert_equals(c.project.app_config("wiki").tool_name, "wiki")
    ThreadLocalORMSession.flush_all()
    with td.raises(ToolError):
        # already installed
        c.project.install_app("Wiki", "hello-test-mount-point")
    ThreadLocalORMSession.flush_all()
    c.project.uninstall_app("hello-test-mount-point")
    ThreadLocalORMSession.flush_all()
    with td.raises(ToolError):
        # mount point reserved
        c.project.install_app("Wiki", "feed")
    with td.raises(ToolError):
        # mount point too long
        c.project.install_app("Wiki", "a" * 64)
    with td.raises(ToolError):
        # mount point must begin with letter
        c.project.install_app("Wiki", "1")
    # single letter mount points are allowed
    c.project.install_app("Wiki", "a")
    # Make sure the project support page is reset if the tool it was pointing
    # to is uninstalled.
    assert c.project.support_page == ""
    app_config = c.project.app_config("hello")
    app_inst = c.project.app_instance(app_config)
    app_inst = c.project.app_instance("hello")
    app_inst = c.project.app_instance("hello2123")
    c.project.breadcrumbs()
    c.app.config.breadcrumbs()
Exemplo n.º 5
0
    def test__post_other_error(self, index_tasks):
        def on_post(chunk):
            raise pymongo.errors.InvalidDocument("Cannot encode object...")

        index_tasks.add_artifacts.post.side_effect = on_post
        with td.raises(pymongo.errors.InvalidDocument):
            self.ext._post(index_tasks.add_artifacts, list(range(5)))
Exemplo n.º 6
0
 def test_hosted_domain(self):
     assert_equal(
         GoogleCodeProjectNameValidator()._to_python('https://code.google.com/a/eclipselabs.org/p/restclient-tool'),
         'a/eclipselabs.org/p/restclient-tool'
     )
     with td.raises(Invalid):
         GoogleCodeProjectNameValidator()._to_python('http://code.google.com/a/eclipselabs.org/bogus')
Exemplo n.º 7
0
 def test_invalid_args(self):
     M.MonQTask.query.remove()
     show_models.ReindexCommand.post('--invalid-option')
     with td.raises(Exception):
         M.MonQTask.run_ready()
     task = M.MonQTask.query.get(task_name=self.task_name)
     assert_equal(task.state, 'error')
     assert_in('Error parsing args', task.result)
Exemplo n.º 8
0
def test_login_overlay():
    with h.login_overlay():
        raise HTTPUnauthorized()
    with h.login_overlay(exceptions=['foo']):
        raise HTTPUnauthorized()
    with td.raises(HTTPUnauthorized):
        with h.login_overlay(exceptions=['foobar']):
            raise HTTPUnauthorized()
Exemplo n.º 9
0
 def test_post_add_artifacts_other_error(self, add_artifacts):
     def on_post(chunk, **kw):
         raise pymongo.errors.InvalidDocument("Cannot encode object...")
     add_artifacts.post.side_effect = on_post
     cmd = show_models.ReindexCommand('reindex')
     cmd.options = Mock()
     with td.raises(pymongo.errors.InvalidDocument):
         cmd._post_add_artifacts(range(5))
Exemplo n.º 10
0
 def test_post_add_artifacts_other_error(self, add_artifacts):
     def on_post(chunk, **kw):
         raise pymongo.errors.InvalidDocument("Cannot encode object...")
     add_artifacts.post.side_effect = on_post
     cmd = show_models.ReindexCommand('reindex')
     cmd.options = Mock(ming_config=None)
     with td.raises(pymongo.errors.InvalidDocument):
         cmd._post_add_artifacts(list(range(5)))
Exemplo n.º 11
0
 def test_invalid_args(self):
     M.MonQTask.query.remove()
     show_models.ReindexCommand.post('--invalid-option')
     with td.raises(Exception):
         M.MonQTask.run_ready()
     task = M.MonQTask.query.get(task_name=self.task_name)
     assert_equal(task.state, 'error')
     assert_in('Error parsing args', task.result)
Exemplo n.º 12
0
def test_subproject():
    with td.raises(ToolError):
        # name exceeds 15 chars
        sp = c.project.new_subproject('test-project-nose')
    sp = c.project.new_subproject('test-proj-nose')
    spp = sp.new_subproject('spp')
    ThreadLocalORMSession.flush_all()
    sp.delete()
    ThreadLocalORMSession.flush_all()
Exemplo n.º 13
0
def test_subproject():
    with td.raises(ToolError):
        # name exceeds 15 chars
        sp = c.project.new_subproject("test-project-nose")
    sp = c.project.new_subproject("test-proj-nose")
    spp = sp.new_subproject("spp")
    ThreadLocalORMSession.flush_all()
    sp.delete()
    ThreadLocalORMSession.flush_all()
Exemplo n.º 14
0
def test_subproject():
    project = M.Project.query.get(shortname='test')
    with td.raises(ToolError):
        # name exceeds 15 chars
        sp = project.new_subproject('test-project-nose')
    sp = project.new_subproject('test-proj-nose')
    spp = sp.new_subproject('spp')
    ThreadLocalORMSession.flush_all()
    sp.delete()
    ThreadLocalORMSession.flush_all()
Exemplo n.º 15
0
 def test_invalid_args(self):
     M.MonQTask.query.remove()
     show_models.ReindexCommand.post('--invalid-option')
     try:
         with td.raises(Exception) as e:
             M.MonQTask.run_ready()
         assert_in('Error parsing args', str(e.exc))
     finally:
         # cleanup - remove bad MonQTask
         M.MonQTask.query.remove()
Exemplo n.º 16
0
def test_project():
    assert type(c.project.sidebar_menu()) == list
    assert c.project.script_name in c.project.url()
    old_proj = c.project
    h.set_context('test/sub1', neighborhood='Projects')
    assert type(c.project.sidebar_menu()) == list
    assert type(c.project.sitemap()) == list
    assert c.project.sitemap()[0].label == 'Admin'
    assert old_proj in list(c.project.parent_iter())
    h.set_context('test', 'wiki', neighborhood='Projects')
    adobe_nbhd = M.Neighborhood.query.get(name='Adobe')
    p = M.Project.query.get(shortname='adobe-1',
                            neighborhood_id=adobe_nbhd._id)
    # assert 'http' in p.url() # We moved adobe into /adobe/, not http://adobe....
    assert p.script_name in p.url()
    assert c.project.shortname == 'test'
    assert '<p>' in c.project.description_html
    c.project.uninstall_app('hello-test-mount-point')
    ThreadLocalORMSession.flush_all()

    c.project.install_app('Wiki', 'hello-test-mount-point')
    c.project.support_page = 'hello-test-mount-point'
    ThreadLocalORMSession.flush_all()
    with td.raises(ToolError):
        # already installed
        c.project.install_app('Wiki', 'hello-test-mount-point')
    ThreadLocalORMSession.flush_all()
    c.project.uninstall_app('hello-test-mount-point')
    ThreadLocalORMSession.flush_all()
    with td.raises(ToolError):
        # mount point reserved
        c.project.install_app('Wiki', 'feed')
    # Make sure the project support page is reset if the tool it was pointing
    # to is uninstalled.
    assert c.project.support_page == ''
    app_config = c.project.app_config('hello')
    app_inst = c.project.app_instance(app_config)
    app_inst = c.project.app_instance('hello')
    app_inst = c.project.app_instance('hello2123')
    c.project.breadcrumbs()
    c.app.config.breadcrumbs()
Exemplo n.º 17
0
def test_subproject():
    project = M.Project.query.get(shortname='test')
    with td.raises(ToolError):
        with patch('allura.lib.plugin.ProjectRegistrationProvider') as Provider:
            Provider.get().shortname_validator.to_python.side_effect = Invalid('name', 'value', {})
            # name doesn't validate
            sp = project.new_subproject('test-proj-nose')
    sp = project.new_subproject('test-proj-nose')
    spp = sp.new_subproject('spp')
    ThreadLocalORMSession.flush_all()
    sp.delete()
    ThreadLocalORMSession.flush_all()
Exemplo n.º 18
0
def test_subproject():
    project = M.Project.query.get(shortname="test")
    with td.raises(ToolError):
        with patch("allura.lib.plugin.ProjectRegistrationProvider") as Provider:
            Provider.get().shortname_validator.to_python.side_effect = Invalid("name", "value", {})
            # name doesn't validate
            sp = project.new_subproject("test-proj-nose")
    sp = project.new_subproject("test-proj-nose")
    spp = sp.new_subproject("spp")
    ThreadLocalORMSession.flush_all()
    sp.delete()
    ThreadLocalORMSession.flush_all()
Exemplo n.º 19
0
def test_project():
    assert type(c.project.sidebar_menu()) == list
    assert c.project.script_name in c.project.url()
    old_proj = c.project
    h.set_context('test/sub1', neighborhood='Projects')
    assert type(c.project.sidebar_menu()) == list
    assert type(c.project.sitemap()) == list
    assert c.project.sitemap()[0].label == 'Admin'
    assert old_proj in list(c.project.parent_iter())
    h.set_context('test', 'wiki', neighborhood='Projects')
    adobe_nbhd = M.Neighborhood.query.get(name='Adobe')
    p = M.Project.query.get(shortname='adobe-1', neighborhood_id=adobe_nbhd._id)
    # assert 'http' in p.url() # We moved adobe into /adobe/, not http://adobe....
    assert p.script_name in p.url()
    assert c.project.shortname == 'test'
    assert '<p>' in c.project.description_html
    c.project.uninstall_app('hello-test-mount-point')
    ThreadLocalORMSession.flush_all()

    c.project.install_app('Wiki', 'hello-test-mount-point')
    c.project.support_page = 'hello-test-mount-point'
    ThreadLocalORMSession.flush_all()
    with td.raises(ToolError):
        # already installed
        c.project.install_app('Wiki', 'hello-test-mount-point')
    ThreadLocalORMSession.flush_all()
    c.project.uninstall_app('hello-test-mount-point')
    ThreadLocalORMSession.flush_all()
    with td.raises(ToolError):
        # mount point reserved
        c.project.install_app('Wiki', 'feed')
    # Make sure the project support page is reset if the tool it was pointing
    # to is uninstalled.
    assert c.project.support_page == ''
    app_config = c.project.app_config('hello')
    app_inst = c.project.app_instance(app_config)
    app_inst = c.project.app_instance('hello')
    app_inst = c.project.app_instance('hello2123')
    c.project.breadcrumbs()
    c.app.config.breadcrumbs()
Exemplo n.º 20
0
def test_extensions_cm():
    session = mock.Mock(_kwargs=dict(extensions=[]))
    extension = mock.Mock()
    with td.raises(ValueError):
        with substitute_extensions(session, [extension]) as sess:
            assert session.flush.call_count == 1
            assert session.close.call_count == 1
            assert sess == session
            assert sess._kwargs['extensions'] == [extension]
            raise ValueError('test')
    assert session.flush.call_count == 2
    assert session.close.call_count == 2
    assert session._kwargs['extensions'] == []
Exemplo n.º 21
0
def test_install_app_validates_options():
    from forgetracker.tracker_main import ForgeTrackerApp
    name = 'TicketMonitoringEmail'
    opt = [o for o in ForgeTrackerApp.config_options if o.name == name][0]
    opt.validator = fev.Email(not_empty=True)
    with patch.object(ForgeTrackerApp, 'config_on_install', new=[opt.name]):
        for v in [None, '', 'bad@email']:
            with td.raises(ToolError):
                c.project.install_app('Tickets', 'test-tickets', **{name: v})
            assert_equals(c.project.app_instance('test-tickets'), None)
        c.project.install_app('Tickets', 'test-tickets', **{name: '*****@*****.**'})
        app = c.project.app_instance('test-tickets')
        assert_equals(app.config.options[name], '*****@*****.**')
Exemplo n.º 22
0
def test_install_app_validates_options():
    from forgetracker.tracker_main import ForgeTrackerApp
    name = 'TicketMonitoringEmail'
    opt = [o for o in ForgeTrackerApp.config_options if o.name == name][0]
    opt.validator = fev.Email(not_empty=True)
    with patch.object(ForgeTrackerApp, 'config_on_install', new=[opt.name]):
        for v in [None, '', 'bad@email']:
            with td.raises(ToolError):
                c.project.install_app('Tickets', 'test-tickets', **{name: v})
            assert_equals(c.project.app_instance('test-tickets'), None)
        c.project.install_app('Tickets', 'test-tickets', **{name: '*****@*****.**'})
        app = c.project.app_instance('test-tickets')
        assert_equals(app.config.options[name], '*****@*****.**')
Exemplo n.º 23
0
def test_extensions_cm_flush_raises():
    session = mock.Mock(_kwargs=dict(extensions=[]))
    extension = mock.Mock()
    with td.raises(AttributeError):
        with substitute_extensions(session, [extension]) as sess:
            session.flush.side_effect = AttributeError
            assert session.flush.call_count == 1
            assert session.close.call_count == 1
            assert sess == session
            assert sess._kwargs['extensions'] == [extension]
    assert session.flush.call_count == 2
    assert session.close.call_count == 1
    assert session._kwargs['extensions'] == []
Exemplo n.º 24
0
def test_extensions_cm_flush_raises():
    session = mock.Mock(_kwargs=dict(extensions=[]))
    extension = mock.Mock()
    with td.raises(AttributeError):
        with substitute_extensions(session, [extension]) as sess:
            session.flush.side_effect = AttributeError
            assert session.flush.call_count == 1
            assert session.close.call_count == 1
            assert sess == session
            assert sess._kwargs['extensions'] == [extension]
    assert session.flush.call_count == 2
    assert session.close.call_count == 1
    assert session._kwargs['extensions'] == []
Exemplo n.º 25
0
def test_install_app_validates_options():
    from forgetracker.tracker_main import ForgeTrackerApp

    name = "TicketMonitoringEmail"
    opt = [o for o in ForgeTrackerApp.config_options if o.name == name][0]
    opt.validator = fev.Email(not_empty=True)
    with patch.object(ForgeTrackerApp, "config_on_install", new=[opt.name]):
        for v in [None, "", "bad@email"]:
            with td.raises(ToolError):
                c.project.install_app("Tickets", "test-tickets", **{name: v})
            assert_equals(c.project.app_instance("test-tickets"), None)
        c.project.install_app("Tickets", "test-tickets", **{name: "*****@*****.**"})
        app = c.project.app_instance("test-tickets")
        assert_equals(app.config.options[name], "*****@*****.**")
Exemplo n.º 26
0
def test_subproject():
    project = M.Project.query.get(shortname='test')
    with td.raises(ToolError):
        with patch(
                'allura.lib.plugin.ProjectRegistrationProvider') as Provider:
            Provider.get().shortname_validator.to_python.side_effect = Invalid(
                'name', 'value', {})
            # name doesn't validate
            sp = project.new_subproject('test-proj-nose')
    sp = project.new_subproject('test-proj-nose')
    spp = sp.new_subproject('spp')
    ThreadLocalORMSession.flush_all()
    sp.delete()
    ThreadLocalORMSession.flush_all()
Exemplo n.º 27
0
    def test_login_overlay(self, c, require_access, request):
        pi = base.ProjectImporter(mock.Mock())
        require_access.side_effect = HTTPUnauthorized

        c.show_login_overlay = False
        request.path = '/test-importer/'
        pi._check_security()
        self.assertEqual(c.show_login_overlay, True)

        c.show_login_overlay = False
        request.path = '/test-importer/check_names/'
        pi._check_security()
        self.assertEqual(c.show_login_overlay, True)

        c.show_login_overlay = False
        request.path = '/test-importer/process/'
        with td.raises(HTTPUnauthorized):
            pi._check_security()
        self.assertEqual(c.show_login_overlay, False)
Exemplo n.º 28
0
    def test_login_overlay(self, c, require_access, request):
        pi = base.ProjectImporter(mock.Mock())
        require_access.side_effect = HTTPUnauthorized

        c.show_login_overlay = False
        request.path = '/test-importer/'
        pi._check_security()
        self.assertEqual(c.show_login_overlay, True)

        c.show_login_overlay = False
        request.path = '/test-importer/check_names/'
        pi._check_security()
        self.assertEqual(c.show_login_overlay, True)

        c.show_login_overlay = False
        request.path = '/test-importer/process/'
        with td.raises(HTTPUnauthorized):
            pi._check_security()
        self.assertEqual(c.show_login_overlay, False)
Exemplo n.º 29
0
 def test_oauth_callback_complete(self):
     with patch.object(self.mix, 'oauth_callback_complete') as _mock, raises(HTTPFound):
         self.mix.oauth_callback()
     self.assertEqual(_mock.call_count, 1)
Exemplo n.º 30
0
 def test_not_readable(self):
     self.readable_mock.return_value = False
     with td.raises(Invalid):
         GoogleCodeProjectNameValidator()._to_python('gmapcatcher')
Exemplo n.º 31
0
 def test_oauth_callback_complete(self):
     with patch.object(
             self.mix,
             'oauth_callback_complete') as _mock, raises(HTTPFound):
         self.mix.oauth_callback()
     self.assertEqual(_mock.call_count, 1)
Exemplo n.º 32
0
 def test__post_other_error(self, index_tasks):
     def on_post(chunk):
         raise pymongo.errors.InvalidDocument("Cannot encode object...")
     index_tasks.add_artifacts.post.side_effect = on_post
     with td.raises(pymongo.errors.InvalidDocument):
         self.ext._post(index_tasks.add_artifacts, range(5))
Exemplo n.º 33
0
 def test_invalid_args(self):
     M.MonQTask.query.remove()
     show_models.ReindexCommand.post('--invalid-option')
     with td.raises(Exception) as e:
         M.MonQTask.run_ready()
     assert_in('Error parsing args', str(e.exc))