Example #1
0
 def addSurvey(self, country, language, title):
     from euphorie.content.survey import Survey
     from euphorie.client.sector import ClientSector
     if "sector" not in country:
         country["sector"] = ClientSector()
         country["sector"].title = u"Test sector"
         country["sector"].id = "sector"
     sector = country["sector"]
     survey = Survey()
     survey.title = title
     survey.id = language
     survey.language = language
     sector[language] = survey
     return survey
Example #2
0
 def addSurvey(self, country, language, title):
     from euphorie.content.survey import Survey
     from euphorie.client.sector import ClientSector
     if "sector" not in country:
         country["sector"] = ClientSector()
         country["sector"].title = u"Test sector"
         country["sector"].id = "sector"
     sector = country["sector"]
     survey = Survey()
     survey.title = title
     survey.id = language
     survey.language = language
     sector[language] = survey
     return survey
Example #3
0
 def test_ignore_non_survey_child(self):
     from zope.publisher.browser import TestRequest
     from euphorie.ghost import PathGhost
     from euphorie.client.sector import ClientSector
     sector = ClientSector(id='ict', title=u'ICT')
     sector['gaming'] = PathGhost('gaming')
     response = self.View(sector, TestRequest()).do_GET()
     self.assertEqual(response['surveys'], [])
Example #4
0
 def setUp(self):
     super(TestURLs, self).setUp()
     self.loginAsPortalOwner()
     self.client = self.portal.client
     # Set locals
     request = testRequest()
     locals.request = request
     # Add survey
     self.client['en'] = ClientCountry('en')
     country = self.client['en']
     country["sector"] = ClientSector('sector')
     country["sector"].title = u"Test sector"
     country["sector"].id = "sector"
     sector = country["sector"]
     survey = Survey('survey')
     survey.title = u'Test Survey'
     survey.language = 'en'
     sector['survey'] = survey
Example #5
0
 def test_plain_view(self):
     from zope.publisher.browser import TestRequest
     from euphorie.client.sector import ClientSector
     sector = ClientSector(id='ict', title=u'ICT')
     response = self.View(sector, TestRequest()).do_GET()
     self.assertTrue(isinstance(response, dict))
     self.assertEqual(set(response), set(['id', 'title', 'surveys']))
     self.assertEqual(response['id'], 'ict')
     self.assertEqual(response['title'], u'ICT')
     self.assertEqual(response['surveys'], [])
Example #6
0
 def setUp(self):
     super(TestURLs, self).setUp()
     self.loginAsPortalOwner()
     self.client = self.portal.client
     # Set locals
     request = testRequest()
     locals.request = request
     # Add survey
     self.client['en'] = ClientCountry('en')
     country = self.client['en']
     country["sector"] = ClientSector('sector')
     country["sector"].title = u"Test sector"
     country["sector"].id = "sector"
     sector = country["sector"]
     survey = Survey('survey')
     survey.title = u'Test Survey'
     survey.introduction = u"This is a survey that is well suited for tests"
     survey.language = 'en'
     sector['survey'] = survey
Example #7
0
 def test_survey_info_filter_by_language(self):
     from zope.publisher.browser import TestRequest
     from euphorie.content.survey import Survey
     from euphorie.client.sector import ClientSector
     sector = ClientSector(id='ict', title=u'ICT')
     sector['gaming'] = Survey(id='gaming', title=u'Gaming', language='nl')
     request = TestRequest()
     request.form['language'] = 'en'
     response = self.View(sector, request).do_GET()
     self.assertEqual(len(response['surveys']), 0)
     request.form['language'] = 'nl'
     response = self.View(sector, request).do_GET()
     self.assertEqual(len(response['surveys']), 1)
Example #8
0
 def test_standard_session_info(self):
     from zope.publisher.browser import TestRequest
     from euphorie.client.country import ClientCountry
     from euphorie.client.sector import ClientSector
     country = ClientCountry(id='nl', title=u'The Netherlands',
             country_type='eu-member')
     country['ict'] = ClientSector(id='ict', title=u'ICT')
     response = self.View(country, TestRequest()).do_GET()
     self.assertEqual(len(response['sectors']), 1)
     sector_info = response['sectors'][0]
     self.assertTrue(isinstance(sector_info, dict))
     self.assertEqual(set(sector_info), set(['id', 'title']))
     self.assertEqual(sector_info['id'], 'ict')
     self.assertEqual(sector_info['title'], 'ICT')
Example #9
0
 def test_survey_info(self):
     from zope.publisher.browser import TestRequest
     from euphorie.content.survey import Survey
     from euphorie.client.sector import ClientSector
     sector = ClientSector(id='ict', title=u'ICT')
     sector['gaming'] = Survey(id='gaming', title=u'Gaming', language='nl')
     response = self.View(sector, TestRequest()).do_GET()
     self.assertEqual(len(response['surveys']), 1)
     survey_info = response['surveys'][0]
     self.assertTrue(isinstance(survey_info, dict))
     self.assertEqual(set(survey_info), set(['id', 'title', 'language']))
     self.assertEqual(survey_info['id'], 'gaming')
     self.assertEqual(survey_info['title'], u'Gaming')
     self.assertEqual(survey_info['language'], 'nl')
Example #10
0
 def test_detailed_session_info(self):
     import mock
     from zope.publisher.browser import TestRequest
     from euphorie.client.country import ClientCountry
     from euphorie.client.sector import ClientSector
     country = ClientCountry(id='nl', title=u'The Netherlands',
             country_type='eu-member')
     country['ict'] = ClientSector(id='ict', title=u'ICT')
     request = TestRequest()
     request.form['details'] = ''
     with mock.patch('euphorie.client.api.sector.View.do_GET') \
             as mock_sector_view:
         mock_sector_view.return_value = 'sector-detailed-info'
         response = self.View(country, request).do_GET()
         self.assertEqual(response['sectors'], ['sector-detailed-info'])
Example #11
0
 def setUp(self):
     super(TestURLs, self).setUp()
     # Set locals
     request = testRequest()
     locals.request = request
     self.loginAsPortalOwner()
     self.client = self.portal.client
     # Add survey
     self.client._setOb("en", ClientCountry("en"))
     country = self.client["en"]
     country._setOb("sector", ClientSector("sector"))
     country["sector"].title = "Test sector"
     country["sector"].id = "sector"
     sector = country["sector"]
     survey = Survey("survey")
     survey.title = "Test Survey"
     survey.introduction = "This is a survey that is well suited for tests"
     survey.language = "en"
     sector._setOb("survey", survey)