def _fixture(self): self.config.include('madetomeasure') root = bootstrap_root() from madetomeasure.models.organisation import Organisation from madetomeasure.views.base import BaseView root['org'] = Organisation(title = 'Hello org') return BaseView(root, testing.DummyRequest())
def test_get_security(self): from madetomeasure.models.app import bootstrap_root self.config.scan('betahaus.pyracont.fields.password') obj = bootstrap_root() self.assertEqual(obj.get_security(), [{'userid': 'admin', 'groups': ('role:Admin',)}]) obj.set_groups('admin', ['role:Admin', 'group:Hipsters']) self.assertEqual(obj.get_security(), [{'userid': 'admin', 'groups': ('group:Hipsters', 'role:Admin')}])
def _fixture(config): from madetomeasure.models.app import bootstrap_root from madetomeasure.models.questions import Question config.scan('betahaus.pyracont.fields.password') root = bootstrap_root() root['questions']['q1'] = Question() root['questions']['q2'] = Question() return root
def test_questions(self): from madetomeasure.models.questions import Question self.config.scan('betahaus.pyracont.fields.password') root = bootstrap_root() root['o'] = obj = self._cut() obj['questions']['q1'] = Question() root['questions']['q2'] = Question() self.assertEqual(obj.questions.keys(), [u'q1', u'q2'])
def _fixture(config, obj): from madetomeasure.models.app import bootstrap_root config.scan('betahaus.pyracont.fields.password') config.include('madetomeasure.models.question_widgets') root = bootstrap_root() root['questions']['test_q'] = obj obj.set_question_type('free_text_question') #bootstrap_root creates this return obj
def _fixture(config): config.scan('betahaus.pyracont.fields.password') from madetomeasure.models.app import bootstrap_root from madetomeasure.models.questions import Question from madetomeasure.models.organisation import Organisation from madetomeasure.models.surveys import Survey from madetomeasure.models.survey_section import SurveySection root = bootstrap_root() root['questions']['q1'] = Question() root['questions']['q2'] = Question() root['o1'] = o1 = Organisation() o1['surveys']['s1'] = s1 = Survey() s1['ss1'] = ss1 = SurveySection() ss1.set_field_value('question_ids', ['q1', 'q2']) return root
def test_question_variant(self): self.config.scan('betahaus.pyracont.fields.password') from madetomeasure.interfaces import IQuestionTranslations from madetomeasure.models.translations import QuestionTranslations settings = dict(default_locale_name='en', available_languages='en sv de ru',) trans_util = QuestionTranslations(settings) self.config.registry.registerUtility(trans_util, IQuestionTranslations) root = bootstrap_root() from madetomeasure.models.organisation import Organisation root['org'] = org = Organisation() root['questions']['test_q'] = obj = self._cut(title = "Hello world") self.assertEqual(obj.get_title(), u"Hello world") self.assertEqual(obj.get_title(lang='en'), u"Hello world") self.assertEqual(obj.get_title(lang='sv'), u"Hello world") org.set_variant(obj.__name__, 'sv', u'Hej världen') self.assertNotEqual(obj.get_title(lang='sv', context=org), u"Hello world") self.assertEqual(obj.get_title(lang='sv', context=org), u"Hej världen") org.set_variant(obj.__name__, 'en', u'Gday world') self.assertNotEqual(obj.get_title(context=org), u"Hello world") self.assertEqual(obj.get_title(context=org), u"Gday world")