コード例 #1
0
 def test_render(self):
     project_sessions_view = views.ProjectSessionsView()
     project = models.Project(1, "Project1", 0, "token")
     project_sessions_view.set_project(project)
     sessions = [
         models.Session(1, 1, None, None, True, False, "127.0.0.1", 1)
     ]
     project_sessions_view.set_project_sessions(sessions)
     sessions_epochs = [[
         models.Epoch(1, 0, {
             "loss": 0,
             "acc": 1,
             "custom": 2
         }, datetime.datetime.now(), 1)
     ]]
     project_sessions_view.set_project_sessions_epochs(sessions_epochs)
     project_sessions_view.render()
     assert project_sessions_view.view_model["list_sessions"][0]["id"] == 1
     assert project_sessions_view.view_model["list_sessions"][0][
         "index"] == 1
     assert project_sessions_view.view_model["list_sessions"][0][
         "is_active"] == True
     assert project_sessions_view.view_model["list_sessions"][0][
         "loss"] == 0
     assert project_sessions_view.view_model["list_sessions"][0]["acc"] == 1
     assert project_sessions_view.view_model["breadcrumbs"][1][
         "label"] == "Sessions"
     assert project_sessions_view.view_model["breadcrumbs"][1][
         "url"] == "/projects/1/sessions"
コード例 #2
0
 def test_set_project_sessions(self):
     project_view = views.ProjectView()
     sessions = [
         models.Session(1, 1, None, None, True, False, "127.0.0.1", 1)
     ]
     project_view.set_project_sessions(sessions)
     assert project_view.sessions[0] == sessions[0]
コード例 #3
0
 def test_render(self):
     project_view = views.ProjectView()
     project = models.Project(1, "Project1", 0, "token")
     project_view.set_project(project)
     sessions = [
         models.Session(1, 1, None, None, True, False, "127.0.0.1", 1)
     ]
     project_view.set_project_sessions(sessions)
     project_view.render()
     assert any(d["type"] == "display_token"
                for d in project_view.view_model["icons"])
     assert any(d["type"] == "delete_project"
                for d in project_view.view_model["icons"])
     assert project_view.view_model["breadcrumbs"][0]["label"] == "Project1"
     assert project_view.view_model["breadcrumbs"][0][
         "url"] == "/projects/1"
コード例 #4
0
 def test_render(self):
     dashboard_view = views.DashboardView()
     dashboard_view.set_projects(
         [models.Project(1, "Project1", 0, "token")])
     dashboard_view.set_sessions(
         [models.Session(1, 1, None, None, True, False, "127.0.0.1", 1)])
     dashboard_view.render()
     assert dashboard_view.view_model["title"] == "Dashboard"
     assert dashboard_view.view_model["number_projects"] == 1
     assert dashboard_view.view_model["number_running_sessions"] == 1
     assert dashboard_view.view_model["icons"][0][
         "type"] == "create_project"
     assert dashboard_view.view_model["breadcrumbs"][0][
         "label"] == "Dashboard"
     assert dashboard_view.view_model["breadcrumbs"][0][
         "url"] == "/dashboard"
コード例 #5
0
 def get_all_sessions(self):
     query = "SELECT id_session, session_index, dt_start, dt_end, is_active, is_favorite, host, description, id_project FROM sessions"
     rows = self.query(query).fetchall()
     sessions = []
     for row in rows:
         id_session = row[0]
         session_index = row[1]
         dt_start = datetime.datetime.strptime(
             row[2], "%Y-%m-%d %H:%M:%S") if row[2] is not None else None
         dt_end = datetime.datetime.strptime(
             row[3], "%Y-%m-%d %H:%M:%S") if row[3] is not None else None
         is_active = row[4]
         is_favorite = row[5]
         host = row[6]
         description = row[7]
         id_project = row[8]
         sessions.append(
             models.Session(id_session, session_index, dt_start, dt_end,
                            is_active, is_favorite, host, description,
                            id_project))
     return sessions
コード例 #6
0
 def get_session(self, id_session):
     query = "SELECT id_session, session_index, dt_start, dt_end, is_active, is_favorite, host, description, id_project FROM sessions WHERE id_session = ?"
     vars = [id_session]
     rows = self.query(query, vars).fetchall()
     session = None
     if len(rows) > 0:
         row = rows[0]
         id_session = row[0]
         session_index = row[1]
         dt_start = datetime.datetime.strptime(
             row[2], "%Y-%m-%d %H:%M:%S") if row[2] is not None else None
         dt_end = datetime.datetime.strptime(
             row[3], "%Y-%m-%d %H:%M:%S") if row[3] is not None else None
         is_active = row[4]
         is_favorite = row[5]
         host = row[6]
         description = row[7]
         id_project = row[8]
         session = models.Session(id_session, session_index, dt_start,
                                  dt_end, is_active, is_favorite, host,
                                  description, id_project)
     return session
コード例 #7
0
 def test_render(self):
     session_view = views.SessionView()
     project = models.Project(1, "Project1", 0, "token")
     session_view.set_project(project)
     session = models.Session(1, 1, None, None, True, False, "127.0.0.1", 1)
     session_view.set_session(session)
     epochs = [
         models.Epoch(1, 0, {
             "loss": 0,
             "acc": 1,
             "custom": 2
         }, datetime.datetime.now(), 1)
     ]
     session_view.set_session_epochs(epochs)
     session_view.render()
     assert session_view.view_model["breadcrumbs"][0]["label"] == "Project1"
     assert session_view.view_model["breadcrumbs"][0][
         "url"] == "/projects/1"
     assert session_view.view_model["breadcrumbs"][1]["label"] == "Sessions"
     assert session_view.view_model["breadcrumbs"][1][
         "url"] == "/projects/1/sessions"
     assert session_view.view_model["breadcrumbs"][2][
         "url"] == "/projects/1/sessions/1"
     assert session_view.view_model["graphs"]["loss"]["data"][0][
         "epoch"] == 0
     assert session_view.view_model["graphs"]["loss"]["data"][0][
         "loss"] == 0
     assert session_view.view_model["graphs"]["acc"]["data"][0][
         "epoch"] == 0
     assert session_view.view_model["graphs"]["acc"]["data"][0]["acc"] == 1
     assert session_view.view_model["graphs"]["custom"]["data"][0][
         "epoch"] == 0
     assert session_view.view_model["graphs"]["custom"]["data"][0][
         "custom"] == 2
     assert session_view.view_model["is_active"] == True
     assert session_view.view_model["number_epochs"] == 1
     assert any(d["type"] == "delete_session"
                for d in session_view.view_model["icons"])
コード例 #8
0
 def test_set_session(self):
     session_view = views.SessionView()
     session = models.Session(1, 1, None, None, True, False, "127.0.0.1", 1)
     session_view.set_session(session)
     assert session_view.session == session