def setUp(self): # pylint: disable=invalid-name,missing-docstring super(ProjectAdviceTipsTestCase, self).setUp() self._db.advice_modules.insert_one({ 'adviceId': 'other-work-env', 'isReadyForProd': True, 'triggerScoringModel': 'constant(3)', 'tipTemplateIds': ['tip1', 'tip2'], }) self._db.tip_templates.insert_many([ { '_id': 'tip1', 'actionTemplateId': 'tip1', 'title': 'First tip', }, { '_id': 'tip2', 'actionTemplateId': 'tip2', 'title': 'Second tip', }, ]) server.clear_cache() self.user_id, self.auth_token = self.create_user_with_token( modifiers=[base_test.add_project], advisor=True) user_info = self.get_user_info(self.user_id, self.auth_token) self.project_id = user_info['projects'][0]['projectId'] user_info['projects'][0]['advices'][0]['status'] = 'ADVICE_ACCEPTED' self.json_from_response(self.app.post( '/api/user', data=json.dumps(user_info), content_type='application/json', headers={'Authorization': 'Bearer ' + self.auth_token}))
def setUp(self): # pylint: disable=invalid-name,missing-docstring super(MigrateAdvisorEndpointTestCase, self).setUp() self._db.advice_modules.insert_many([ { 'adviceId': 'spontaneous-application', 'isReadyForProd': True, 'triggerScoringModel': 'constant(3)', }, ]) server.clear_cache()
def setUp(self) -> None: super().setUp() self._db.advice_modules.insert_many([ { 'adviceId': 'spontaneous-application', 'isReadyForProd': True, 'triggerScoringModel': 'constant(3)', }, ]) server.clear_cache()
def setUp(self) -> None: super().setUp() self._db.advice_modules.insert_one({ 'adviceId': 'other-work-env', 'isReadyForProd': True, 'triggerScoringModel': 'constant(3)', 'tipTemplateIds': ['tip1', 'tip2'], }) self._db.tip_templates.insert_many([ { '_id': 'tip1', 'actionTemplateId': 'tip1', 'title': 'First tip', 'title_feminine': 'First tip for women', }, { '_id': 'tip2', 'actionTemplateId': 'tip2', 'title': 'Second tip', }, ]) patcher = mailjetmock.patch() patcher.start() self.addCleanup(patcher.stop) server.clear_cache() self.user_id, self.auth_token = self.create_user_with_token( modifiers=[base_test.add_project], advisor=True) user_info = self.get_user_info(self.user_id, self.auth_token) self.project_id = user_info['projects'][0]['projectId'] user_info['projects'][0]['advices'][0]['status'] = 'ADVICE_ACCEPTED' self.json_from_response( self.app.post( '/api/user', data=json.dumps(user_info), content_type='application/json', headers={'Authorization': 'Bearer ' + self.auth_token}))
def test_project_in_advisor(self): """New project should get advised and diagnosed.""" project = { 'mobility': { 'city': { 'departementId': '38' }, }, 'localStats': { 'lessStressfulJobGroups': [{}], }, 'minSalary': 1000, 'targetJob': { 'jobGroup': { 'romeId': 'M1403' } }, } user_id, auth_token = self.authenticate_new_user_token( email='*****@*****.**') self._db.advice_modules.insert_many([ { 'adviceId': 'spontaneous-application', 'isReadyForProd': True, 'triggerScoringModel': 'constant(3)', }, { 'adviceId': 'network-application', 'isReadyForProd': True, 'triggerScoringModel': 'constant(2)', }, ]) self._db.diagnostic_sentences.insert_one({ 'order': 1, 'sentenceTemplate': 'You are a star.', }) self._db.diagnostic_submetrics_sentences.insert_many([{ 'triggerScoringModel': 'constant(3)', 'positiveSentenceTemplate': "Vous avez de l'expérience.", 'submetric': submetric, 'weight': 1, 'negativeSentenceTemplate': "Vous manquez d'expérience.", } for submetric in { 'PROFILE_DIAGNOSTIC', 'PROJECT_DIAGNOSTIC', 'JOB_SEARCH_DIAGNOSTIC' }]) server.clear_cache() response = self.app.post( '/api/user', data='{{"userId": "{}", "profile": {{"email":"*****@*****.**"}}, ' '"featuresEnabled": {{"advisor": "ACTIVE"}}, ' '"projects": [{}]}}'.format(user_id, json.dumps(project)), content_type='application/json', headers={'Authorization': 'Bearer ' + auth_token}) user_info = self.json_from_response(response) project = user_info['projects'][0] self.assertEqual('ACTIVE', user_info.get('featuresEnabled', {}).get('advisor')) self.assertEqual({'overallScore', 'subDiagnostics', 'text'}, project.get('diagnostic', {}).keys()) all_advices = [ { 'adviceId': 'spontaneous-application', 'numStars': 3, 'status': 'ADVICE_RECOMMENDED', }, { 'adviceId': 'network-application', 'numStars': 2, 'status': 'ADVICE_RECOMMENDED', }, ] self.assertEqual(all_advices, project.get('advices'))