Beispiel #1
0
 def test_increment_project_session_counter(self):
     db = database.MambasDatabase()
     self.create_test_db(db)
     id = db.create_project("Project1", "MyToken").id_project
     project = db.increment_project_session_counter(id)
     assert project.session_counter == 1
     self.destroy_test_db(db)
Beispiel #2
0
 def test_delete_project(self):
     db = database.MambasDatabase()
     self.create_test_db(db)
     id = db.create_project("Project1", "MyToken").id_project
     result = db.delete_project(id)
     assert result == True
     self.destroy_test_db(db)
Beispiel #3
0
 def test_create_project(self):
     db = database.MambasDatabase()
     self.create_test_db(db)
     project = db.create_project("Project1", "MyToken")
     assert project.name == "Project1"
     assert project.token == "MyToken"
     self.destroy_test_db(db)
Beispiel #4
0
 def test_delete_session(self):
     db = database.MambasDatabase()
     self.create_test_db(db)
     id_project = db.create_project("Project1", "MyToken").id_project
     id = db.create_session_for_project(1, "127.0.0.1", id_project).id_session
     result = db.delete_session(id)
     assert result == True
     self.destroy_test_db(db)
Beispiel #5
0
 def test_set_session_inactive(self):
     db = database.MambasDatabase()
     self.create_test_db(db)
     id_project = db.create_project("Project1", "MyToken").id_project
     id = db.create_session_for_project(1, "127.0.0.1", id_project).id_session
     session = db.set_session_inactive(id)
     assert session.is_active == False
     self.destroy_test_db(db)
Beispiel #6
0
 def test_get_all_projects(self):
     db = database.MambasDatabase()
     self.create_test_db(db)
     db.create_project("Project1", "MyToken")
     projects = db.get_all_projects()
     assert len(projects) == 1
     assert projects[0].name == "Project1"
     assert projects[0].token == "MyToken"
     self.destroy_test_db(db)
Beispiel #7
0
 def test_get_session(self):
     db = database.MambasDatabase()
     self.create_test_db(db)
     id_project = db.create_project("Project1", "MyToken").id_project
     id = db.create_session_for_project(1, "127.0.0.1", id_project).id_session
     session = db.get_session(id)
     assert session.index == 1
     assert session.host == "127.0.0.1"
     assert session.id_project == id
     self.destroy_test_db(db)
Beispiel #8
0
 def test_create_session_for_project(self):
     db = database.MambasDatabase()
     self.create_test_db(db)
     id = db.create_project("Project1", "MyToken").id_project
     session = db.create_session_for_project(1, "127.0.0.1", id)
     assert session.index == 1
     assert session.host == "127.0.0.1"
     assert session.id_project == id
     assert session.is_active == True
     self.destroy_test_db(db)
Beispiel #9
0
 def test_delete_epoch(self):
     db = database.MambasDatabase()
     self.create_test_db(db)
     id_project = db.create_project("Project1", "MyToken").id_project
     id_session = db.create_session_for_project(1, "127.0.0.1", id_project).id_session
     now = datetime.datetime.now()
     id = db.create_epoch_for_session(0, {}, now, id_session).id_epoch
     result = db.delete_epoch(id)
     assert result == True
     self.destroy_test_db(db)
Beispiel #10
0
 def test_create_epoch_for_session(self):
     db = database.MambasDatabase()
     self.create_test_db(db)
     id_project = db.create_project("Project1", "MyToken").id_project
     id = db.create_session_for_project(1, "127.0.0.1", id_project).id_session
     now = datetime.datetime.now()
     epoch = db.create_epoch_for_session(0, {}, now, id)
     assert epoch.index == 0
     assert len(epoch.metrics) == 0
     assert epoch.time.strftime("%Y-%m-%d %H:%M:%S") == now.strftime("%Y-%m-%d %H:%M:%S")
     assert epoch.id_session == id
     self.destroy_test_db(db)
Beispiel #11
0
 def test_set_session_end_time(self):
     db = database.MambasDatabase()
     self.create_test_db(db)
     id_project = db.create_project("Project1", "MyToken").id_project
     id = db.create_session_for_project(1, "127.0.0.1", id_project).id_session
     now = datetime.datetime.now()
     session = db.set_session_end_time(id, now)
     assert session.dt_end.year == now.year
     assert session.dt_end.month == now.month
     assert session.dt_end.day == now.day
     assert session.dt_end.hour == now.hour
     assert session.dt_end.minute == now.minute
     assert session.dt_end.second == now.second
     self.destroy_test_db(db)