'Updates 3 of the 4 existing html to limit their visibility by content group.
Publishes the modified units.'

def link_html_to_content_groups_and_publish(self):

    container_page = self.go_to_unit_page()
    def set_visibility(html_block_index, groups):
        '\n                                                Set    visibility    on    html    blocks    to    specified    groups.\n                                                '
        html_block = container_page.xblocks[html_block_index]
        html_block.edit_visibility()
        visibility_dialog = XBlockVisibilityEditorView(self.browser, html_block.locator)
        visibility_dialog.select_groups_in_partition_scheme(visibility_dialog.CONTENT_GROUP_PARTITION, groups)
    set_visibility(1, [self.content_group_a])
    set_visibility(2, [self.content_group_b])
    set_visibility(3, [self.content_group_a, self.content_group_b])
    container_page.publish_action.click()
