Ejemplo n.º 1
0
 def test_first_dummy_page(self):
     items = [BasisItem('all', 'basicproblemsolving', '4')]
     basis = RecommendationBasis('dummypage', items)
     recommendations = recommend_resources(basis, self.get_dummypage_data())
     self.assertEqual(1, len(recommendations))
     self.assertEqual(recommendations[0]['educationalFramework'],
                      'basicproblemsolving')
     self.assertEqual(1, len(recommendations[0]['recommendations']))
     # digital skills
     items = [BasisItem('all', 'digitalskills', '3')]
     basis = RecommendationBasis('dummypage', items)
     recommendations = recommend_resources(basis, self.get_dummypage_data())
     self.assertEqual(1, len(recommendations))
     self.assertEqual(recommendations[0]['educationalFramework'],
                      'digitalskills')
     self.assertEqual(1, len(recommendations[0]['recommendations']))
     self.assertEqual('word for dummies',
                      recommendations[0]['recommendations'][0]['name'])
     #cooking
     items = [BasisItem('all', 'cooking', '2')]
     basis = RecommendationBasis('dummypage', items)
     recommendations = recommend_resources(basis, self.get_dummypage_data())
     self.assertEqual(1, len(recommendations))
     self.assertEqual(2, len(recommendations[0]['recommendations']))
     #cooking & digital
     items = [
         BasisItem('all', 'cooking', '2'),
         BasisItem('all', 'digitalskills', '3')
     ]
     basis = RecommendationBasis('dummypage', items)
     recommendations = recommend_resources(basis, self.get_dummypage_data())
     digitalrecs = [
         x['recommendations'] for x in recommendations
         if x['educationalFramework'] == 'digitalskills'
     ]
     self.assertEqual(1, len(digitalrecs[0]))
     cooking = [
         x['recommendations'] for x in recommendations
         if x['educationalFramework'] == 'cooking'
     ]
     self.assertEqual(2, len(cooking[0]))
     #dodo
     items = [BasisItem('all', 'dodo', '2'), BasisItem('all', 'klein', '3')]
     basis = RecommendationBasis('dummypage', items)
     recommendations = recommend_resources(basis, self.get_dummypage_data())
     self.assertEqual(2, len(recommendations))
     self.assertEqual(0, len(recommendations[0]['recommendations']))
     self.assertEqual(0, len(recommendations[1]['recommendations']))
Ejemplo n.º 2
0
 def test_learning_registry_lookup_one_recommendation(self):
     items = [
         BasisItem(
             'all', 'Civil Service Digital Skills Framework',
             'https://civilservicelearning.civilservice.gov.uk/digitalskillsf#ProblemSolving#3'
         )
     ]
     basis = RecommendationBasis('learning_registry_match', items)
     recommendations = recommend_resources(
         basis, self.get_learningregistry_items())
     self.assertEqual(1, len(recommendations))
     self.assertEqual('Civil Service Digital Skills Framework',
                      recommendations[0]['title'])
     self.assertEqual(1, len(recommendations[0]['areas']))
     self.assertEqual('ProblemSolving',
                      recommendations[0]['areas'][0]['name'])
     self.assertEqual(4, recommendations[0]['areas'][0]['level'])
     self.assertEqual(
         1, len(recommendations[0]['areas'][0]['recommendations']))
     self.assertEqual(
         'http://www.computerperformance.co.uk/Training/Problems.htm',
         recommendations[0]['areas'][0]['recommendations'][0]['url'])
     # Check associated tincanstatement is associated
     self.assertEqual(
         True, 'tincanstatement'
         in recommendations[0]['areas'][0]['recommendations'][0])
Ejemplo n.º 3
0
def get_recommendations(answers):
    rule = Config.DGN_RULE
    basisItems = _transform_to_basis_items(answers)
    recBasis = RecommendationBasis(rule, basisItems)
    potential_resources = _get_resources_data()

    raw_recs = rec_service.recommend_resources(recBasis, potential_resources)
    return _transform_to_recommendations(raw_recs)
def get_recommendations(answers):
    rule = Config.DGN_RULE
    basisItems = _transform_to_basis_items(answers)
    recBasis = RecommendationBasis(rule, basisItems)
    potential_resources = _get_resources_data()
    
    raw_recs = rec_service.recommend_resources(recBasis, potential_resources)
    return _transform_to_recommendations(raw_recs)
 def test_basic_two_recommendation_test(self):
     ''' Pick a single recommended resource from a list of three '''
     # Base the recommendations on a simple 1-5 scoring where we score 3 and want something of 4
     # to come back as a result
     
     # one single item to base on
     items = [BasisItem('all', '1to5', '1to5:3'), BasisItem('all', '1to5', '1to5:4')]
     basis = RecommendationBasis('1to5', items)
     recommended = recommend_resources(basis, self.get_basic_candidatedata())
     self.assertEqual(2, len(recommended))
     self.assertEqual(recommended[1]['targetUrl'], '1to5:5')
     self.assertEqual(recommended[1]['resourceUrl'], 'http://1-5/5')
 def test_learning_registry_lookup_one_recommendation(self):
     items = [BasisItem('all', 'Civil Service Digital Skills Framework', 'https://civilservicelearning.civilservice.gov.uk/digitalskillsf#ProblemSolving#3')]
     basis = RecommendationBasis('learning_registry_match', items)
     recommendations = recommend_resources(basis, self.get_learningregistry_items())
     self.assertEqual(1, len(recommendations))
     self.assertEqual('Civil Service Digital Skills Framework', recommendations[0]['title'])
     self.assertEqual(1, len(recommendations[0]['areas']))
     self.assertEqual('ProblemSolving', recommendations[0]['areas'][0]['name'])
     self.assertEqual(4, recommendations[0]['areas'][0]['level'])
     self.assertEqual(1, len(recommendations[0]['areas'][0]['recommendations']))
     self.assertEqual('http://www.computerperformance.co.uk/Training/Problems.htm', recommendations[0]['areas'][0]['recommendations'][0]['url'])
     # Check associated tincanstatement is associated
     self.assertEqual(True, 'tincanstatement' in recommendations[0]['areas'][0]['recommendations'][0])       
Ejemplo n.º 7
0
    def test_basic_single_recommendation_test(self):
        ''' Pick a single recommended resource from a list of three '''
        # Base the recommendations on a simple 1-5 scoring where we score 3 and want something of 4
        # to come back as a result

        # one single item to base on
        items = [BasisItem('all', '1to5', '1to5:3')]
        basis = RecommendationBasis('1to5', items)
        recommended = recommend_resources(basis,
                                          self.get_basic_candidatedata())
        self.assertEqual(1, len(recommended))
        self.assertEqual(recommended[0]['targetUrl'], '1to5:4')
        self.assertEqual(recommended[0]['resourceUrl'], 'http://1-5/4')
 def test_first_dummy_page(self):
     items = [BasisItem('all', 'basicproblemsolving', '4')]
     basis = RecommendationBasis('dummypage', items)
     recommendations = recommend_resources(basis, self.get_dummypage_data())
     self.assertEqual(1, len(recommendations))
     self.assertEqual(recommendations[0]['educationalFramework'], 'basicproblemsolving')
     self.assertEqual(1, len(recommendations[0]['recommendations']))
     # digital skills
     items = [BasisItem('all', 'digitalskills', '3')]
     basis = RecommendationBasis('dummypage', items)
     recommendations = recommend_resources(basis, self.get_dummypage_data())
     self.assertEqual(1, len(recommendations))
     self.assertEqual(recommendations[0]['educationalFramework'], 'digitalskills')
     self.assertEqual(1, len(recommendations[0]['recommendations']))
     self.assertEqual('word for dummies', recommendations[0]['recommendations'][0]['name'])
     #cooking
     items = [BasisItem('all', 'cooking', '2')]
     basis = RecommendationBasis('dummypage', items)
     recommendations = recommend_resources(basis, self.get_dummypage_data())
     self.assertEqual(1, len(recommendations))
     self.assertEqual(2, len(recommendations[0]['recommendations']))
     #cooking & digital
     items = [BasisItem('all', 'cooking', '2'), BasisItem('all', 'digitalskills', '3')]
     basis = RecommendationBasis('dummypage', items)
     recommendations = recommend_resources(basis, self.get_dummypage_data())
     digitalrecs = [x['recommendations'] for x in recommendations if x['educationalFramework']=='digitalskills']
     self.assertEqual(1, len(digitalrecs[0]))
     cooking = [x['recommendations'] for x in recommendations if x['educationalFramework']=='cooking']
     self.assertEqual(2, len(cooking[0]))
     #dodo
     items = [BasisItem('all', 'dodo', '2'), BasisItem('all', 'klein', '3')]
     basis = RecommendationBasis('dummypage', items)
     recommendations = recommend_resources(basis, self.get_dummypage_data())
     self.assertEqual(2, len(recommendations))
     self.assertEqual(0, len(recommendations[0]['recommendations']))
     self.assertEqual(0, len(recommendations[1]['recommendations']))
Ejemplo n.º 9
0
    def test_learning_registry_lookup_two_recommendations_over_two_frameworks(
            self):

        items = [
            BasisItem(
                'all', 'Civil Service Digital Skills Framework',
                'https://civilservicelearning.civilservice.gov.uk/digitalskillsf#Communications#4'
            ),
            BasisItem(
                'all', 'Civil Service Digital Skills Framework',
                'https://civilservicelearning.civilservice.gov.uk/digitalskillsf#ProblemSolving#3'
            )
        ]
        basis = RecommendationBasis('learning_registry_match', items)
        recommendations = recommend_resources(
            basis, self.get_learningregistry_items())
        self.assertEqual(1, len(recommendations))
        self.assertEqual('Civil Service Digital Skills Framework',
                         recommendations[0]['title'])
        print(recommendations[0]['areas'])
        self.assertEqual(2, len(recommendations[0]['areas']))

        # Digital Skills level 4
        ps = [
            r for r in recommendations[0]['areas']
            if r['name'] == 'ProblemSolving'
        ]
        self.assertEqual(1, len(ps))
        ps = ps[0]
        self.assertEqual(4, ps['level'])
        self.assertEqual(1, len(ps['recommendations']))

        # Digital Comms level 5
        c = [
            r for r in recommendations[0]['areas']
            if r['name'] == 'Communications'
        ]
        self.assertEqual(5, c[0]['level'])
        self.assertEqual(2, len(c[0]['recommendations']))
        self.assertEqual(True, 'tincanstatement' in c[0]['recommendations'][0])
        self.assertEqual(True, 'tincanstatement' in c[0]['recommendations'][1])
    def test_learning_registry_lookup_two_recommendations_over_two_frameworks(self):

        items = [BasisItem('all', 'Civil Service Digital Skills Framework', 'https://civilservicelearning.civilservice.gov.uk/digitalskillsf#Communications#4'),
                BasisItem('all', 'Civil Service Digital Skills Framework', 'https://civilservicelearning.civilservice.gov.uk/digitalskillsf#ProblemSolving#3')]
        basis = RecommendationBasis('learning_registry_match', items)
        recommendations = recommend_resources(basis, self.get_learningregistry_items())
        self.assertEqual(1, len(recommendations))
        self.assertEqual('Civil Service Digital Skills Framework', recommendations[0]['title'])
        print(recommendations[0]['areas'])
        self.assertEqual(2, len(recommendations[0]['areas']))

        # Digital Skills level 4
        ps = [r for r in recommendations[0]['areas'] if r['name'] == 'ProblemSolving']
        self.assertEqual(1, len(ps))
        ps = ps[0]
        self.assertEqual(4, ps['level'])
        self.assertEqual(1, len(ps['recommendations']))

        # Digital Comms level 5
        c = [r for r in recommendations[0]['areas'] if r['name'] == 'Communications']
        self.assertEqual(5, c[0]['level'])
        self.assertEqual(2, len(c[0]['recommendations']))
        self.assertEqual(True, 'tincanstatement' in c[0]['recommendations'][0])
        self.assertEqual(True, 'tincanstatement' in c[0]['recommendations'][1])