def test_get_all_scaled_scores_failure(self):
     """Score Test all scaled score"""
     with mock.patch('score.ScoresGenerator.split_data') \
     as mock_split_data:
         with mock.patch('score.ScoresGenerator.create_category_scaled_score') \
         as mock_scaled_category:
             with mock.patch('score.ScoresGenerator.create_total_scaled_score') \
             as mock_scaled_total:
                 for test in self.failure_get_all_scaled_score_test_params:
                     score_test = score.ScoresGenerator()
                     score_test.get_all_scaled_scores(test[KEY_INPUT])
                     self.assertNotAlmostEqual(score_test.SCORES[KEY_WORK_LOAD],
                                               test[KEY_EXPECTED][KEY_WORK_LOAD], places=1)
                     self.assertNotAlmostEqual(score_test.SCORES[KEY_INDEPENDENCE],
                                               test[KEY_EXPECTED][KEY_INDEPENDENCE], places=1)
                     self.assertNotAlmostEqual(score_test.SCORES[KEY_LEADER_SUPPORT],
                                               test[KEY_EXPECTED][KEY_LEADER_SUPPORT], places=1)
                     self.assertNotAlmostEqual(score_test.SCORES[KEY_PEER_RELATIONSHIPS],
                                               test[KEY_EXPECTED][KEY_PEER_RELATIONSHIPS],
                                               places=1)
                     self.assertNotAlmostEqual(
                         score_test.SCORES[KEY_CONTRIBUTION_IMPACT],
                         test[KEY_EXPECTED][KEY_CONTRIBUTION_IMPACT], places=1)
                     self.assertNotAlmostEqual(
                         score_test.SCORES[KEY_DEVELOPMENT],
                         test[KEY_EXPECTED][KEY_DEVELOPMENT], places=1)
 def test_get_all_scaled_scores_success(self):
     """Score Test all scaled score"""
     with mock.patch('score.ScoresGenerator.split_data') as mock_split_data:
         with mock.patch('score.ScoresGenerator.create_category_scaled_score') \
          as mock_scaled_category:
             with mock.patch('score.ScoresGenerator.create_total_scaled_score') \
             as mock_scaled_total:
                 for test in self.success_get_all_scaled_score_test_params:
                     score_test = score.ScoresGenerator()
                     score_test.get_all_scaled_scores(test[KEY_INPUT])
                     self.assertDictEqual(score_test.SCALED_SCORES, test[KEY_EXPECTED])
 def test_split_data_failure(self):
     """Score Test failure"""
     for test in self.failure_split_data_test_params:
         score_test = score.ScoresGenerator()
         score_test.split_data(test[KEY_INPUT])
         self.assertNotEqual(score_test.SCORES[KEY_WORK_LOAD],
         test[KEY_EXPECTED][KEY_WORK_LOAD])
         self.assertNotEqual(score_test.SCORES[KEY_INDEPENDENCE],
         test[KEY_EXPECTED][KEY_INDEPENDENCE])
         self.assertNotEqual(score_test.SCORES[KEY_LEADER_SUPPORT],
         test[KEY_EXPECTED][KEY_LEADER_SUPPORT])
         self.assertNotEqual(score_test.SCORES[KEY_PEER_RELATIONSHIPS],
         test[KEY_EXPECTED][KEY_PEER_RELATIONSHIPS])
         self.assertNotEqual(score_test.SCORES[KEY_CONTRIBUTION_IMPACT],
         test[KEY_EXPECTED][KEY_CONTRIBUTION_IMPACT])
         self.assertNotEqual(score_test.SCORES[KEY_DEVELOPMENT],
         test[KEY_EXPECTED][KEY_DEVELOPMENT])
Example #4
0
def on_quiz_submission(data):
    """emit, when user submits a quiz

    Args:
        data ([string]): [quiz responses]
    """
    score_generator = score.ScoresGenerator()
    data_dict = {}
    for var in data:
        q_key = "q" + var['qid']
        data_dict.update({q_key: int(var['qval'])})
    print(data_dict)
    result = score_generator.get_all_scaled_scores(data_dict)
    socketio.emit("on_quiz_submission_response",
                  result,
                  room=get_room_client_id())
    print(
        f'Emitted socket to client {get_room_client_id()} with updated scores: {result}'
    )
 def test_create_total_scaled_score(self):
     """Score Test scaled score"""
     score_test = score.ScoresGenerator()
     expected = 0
     score_test.create_total_scaled_score()
     self.assertEqual(score_test.SCALED_SCORES[KEY_TOTAL], expected)
 def test_create_category_scaled_score_failure(self):
     """Score Test scaled score"""
     score_test = score.ScoresGenerator()
     for test in self.failure_create_category_scaled_score_test_params:
         score_test.create_category_scaled_score(test[KEY_INPUT])
         self.assertNotEqual(score_test.SCALED_SCORES[test[KEY_INPUT]], test[KEY_EXPECTED])
 def test_split_data_success(self):
     """Score Test data success"""
     for test in self.success_split_data_test_params:
         score_test = score.ScoresGenerator()
         score_test.split_data(test[KEY_INPUT])
         self.assertDictEqual(score_test.SCORES, test[KEY_EXPECTED])