Пример #1
0
 def _mk_view(self, action = '', tag = 'testing', uid = 'uid' ,is_xhr = True):
     root = barebone_fixture(self.config)
     root['context'] = context = DummyContext()
     matchdict = {'action': action, 'tag': tag, 'uid': uid}
     request = testing.DummyRequest(matchdict = matchdict, is_xhr = is_xhr)
     request.root = root
     return self._cut(context, request)
Пример #2
0
 def test_add(self):
     root = barebone_fixture(self.config)
     obj = self._cut(root)
     obj.add('userid', 'dummy_service', 'identifier')
     self.assertIn('userid', obj.userid_to_services)
     self.assertIn(('dummy_service', 'identifier'),
                   obj.service_identifier_to_userid)
Пример #3
0
 def _fixture(self):
     from arche.resources import User
     from arche.resources import Document
     root = barebone_fixture(self.config)
     root['users']['jane'] = User()
     root['doc'] = Document()
     return root
Пример #4
0
 def test_login(self):
     self.config.include('arche_pas_social')
     root = barebone_fixture(self.config)
     obj = self._cut(root)
     obj.name = 'dummy_service'
     self.assertEqual(obj.login('404'), None)
     mapper = IProviderMapper(root)
     mapper.add('userid', 'dummy_service', 'identifier')
     self.assertEqual(obj.login('identifier'), 'userid')
Пример #5
0
 def test_login(self):
     self.config.include('arche_pas_social')
     root = barebone_fixture(self.config)
     obj = self._cut(root)
     obj.name = 'dummy_service'
     self.assertEqual(obj.login('404'), None)
     mapper = IProviderMapper(root)
     mapper.add('userid', 'dummy_service', 'identifier')
     self.assertEqual(obj.login('identifier'), 'userid')
Пример #6
0
 def _fixture(self):
     from arche.resources import User
     root = barebone_fixture(self.config)
     root['users']['jane'] = User(email = '*****@*****.**')
     request = testing.DummyRequest()
     apply_request_extensions(request)
     self.config.begin(request)
     request.root = root
     return root, request
Пример #7
0
 def test_get_profile(self):
     request = testing.DummyRequest()
     root = barebone_fixture(self.config)
     from arche.api import User
     root['users']['jeff'] = jeff = User()
     request.root = root
     self.assertEqual(self._fut(request), None)
     self.config.testing_securitypolicy(userid = 'jeff')
     self.assertEqual(self._fut(request), jeff)
Пример #8
0
 def test_update_stores_data(self):
     root = barebone_fixture(self.config)
     self.config.add_versioning(IContent, ['title'])
     root['a'] = context = _DummyContent(title = "What's up?")
     obj = IRevisions(context, {})
     context.update(title = "Hello world")
     obj = IRevisions(context)
     self.assertEqual(len(obj), 2)
     self.assertEqual(obj[1]['title'], "Hello world")
Пример #9
0
 def _fixture(self):
     self.config.include('arche.testing')
     self.config.include('arche.plugins.request_auth')
     root = barebone_fixture(self.config)
     root['users']['robot'] = User()
     root['users']['jane'] = User()
     self.request.root = root
     init_request_methods(self.request)
     return root
Пример #10
0
 def test_resolve_uid(self):
     self.config.include('arche.testing')
     self.config.include('arche.testing.catalog')
     root = barebone_fixture(self.config)
     from arche.api import Content
     obj = Content(uid = 'hello')
     root['o'] = obj
     request = testing.DummyRequest()
     request.root = root
     self.assertEqual(self._cut(request, 'hello'), obj)
Пример #11
0
 def test_register_and_call_behaviour_are_the_same(self):
     from arche_ttw_translation.models import Translatable
     t = Translatable()
     t('one', 'One')
     t('Two')
     self.config.register_ttwt(t)
     root = barebone_fixture(self.config)
     tr = ITranslations(root)
     self.assertEqual(tr('one', 'One'), 'One')
     self.assertEqual(tr('Two'), 'Two')
Пример #12
0
 def test_get_image_tag(self):
     self.config.include('voteit.core.plugins.gravatar_profile_image')
     root = barebone_fixture()
     request = testing.DummyRequest()
     request.root = root
     root['users']['jane'] = obj = self._make_obj()
     obj.set_field_value('email', '*****@*****.**')
     self.assertEqual(
         '<img src="https://secure.gravatar.com/avatar/4b3cdf9adfc6258a102ab90eb64565ea?s=45&d=robohash" height="45" width="45" class="profile-pic" />',
         obj.get_image_tag(size=45, request=request))
Пример #13
0
 def _fixture(self):
     from arche_comments.models.comments import CommentsFolder
     root = barebone_fixture()
     root['users']['a'] = User(email='*****@*****.**')
     root['_comments'] = CommentsFolder()
     request = testing.DummyRequest()
     apply_request_extensions(request)
     request.root = root
     self.config.begin(request)
     return root, request
Пример #14
0
 def test_register_and_call_behaviour_are_the_same(self):
     from arche_ttw_translation.models import Translatable
     t = Translatable()
     t('one', 'One')
     t('Two')
     self.config.register_ttwt(t)
     root = barebone_fixture(self.config)
     tr = ITranslations(root)
     self.assertEqual(tr('one', 'One'), 'One')
     self.assertEqual(tr('Two'), 'Two')
Пример #15
0
 def test_remove_unknown_identifier(self):
     root = barebone_fixture(self.config)
     obj = self._cut(root)
     obj.add('userid', 'dummy_service', 'identifier')
     obj.add('userid', 'd1', 'i1')
     obj.add('userid', 'd2', 'i2')
     obj.remove('userid', 'd2')
     self.assertIn(('dummy_service', 'identifier'), obj.service_identifier_to_userid)
     self.assertIn(('d1', 'i1'), obj.service_identifier_to_userid)
     self.assertNotIn(('d2', 'i2'), obj.service_identifier_to_userid)
Пример #16
0
 def _fixture(self):
     self.config.include("arche.testing")
     self.config.include("arche.testing.catalog")
     self.config.include("arche.models.workflow")
     self.config.include("betahaus.viewcomponent")
     self.config.include("arche_m2m")
     self.config.include("m2m_feedback")
     root = barebone_fixture(self.config)
     question_fixture(root)
     _fixture_feedback_section(root)
     return root
Пример #17
0
 def test_cleanup_on_user_delete(self):
     from arche.api import User
     self.config.include('arche_pas_social.models')
     root = barebone_fixture(self.config)
     users = root['users']
     users['userid'] = User()
     obj = self._cut(root)
     obj.add('userid', 'dummy_service', 'identifier')
     del users['userid']
     self.assertNotIn(('dummy_service', 'identifier'), obj.service_identifier_to_userid)
     self.assertNotIn('userid', obj.userid_to_services)
Пример #18
0
 def test_remove_unknown_identifier(self):
     root = barebone_fixture(self.config)
     obj = self._cut(root)
     obj.add('userid', 'dummy_service', 'identifier')
     obj.add('userid', 'd1', 'i1')
     obj.add('userid', 'd2', 'i2')
     obj.remove('userid', 'd2')
     self.assertIn(('dummy_service', 'identifier'),
                   obj.service_identifier_to_userid)
     self.assertIn(('d1', 'i1'), obj.service_identifier_to_userid)
     self.assertNotIn(('d2', 'i2'), obj.service_identifier_to_userid)
Пример #19
0
 def _fixture(self):
     self.config.include('arche.testing')
     self.config.include('arche.testing.catalog')
     self.config.include('arche.testing.workflow')
     self.config.set_content_workflow('User', 'simple_workflow')
     root = barebone_fixture(self.config)
     from arche.api import User
     root['a'] = User()
     root['b'] = User()
     request = testing.DummyRequest()
     request.root = root
     return root, request
Пример #20
0
 def _fixture(self):
     from arche.resources import Document
     root = barebone_fixture(self.config)
     root['source'] = source = Document()
     source['a'] = Document()
     source['a']['b'] = Document()
     root['target'] = Document()
     request = testing.DummyRequest()
     request.root = root
     apply_request_extensions(request)
     self.config.begin(request)
     return root, request
Пример #21
0
 def test_cleanup_on_user_delete(self):
     from arche.api import User
     self.config.include('arche_pas_social.models')
     root = barebone_fixture(self.config)
     users = root['users']
     users['userid'] = User()
     obj = self._cut(root)
     obj.add('userid', 'dummy_service', 'identifier')
     del users['userid']
     self.assertNotIn(('dummy_service', 'identifier'),
                      obj.service_identifier_to_userid)
     self.assertNotIn('userid', obj.userid_to_services)
 def test_get_questions(self):
     self.config.include('arche.testing')
     self.config.include('arche.testing.catalog')
     self.config.include('arche.testing.workflow')
     self.config.include('betahaus.viewcomponent')
     self.config.include('arche_m2m')
     root = barebone_fixture(self.config)
     question_fixture(root)
     root['survey_section'] = obj = self._cut()
     obj.question_ids = ['q_cluster', 'q_cluster2', 'q_cluster3']
     self.assertEqual(len(obj.get_questions(None)), 4) #All
     self.assertEqual(len(obj.get_questions('en')), 1)
     self.assertEqual(len(obj.get_questions('sv')), 3)
Пример #23
0
 def _fixture(self):
     self.config.include('arche.testing.catalog')
     self.config.include('voteit.core.models.catalog')
     self.config.include('voteit.core.testing_helpers.register_workflows')
     self.config.include('voteit.core.helpers')
     self.config.include('voteit.core.models.read_names')
     from voteit.core.models.meeting import Meeting
     request = testing.DummyRequest()
     root = barebone_fixture(self.config)
     request.root = root
     apply_request_extensions(request)
     self.config.begin(request)
     root['m'] = request.meeting = Meeting()
     return root['m'], request
Пример #24
0
 def test_recheck_voters(self):
     self.config.include('arche.testing')
     self.config.include('arche.testing.catalog')
     self.config.include('arche.testing.workflow')
     self.config.include('voteit.multiple_votes.resources')
     root = barebone_fixture()
     root['m'] = m = Meeting()
     m[MEETING_NAMESPACE] = obj = self._cut()
     lr = m.local_roles
     lr.add('someone', ROLE_VOTER)
     obj['a'] = a = self._VA(userid_assigned='a', votes=2)
     obj['b'] = b = self._VA(userid_assigned='b', votes=4)
     obj.recheck_voters()
     self.assertEqual({'a', 'b'}, set(lr.get_any_local_with(ROLE_VOTER)))
Пример #25
0
 def _fixture(self):
     self.config.include('arche.testing.catalog')
     self.config.include('voteit.core.models.catalog')
     self.config.include('voteit.core.testing_helpers.register_workflows')
     self.config.include('voteit.core.helpers')
     self.config.include('voteit.core.models.read_names')
     from voteit.core.models.meeting import Meeting
     request = testing.DummyRequest()
     root = barebone_fixture(self.config)
     request.root = root
     apply_request_extensions(request)
     self.config.begin(request)
     root['m'] = request.meeting = Meeting()
     return root['m'], request
Пример #26
0
    def setUp(self):
        self.config = testing.setUp()
        self.config.include('arche.testing')
        self.config.include('arche.testing.catalog')
        self.config.include('arche.testing.workflow')
        self.config.registry.settings['arche_celery.ini'] = CONFIG_INI_TESTS
        self.config.include('arche_celery')
        self.root = barebone_fixture(self.config)
        request = testing.DummyRequest()
        apply_request_extensions(request)
        self.config.begin(request)
        global_registries.add(self.config.registry)

        def _root_fact(*args):
            return self.root

        self.config.set_root_factory(_root_fact)
Пример #27
0
 def test_integration_read_count(self):
     from voteit.core.models.meeting import Meeting
     self.config.include('arche.testing.catalog')
     self.config.include('voteit.core.models.catalog')
     self.config.include('voteit.core.testing_helpers.register_workflows')
     self.config.include('voteit.core.helpers')
     self.config.include('voteit.core.models.read_names')
     request = testing.DummyRequest()
     root = barebone_fixture(self.config)
     request.root = root
     apply_request_extensions(request)
     self.config.begin(request)
     root['m'] = meeting = Meeting()
     self.assertEqual(request.get_read_count(meeting, 'Proposal', 'frej'), 0)
     obj = self._cut(meeting, request)
     obj.change('Dummy', 3, 'frej')
     self.assertEqual(obj.get_read_count('Dummy', 'frej'), 3)
     self.assertEqual(request.get_read_count(meeting, 'Dummy', 'frej'), 3)
Пример #28
0
 def test_integration_read_count(self):
     from voteit.core.models.meeting import Meeting
     self.config.include('arche.testing.catalog')
     self.config.include('voteit.core.models.catalog')
     self.config.include('voteit.core.testing_helpers.register_workflows')
     self.config.include('voteit.core.helpers')
     self.config.include('voteit.core.models.read_names')
     request = testing.DummyRequest()
     root = barebone_fixture(self.config)
     request.root = root
     apply_request_extensions(request)
     self.config.begin(request)
     root['m'] = meeting = Meeting()
     self.assertEqual(request.get_read_count(meeting, 'Proposal', 'frej'),
                      0)
     obj = self._cut(meeting, request)
     obj.change('Dummy', 3, 'frej')
     self.assertEqual(obj.get_read_count('Dummy', 'frej'), 3)
     self.assertEqual(request.get_read_count(meeting, 'Dummy', 'frej'), 3)
Пример #29
0
 def test_voter_count_subscriber(self):
     self.config.include('arche.testing')
     self.config.include('arche.testing.catalog')
     self.config.include('arche.testing.workflow')
     self.config.include('voteit.multiple_votes.resources')
     root = barebone_fixture()
     root['m'] = m = Meeting()
     m[MEETING_NAMESPACE] = obj = self._cut()
     self.assertEqual(0, obj.total_voters)
     obj['a1'] = a1 = self._VA(userid_assigned='a', votes=1)
     self.assertEqual(1, obj.total_voters)
     obj['a2'] = a2 = self._VA(userid_assigned='a', votes=2)
     self.assertEqual(1, obj.total_voters)
     obj['b1'] = b1 = self._VA(userid_assigned='b', votes=4)
     self.assertEqual(2, obj.total_voters)
     del obj['b1']
     self.assertEqual(1, obj.total_voters)
     a1.update(userid_assigned='c')
     self.assertEqual(2, obj.total_voters)
Пример #30
0
    def setUp(self):
        self.config = testing.setUp()
        self.config.include('arche.testing')
        self.config.include('arche.testing.catalog')
        self.config.include('arche.testing.workflow')
        self.config.registry.settings['arche_celery.ini'] = CONFIG_INI_TESTS
        self.config.include('arche_celery')
        self.root = barebone_fixture(self.config)
        request = testing.DummyRequest()
        request.root = self.root
        apply_request_extensions(request)
        self.request = request
        self.config.begin(request)
        #Need to make registry accessible for worker.
        #This may change in pyramid
        global_registries.add(self.config.registry)

        def _root_fact(*args):
            return self.root

        self.config.set_root_factory(_root_fact)
Пример #31
0
 def test_adapter_registration(self):
     root = barebone_fixture(self.config)
     self.failUnless(ITranslations(root, None))
Пример #32
0
 def _mk_instance(self):
     context = barebone_fixture(self.config)
     request = testing.DummyRequest()
     return self._cut(context, request)
Пример #33
0
 def test_registration(self):
     self.config.include('arche_pas_social')
     root = barebone_fixture(self.config)
     self.failUnless(self.config.registry.queryAdapter(root, IProviderMapper))
Пример #34
0
 def test_add(self):
     root = barebone_fixture(self.config)
     obj = self._cut(root)
     obj.add('userid', 'dummy_service', 'identifier')
     self.assertIn('userid', obj.userid_to_services)
     self.assertIn(('dummy_service', 'identifier'), obj.service_identifier_to_userid)
 def _fixture(self):
     root = barebone_fixture(self.config)
     request = testing.DummyRequest()
     apply_request_extensions(request)
     request.root = root
     return root, request
Пример #36
0
 def test_add_stores_data(self):
     root = barebone_fixture(self.config)
     self.config.add_versioning(IContent, ['title'])
     root['a'] = context = _DummyContent(title = "What's up?")
     obj = IRevisions(context, {})
     self.assertEqual(obj[0]['title'], "What's up?")
Пример #37
0
 def test_adapter_registration(self):
     root = barebone_fixture(self.config)
     self.failUnless(ITranslations(root, None))
Пример #38
0
 def test_remove_nonexistent(self):
     root = barebone_fixture(self.config)
     obj = self._cut(root)
     obj.remove('userid', 'dummy_service', 'identifier')
     obj.add('userid', 'd1', 'i1')
     obj.remove('userid', 'dummy_service', 'identifier')
Пример #39
0
 def _fixture(self):
     from arche.resources import User
     root = barebone_fixture(self.config)
     root['users']['jane'] = User(email = '*****@*****.**')
     return root
Пример #40
0
 def _fixture(self):
     root = barebone_fixture(self.config)
     request = testing.DummyRequest()
     apply_request_extensions(request)
     request.root = root
     return root, request
Пример #41
0
 def _fixture(self):
     root = barebone_fixture(self.config)
     question_fixture(root)
     return root
Пример #42
0
 def test_remove_nonexistent(self):
     root = barebone_fixture(self.config)
     obj = self._cut(root)
     obj.remove('userid', 'dummy_service', 'identifier')
     obj.add('userid', 'd1', 'i1')
     obj.remove('userid', 'dummy_service', 'identifier')
Пример #43
0
 def _fixture(self):
     self.config.include('arche.testing')
     self.config.include('arche.models.catalog')
     return barebone_fixture(self.config)
Пример #44
0
 def test_registration(self):
     self.config.include('arche_pas_social')
     root = barebone_fixture(self.config)
     self.failUnless(
         self.config.registry.queryAdapter(root, IProviderMapper))