def test_create_gantt_plotly(tmpdir): """test_create_gantt_plotly.""" c1 = BaseComponent("c1") c2 = BaseComponent("c2") product = BaseProduct([c1, c2]) # Set test case c1.state_record_list = [ BaseTaskState.READY, BaseTaskState.WORKING, BaseTaskState.FINISHED, BaseTaskState.WORKING, BaseTaskState.WORKING, BaseTaskState.FINISHED, ] c2.state_record_list = [ BaseTaskState.WORKING, BaseTaskState.WORKING, BaseTaskState.FINISHED, BaseTaskState.WORKING, BaseTaskState.FINISHED, BaseTaskState.FINISHED, ] init_datetime = datetime.datetime(2020, 4, 1, 8, 0, 0) timedelta = datetime.timedelta(days=1) for ext in ["png", "html", "json"]: save_fig_path = os.path.join(str(tmpdir), "test." + ext) product.create_gantt_plotly(init_datetime, timedelta, save_fig_path=save_fig_path)
def test_create_data_for_gantt_plotly(): """test_create_data_for_gantt_plotly.""" c1 = BaseComponent("c1") c2 = BaseComponent("c2") product = BaseProduct([c1, c2]) # Set test case c1.state_record_list = [ BaseTaskState.READY, BaseTaskState.WORKING, BaseTaskState.FINISHED, BaseTaskState.WORKING, BaseTaskState.WORKING, BaseTaskState.FINISHED, ] c2.state_record_list = [ BaseTaskState.WORKING, BaseTaskState.WORKING, BaseTaskState.FINISHED, BaseTaskState.WORKING, BaseTaskState.FINISHED, BaseTaskState.FINISHED, ] init_datetime = datetime.datetime(2020, 4, 1, 8, 0, 0) timedelta = datetime.timedelta(days=1) product.create_data_for_gantt_plotly(init_datetime, timedelta)
def test_plot_simple_gantt(tmpdir): """test_plot_simple_gantt.""" c1 = BaseComponent("c1") c2 = BaseComponent("c2") product = BaseProduct([c1, c2]) # Set test case c1.state_record_list = [ BaseTaskState.READY, BaseTaskState.WORKING, BaseTaskState.FINISHED, BaseTaskState.WORKING, BaseTaskState.WORKING, BaseTaskState.FINISHED, ] c2.state_record_list = [ BaseTaskState.WORKING, BaseTaskState.WORKING, BaseTaskState.FINISHED, BaseTaskState.WORKING, BaseTaskState.FINISHED, BaseTaskState.FINISHED, ] for ext in ["png"]: save_fig_path = os.path.join(str(tmpdir), "test." + ext) product.plot_simple_gantt(save_fig_path=save_fig_path)
def dummy_product_for_extracting(scope="function"): """dummy_product_for_extracting.""" component1 = BaseComponent("component1") component1.state_record_list = [ BaseComponentState.WORKING, BaseComponentState.FINISHED, BaseComponentState.FINISHED, BaseComponentState.FINISHED, BaseComponentState.FINISHED, ] component2 = BaseComponent("component2") component2.state_record_list = [ BaseComponentState.WORKING, BaseComponentState.WORKING, BaseComponentState.FINISHED, BaseComponentState.FINISHED, BaseComponentState.FINISHED, ] component3 = BaseComponent("component3") component3.state_record_list = [ BaseComponentState.READY, BaseComponentState.WORKING, BaseComponentState.WORKING, BaseComponentState.FINISHED, BaseComponentState.FINISHED, ] component4 = BaseComponent("component4") component4.state_record_list = [ BaseComponentState.NONE, BaseComponentState.READY, BaseComponentState.WORKING, BaseComponentState.WORKING, BaseComponentState.FINISHED, ] component5 = BaseComponent("component5") component5.state_record_list = [ BaseComponentState.NONE, BaseComponentState.NONE, BaseComponentState.READY, BaseComponentState.READY, BaseComponentState.WORKING, ] return BaseProduct( [component1, component2, component3, component4, component5])
def test_get_time_list_for_gannt_chart(): w = BaseComponent("w1", "----") w.state_record_list = [ BaseComponentState.NONE, BaseComponentState.READY, BaseComponentState.WORKING, ] ready_time_list, working_time_list = w.get_time_list_for_gannt_chart() assert ready_time_list == [(1, 1)] assert working_time_list == [(2, 1)] w.state_record_list = [ BaseComponentState.NONE, BaseComponentState.READY, BaseComponentState.READY, ] ready_time_list, working_time_list = w.get_time_list_for_gannt_chart() assert ready_time_list == [(1, 2)] assert working_time_list == [] w.state_record_list = [ BaseComponentState.NONE, BaseComponentState.WORKING, BaseComponentState.FINISHED, ] ready_time_list, working_time_list = w.get_time_list_for_gannt_chart() assert ready_time_list == [] assert working_time_list == [(1, 1)] # for backward w.state_record_list = [ BaseComponentState.FINISHED, BaseComponentState.WORKING, BaseComponentState.READY, BaseComponentState.READY, BaseComponentState.FINISHED, BaseComponentState.WORKING, BaseComponentState.WORKING, BaseComponentState.READY, ] ready_time_list, working_time_list = w.get_time_list_for_gannt_chart() assert ready_time_list == [(2, 2), (7, 1)] assert working_time_list == [(1, 1), (5, 2)]
def test_remove_insert_absence_time_list(): """test_remove_insert_absence_time_list.""" c1 = BaseComponent("c1", "----") c1.placed_workplace_id_record = ["aa", "bb", "cc", "dd", "ee", "ff"] c1.state_record_list = [0, 1, 2, 3, 4, 5] c2 = BaseComponent("c2", "----") c2.placed_workplace_id_record = ["ff", "ee", "dd", "cc", "bb", "aa"] c2.state_record_list = [5, 4, 3, 2, 1, 0] c2.append_child_component(c1) product = BaseProduct([c1, c2]) absence_time_list = [0, 1] product.remove_absence_time_list(absence_time_list) assert c1.placed_workplace_id_record == ["cc", "dd", "ee", "ff"] assert c1.state_record_list == [2, 3, 4, 5] assert c2.placed_workplace_id_record == ["dd", "cc", "bb", "aa"] assert c2.state_record_list == [3, 2, 1, 0] product.insert_absence_time_list(absence_time_list) assert c1.placed_workplace_id_record == [ None, None, "cc", "dd", "ee", "ff" ] assert c1.state_record_list == [ BaseComponentState.NONE, BaseComponentState.READY, 2, 3, 4, 5, ] assert c2.placed_workplace_id_record == [ None, None, "dd", "cc", "bb", "aa" ] assert c2.state_record_list == [ BaseComponentState.NONE, BaseComponentState.NONE, 3, 2, 1, 0, ]
def test_create_data_for_gantt_plotly(): """test_create_data_for_gantt_plotly.""" c = BaseComponent("c") c.state_record_list = [ BaseComponentState.WORKING, BaseComponentState.FINISHED, BaseComponentState.FINISHED, BaseComponentState.FINISHED, BaseComponentState.FINISHED, ] init_datetime = datetime.datetime(2020, 4, 1, 8, 0, 0) timedelta = datetime.timedelta(days=1) c.create_data_for_gantt_plotly(init_datetime, timedelta)
def test_remove_insert_absence_time_list(): """test_remove_insert_absence_time_list.""" w = BaseComponent("w1", "----") w.placed_workplace_id_record = ["aa", "bb", "cc", "dd", "ee", "ff"] w.state_record_list = [0, 1, 2, 3, 4, 5] absence_time_list = [0, 1] w.remove_absence_time_list(absence_time_list) assert w.placed_workplace_id_record == ["cc", "dd", "ee", "ff"] assert w.state_record_list == [2, 3, 4, 5] w.insert_absence_time_list(absence_time_list) assert w.placed_workplace_id_record == [None, None, "cc", "dd", "ee", "ff"] assert w.state_record_list == [ BaseComponentState.NONE, BaseComponentState.READY, 2, 3, 4, 5, ]