'Given course outline page, publish first unit and view it in LMS when publish is false, it will only view'

def publish_unit_in_lms_and_view(self, courseware_page, publish=True):

    self.outline_page.visit()
    self.outline_page.expand_all_subsections()
    section = self.outline_page.section_at(0)
    unit = section.subsection_at(0).unit_at(0).go_to()
    if publish:
        unit.publish_action.click()
    unit.view_published_version()
    self.assertEqual(len(self.browser.window_handles), 2)
    courseware_page.wait_for_page()
