def test_adjacency_passes(self): probe_group, matches, scif = self.create_scene_scif_matches_stitch_groups_data_mocks( DataTestUnitPEPSICOUK.test_case_1, 1) self.mock_adjacency_results( [DataTestUnitPEPSICOUK.adjacency_results_true]) scene_tb = PEPSICOUKSceneToolBox(self.data_provider_mock, self.output) scene_tb.passed_blocks = { 'Pringles_FTT_Tubes': DataTestUnitPEPSICOUK.block_results, 'Hula Hoops_LMP_Snacks': DataTestUnitPEPSICOUK.block_results_2 } scene_tb.block_results = DataTestUnitPEPSICOUK.blocks_all_pass scene_tb.calculate_adjacency_new() kpi_result = scene_tb.kpi_results self.assertEquals(len(kpi_result), 1) expected_list = list() expected_list.append({ 'kpi_fk': 320, 'numerator': 166, 'denominator': 165, 'result': 4, 'score': 1 }) test_result_list = [] for expected_result in expected_list: test_result_list.append( self.check_kpi_results(kpi_result, expected_result) == 1) self.assertTrue(all(test_result_list))
def test_adjacency_no_results_if_no_blocks_pass(self): probe_group, matches, scif = self.create_scene_scif_matches_stitch_groups_data_mocks( DataTestUnitPEPSICOUK.test_case_1, 1) scene_tb = PEPSICOUKSceneToolBox(self.data_provider_mock, self.output) scene_tb.block_results = DataTestUnitPEPSICOUK.blocks_none_passes scene_tb.calculate_adjacency_new() self.assertTrue(scene_tb.kpi_results.empty)
def test_get_group_pairs_1_pass_out_of_3(self): probe_group, matches, scif = self.create_scene_scif_matches_stitch_groups_data_mocks( DataTestUnitPEPSICOUK.test_case_1, 1) scene_tb = PEPSICOUKSceneToolBox(self.data_provider_mock, self.output) scene_tb.block_results = DataTestUnitPEPSICOUK.blocks_combinations_1_pass_of_3 pairs = scene_tb.get_group_pairs() self.assertEquals(len(pairs), 0)
def test_get_group_pairs_2_pass_out_of_3(self): probe_group, matches, scif = self.create_scene_scif_matches_stitch_groups_data_mocks( DataTestUnitPEPSICOUK.test_case_1, 1) scene_tb = PEPSICOUKSceneToolBox(self.data_provider_mock, self.output) scene_tb.block_results = DataTestUnitPEPSICOUK.blocks_combinations_2_pass_of_3 pairs = scene_tb.get_group_pairs() expected_result = [frozenset(['Group 2', 'Group 1'])] self.assertEquals(len(pairs), 1) self.assertItemsEqual(pairs, expected_result)
def test_get_group_pairs_4_pass_out_of_4(self): probe_group, matches, scif = self.create_scene_scif_matches_stitch_groups_data_mocks( DataTestUnitPEPSICOUK.test_case_1, 1) self.mock_object('PositionGraphs', path='KPIUtils_v2.Calculations.AdjacencyCalculations') scene_tb = PEPSICOUKSceneToolBox(self.data_provider_mock, self.output) scene_tb.block_results = DataTestUnitPEPSICOUK.blocks_combinations_4_pass_of_4 pairs = scene_tb.get_group_pairs() expected = [ frozenset(['Group 3', 'Group 1']), frozenset(['Group 4', 'Group 2']), frozenset(['Group 4', 'Group 3']), frozenset(['Group 2', 'Group 3']), frozenset(['Group 4', 'Group 1']), frozenset(['Group 2', 'Group 1']) ] self.assertEquals(len(pairs), 6) self.assertItemsEqual(pairs, expected)