def compute_average_user_performance(self): set_up() normalization: Normalization = Normalization() user_keys: str = Database().get_user_keys() for user_key in user_keys: normalization.calculate_average_performance(user_key) Cluster(1).cluster_users() clean_up()
def test_from_dict(self): set_up() database: Database = Database() result: Session = database.get_session(Samples.sample_user.user_key, Samples.sample_session.session_key) timestamp = result.to_dict()['timestamp'] expected_result: Session = Samples.sample_session expected_result.timestamp = timestamp # # # self.assertEqual(result.to_dict(), expected_result.to_dict())
def test_get_session(self): set_up() # Should retrieve an existing session from Firestore. result: Session = Database().get_session( Samples.sample_user.user_key, Samples.sample_session.session_key) timestamp = result.to_dict()['timestamp'] # Defines the expected result. expected_result: Session = Samples.sample_session expected_result.timestamp = timestamp # Expects the result to be equal to a predefined sample session. self.assertEqual(result.to_dict(), expected_result.to_dict()) clean_up()
def test_calculate_user_score(self): # Sets up a test environment. set_up() # Calculates the user score for a sample user. result: int = Normalization().calculate_user_score( Samples.sample_user.user_key) # Expects the user score to be 100. expected_result: int = 100 # Assets whether the result is equals the expected result. self.assertEqual(result, expected_result) # Removes the test environment. clean_up()
def test_create_DataFrame(self): set_up() df = Normalization().create_DataFrame('user_042') result = df.loc[['user_042:session_042']].values excepted_result = [[1., 1., 1., 0., 600., 45., 15., 80]] self.assertEqual(result[0][0], excepted_result[0][0]) self.assertEqual(result[0][1], excepted_result[0][1]) self.assertEqual(result[0][2], excepted_result[0][2]) self.assertEqual(result[0][3], excepted_result[0][3]) self.assertEqual(result[0][4], excepted_result[0][4]) self.assertEqual(result[0][5], excepted_result[0][5]) self.assertEqual(result[0][6], excepted_result[0][6]) self.assertEqual(result[0][7], excepted_result[0][7]) clean_up()
def test_calculate_average_performance(self): set_up() df = Normalization().calculate_average_performance('user_042') result = df.loc[['user_042']].values excepted_result = [[1., 1., 1., 0., 600., 45., 15., 80]] self.assertEqual(result[0][0], excepted_result[0][0]) self.assertEqual(result[0][1], excepted_result[0][1]) self.assertEqual(result[0][2], excepted_result[0][2]) self.assertEqual(result[0][3], excepted_result[0][3]) self.assertEqual(result[0][4], excepted_result[0][4]) self.assertEqual(result[0][5], excepted_result[0][5]) self.assertEqual(result[0][6], excepted_result[0][6]) self.assertEqual(result[0][7], excepted_result[0][7]) clean_up()
def test_normalize_performance(self): # Sets up a test environment. set_up() # df = Normalization().normalize_performance() result = df.loc[['user_042']].values excepted_result = [[1., 1., 1., 0., 1., 1., 1., 1.]] self.assertEqual(result[0][0], excepted_result[0][0]) self.assertEqual(result[0][1], excepted_result[0][1]) self.assertEqual(result[0][2], excepted_result[0][2]) self.assertEqual(result[0][3], excepted_result[0][3]) self.assertEqual(result[0][4], excepted_result[0][4]) self.assertEqual(result[0][5], excepted_result[0][5]) self.assertEqual(result[0][6], excepted_result[0][6]) self.assertEqual(result[0][7], excepted_result[0][7]) clean_up()
class Test_Level(unittest.TestCase): set_up() result = Samples