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)
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): from arche.resources import User from arche.resources import Document root = barebone_fixture(self.config) root['users']['jane'] = User() root['doc'] = Document() return root
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')
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
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)
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")
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
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)
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')
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))
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
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)
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
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 _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
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
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)
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
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)))
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)
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)
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)
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)
def test_adapter_registration(self): root = barebone_fixture(self.config) self.failUnless(ITranslations(root, None))
def _mk_instance(self): context = barebone_fixture(self.config) request = testing.DummyRequest() return self._cut(context, request)
def test_registration(self): self.config.include('arche_pas_social') root = barebone_fixture(self.config) self.failUnless(self.config.registry.queryAdapter(root, IProviderMapper))
def _fixture(self): root = barebone_fixture(self.config) request = testing.DummyRequest() apply_request_extensions(request) request.root = root return root, request
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?")
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')
def _fixture(self): from arche.resources import User root = barebone_fixture(self.config) root['users']['jane'] = User(email = '*****@*****.**') return root
def _fixture(self): root = barebone_fixture(self.config) question_fixture(root) return root
def _fixture(self): self.config.include('arche.testing') self.config.include('arche.models.catalog') return barebone_fixture(self.config)
def test_registration(self): self.config.include('arche_pas_social') root = barebone_fixture(self.config) self.failUnless( self.config.registry.queryAdapter(root, IProviderMapper))