def test_no_get_flipped_tasks_if_tasks_werent_active(self): build_variant = "test" tasks = [ _mock_task(display_name=str(i), activated=False, status="True") for i in range(10) ] build_mock = MagicMock(build_variant=build_variant) build_mock.get_tasks.return_value = tasks prev_version = MagicMock() prev_build = MagicMock() prev_build.get_tasks.return_value = [ _mock_task(display_name=str(i), status=str(i % 2 == 0)) for i in range(9) ] prev_version.build_by_variant.return_value = prev_build next_version = MagicMock() next_build = MagicMock() next_build.get_tasks.return_value = [ _mock_task(display_name=str(i), status=str(i % 3 == 0)) for i in range(9) ] next_version.build_by_variant.return_value = next_build flipped_tasks = under_test._get_flipped_tasks_per_build( build_mock, prev_version, next_version) assert len(flipped_tasks) == 0
def test_no_get_flipped_tasks_if_next_version_does_not_contain_variant( self): build_variant = "test" tasks = [ _mock_task(display_name=str(i), activated=True, status="Success") for i in range(12) ] build_mock = MagicMock(build_variant=build_variant) build_mock.get_tasks.return_value = tasks prev_version = MagicMock() prev_build = MagicMock() prev_build.get_tasks.return_value = [ _mock_task(display_name=str(i), activated=True, status="Success" if (i % 2 == 0) else "Failed") for i in range(11) ] prev_version.build_by_variant.return_value = prev_build next_version = MagicMock() next_version.build_by_variant.side_effect = KeyError flipped_tasks = under_test._get_flipped_tasks_per_build( build_mock, prev_version, next_version) assert len(flipped_tasks) == 0
def test_get_flipped_tasks_per_build(self): build_variant = "test" tasks = [ _mock_task(display_name=str(i), activated=True, status="Success") for i in range(12) ] build_mock = MagicMock(build_variant=build_variant) build_mock.get_tasks.return_value = tasks prev_version = MagicMock() prev_build = MagicMock() prev_build.get_tasks.return_value = [ _mock_task(display_name=str(i), activated=True, status="Success" if (i % 2 == 0) else "Failed") for i in range(11) ] prev_version.build_by_variant.return_value = prev_build next_version = MagicMock() next_build = MagicMock() next_build.get_tasks.return_value = [ _mock_task(display_name=str(i), activated=True, status="Success" if (i % 3 == 0) else "Failed") for i in range(11) ] next_version.build_by_variant.return_value = next_build flipped_tasks = under_test._get_flipped_tasks_per_build( build_mock, prev_version, next_version) expected = ["3", "9"] assert len(flipped_tasks) == len(expected) for name in expected: assert name in flipped_tasks