示例#1
0
    def check_privacy_status(video_id1,
                             is_private,
                             check_db=True,
                             check_api=False):
        with django_db_blocker.unblock():
            Video.recompute_computed_properties(only_pending=True)

        priv_public = 'private' if is_private else 'public'
        WebDriverWait(driver, TIME_WAIT).until(
            EC.presence_of_element_located(
                (By.ID, f'id_video_{video_id1}_{priv_public}')))

        if check_db:
            with django_db_blocker.unblock():
                get_object_with_timeout(VideoRatingPrivacy,
                                        video__video_id=video_id1,
                                        user=up,
                                        is_public=not is_private)

        if check_api:
            pe = do_api_call_v2(driver, '/videos/?video_id=' +
                                video_id1)['results'][0]['public_experts']
            if is_private:
                assert len(pe) == 0
            else:
                assert len(pe) == 1, pe
                assert pe[0]['username'] == test_username
示例#2
0
def test_rate_confidence(driver, django_db_blocker):
    """Test skips mode."""

    login(driver)

    with django_db_blocker.unblock():
        # creating two videos
        video_1_id = create_test_video()
        video_2_id = create_test_video()

        # setting user preferences
        up = UserPreferences.objects.get(user__username=test_username)

        # enabling two features
        for f in VIDEO_FIELDS[:4]:
            setattr(up, f"{f}_enabled", True)
        for f in VIDEO_FIELDS[4:]:
            setattr(up, f"{f}_enabled", False)

        f0, f1 = VIDEO_FIELDS[:2]

        # setting mode to enable_all
        up.rating_mode = "confidence"

        up.save()

    driver.get(web_url + f'/rate/{video_1_id}/{video_2_id}')

    # waiting for the page to load
    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located((By.ID, 'id_no_pending_expert')))

    check_feature_visibility(up, driver)

    # setting stars
    stars_set_value(driver, VIDEO_FIELDS[0] + "_confidence", 0)
    stars_set_value(driver, VIDEO_FIELDS[1] + "_confidence", 1)
    stars_set_value(driver, VIDEO_FIELDS[2] + "_confidence", 2)
    stars_set_value(driver, VIDEO_FIELDS[3] + "_confidence", 3)

    print("Submitting the rating...")
    expert_submit_btn = driver.find_element_by_id('expert_submit_btn')
    expert_submit_btn.click()

    with django_db_blocker.unblock():
        obj = get_object_with_timeout(ExpertRating,
                                      video_1__video_id=video_1_id,
                                      video_2__video_id=video_2_id,
                                      user__user__username=test_username)

        # checking weight
        assert getattr(obj, f"{VIDEO_FIELDS[0]}_weight") == 0.0
        assert getattr(obj, f"{VIDEO_FIELDS[1]}_weight") == 0.5
        assert getattr(obj, f"{VIDEO_FIELDS[2]}_weight") == 1.0
        assert getattr(obj, f"{VIDEO_FIELDS[3]}_weight") == 1.5
        for f in VIDEO_FIELDS[4:]:
            assert getattr(obj, f"{f}_weight") == 0.0

        # now, setting second value to None
        setattr(obj, VIDEO_FIELDS[1], None)
        obj.save()

    # editing the rating with default None values and wrong weights
    driver.refresh()

    # waiting for the page to load
    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located((By.ID, 'id_no_pending_expert')))

    print("Submitting the rating...")
    expert_submit_btn = driver.find_element_by_id('expert_submit_btn')
    expert_submit_btn.click()

    with django_db_blocker.unblock():
        obj = get_object_with_timeout(
            ExpertRating,
            video_1__video_id=video_1_id,
            video_2__video_id=video_2_id,
            user__user__username=test_username,
            **{VIDEO_FIELDS[0] + "_weight__lte": 0.5})

        # checking that weights are 1 for the first feature and 0 for the rest
        assert getattr(obj, f"{VIDEO_FIELDS[0]}_weight") == 0.0
        assert getattr(obj, f"{VIDEO_FIELDS[1]}_weight") == 0.0
        assert getattr(obj, f"{VIDEO_FIELDS[2]}_weight") == 1.0
        assert getattr(obj, f"{VIDEO_FIELDS[3]}_weight") == 1.5
        for f in VIDEO_FIELDS[4:]:
            assert getattr(obj, f"{f}_weight") == 0.0

        assert getattr(obj, VIDEO_FIELDS[0]) is not None

    with django_db_blocker.unblock():
        Video.objects.filter(video_id__in=[video_1_id, video_2_id]).delete()

    logout(driver)
示例#3
0
def test_rate_enable_all_weight_none(driver, django_db_blocker):
    """Test all features enabled mode."""

    login(driver)

    with django_db_blocker.unblock():
        # creating two videos
        video_1_id = create_test_video()
        video_2_id = create_test_video()

        # setting user preferences
        up = UserPreferences.objects.get(user__username=test_username)

        # disabling all features, except for the first one
        setattr(up, f"{VIDEO_FIELDS[0]}_enabled", True)
        for f in VIDEO_FIELDS[1:]:
            setattr(up, f"{f}_enabled", False)

        # setting mode to enable_all
        up.rating_mode = "enable_all"

        up.save()

    driver.get(web_url + f'/rate/{video_1_id}/{video_2_id}')

    # waiting for the page to load
    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located((By.ID, 'id_no_pending_expert')))

    check_feature_visibility(up, driver)

    print("Submitting the rating...")
    expert_submit_btn = driver.find_element_by_id('expert_submit_btn')
    expert_submit_btn.click()

    with django_db_blocker.unblock():
        obj = get_object_with_timeout(ExpertRating,
                                      video_1__video_id=video_1_id,
                                      video_2__video_id=video_2_id,
                                      user__user__username=test_username)

        # checking that weights are 1 for the first feature and 0 for the rest
        for i, f in enumerate(VIDEO_FIELDS):
            val = 1.0 if (i == 0) else 0.0
            assert getattr(obj, f"{f}_weight") == val

        # now, setting first value to None
        # and first weight to None

        setattr(obj, VIDEO_FIELDS[0], None)
        setattr(obj, VIDEO_FIELDS[0] + "_weight", 0.0)
        obj.save()

    # editing the rating with default None values and wrong weights
    driver.refresh()

    print(video_1_id, video_2_id)

    # waiting for the page to load
    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located((By.ID, 'id_no_pending_expert')))

    print("Submitting the rating...")
    expert_submit_btn = driver.find_element_by_id('expert_submit_btn')
    expert_submit_btn.click()

    with django_db_blocker.unblock():
        obj = get_object_with_timeout(ExpertRating,
                                      video_1__video_id=video_1_id,
                                      video_2__video_id=video_2_id,
                                      user__user__username=test_username,
                                      **{VIDEO_FIELDS[0] + "_weight__gt": 0.5})

        # checking that weights are 1 for the first feature and 0 for the rest
        for i, f in enumerate(VIDEO_FIELDS):
            val = 1.0 if (i == 0) else 0.0
            assert getattr(obj, f"{f}_weight") == val

        assert getattr(obj, VIDEO_FIELDS[0]) is not None

    with django_db_blocker.unblock():
        Video.objects.filter(video_id__in=[video_1_id, video_2_id]).delete()

    logout(driver)
示例#4
0
def test_rate_skips(driver, django_db_blocker):
    """Test skips mode."""

    login(driver)

    with django_db_blocker.unblock():
        # creating two videos
        video_1_id = create_test_video()
        video_2_id = create_test_video()

        # setting user preferences
        up = UserPreferences.objects.get(user__username=test_username)

        # enabling two features
        for f in VIDEO_FIELDS[:2]:
            setattr(up, f"{f}_enabled", True)
        for f in VIDEO_FIELDS[2:]:
            setattr(up, f"{f}_enabled", False)

        f0, f1 = VIDEO_FIELDS[:2]

        # setting mode to enable_all
        up.rating_mode = "skip"

        up.save()

    driver.get(web_url + f'/rate/{video_1_id}/{video_2_id}')

    # waiting for the page to load
    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located((By.ID, 'id_no_pending_expert')))

    check_feature_visibility(up, driver)

    # checkboxes should be unchecked
    elem0 = driver.find_element_by_id("id_checkbox_skip_" + f0)
    elem1 = driver.find_element_by_id("id_checkbox_skip_" + f1)
    assert elem0.get_property('checked') is False
    assert elem1.get_property('checked') is False

    elem1.click()

    print("Submitting the rating...")
    expert_submit_btn = driver.find_element_by_id('expert_submit_btn')
    expert_submit_btn.click()

    with django_db_blocker.unblock():
        obj = get_object_with_timeout(ExpertRating,
                                      video_1__video_id=video_1_id,
                                      video_2__video_id=video_2_id,
                                      user__user__username=test_username)

        # checking that weights are 1 for the first feature and 0 for the rest
        for i, f in enumerate(VIDEO_FIELDS):
            val = 1.0 if (i == 0) else 0.0
            assert getattr(obj, f"{f}_weight") == val

        # now, setting first value to None

        setattr(obj, VIDEO_FIELDS[0], None)
        obj.save()

    # editing the rating with default None values and wrong weights
    driver.refresh()

    # waiting for the page to load
    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located((By.ID, 'id_no_pending_expert')))

    elem0 = driver.find_element_by_id("id_checkbox_skip_" + f0)
    elem1 = driver.find_element_by_id("id_checkbox_skip_" + f1)
    assert elem0.get_property('checked') is True
    assert elem1.get_property('checked') is True

    print("Submitting the rating...")
    expert_submit_btn = driver.find_element_by_id('expert_submit_btn')
    expert_submit_btn.click()

    with django_db_blocker.unblock():
        obj = get_object_with_timeout(
            ExpertRating,
            video_1__video_id=video_1_id,
            video_2__video_id=video_2_id,
            user__user__username=test_username,
            **{VIDEO_FIELDS[0] + "_weight__lte": 0.5})

        # checking that weights are 1 for the first feature and 0 for the rest
        for i, f in enumerate(VIDEO_FIELDS):
            assert getattr(obj, f"{f}_weight") == 0.0

        assert getattr(obj, VIDEO_FIELDS[0]) is not None

    with django_db_blocker.unblock():
        Video.objects.filter(video_id__in=[video_1_id, video_2_id]).delete()

    logout(driver)
示例#5
0
def test_insert_video_id(driver, django_db_blocker):
    """Test that we can insert videos into the Video ID field in VideoSelector."""

    cleanup_rate_later(django_db_blocker)
    set_all_features_enabled(django_db_blocker)

    # format: text to insert -> resulting stored ID or None if no record should exist
    ids_to_insert = {
        'https://www.youtube.com/watch?v=gU-mkuMU428&ab_channel=LexFridman':
        'gU-mkuMU428',
        'https://youtu.be/gU-mkuMU428':
        'gU-mkuMU428',
        'https://www.youtube.com/embed/gU-mkuMU428':
        'gU-mkuMU428',
        'gU-mkuMU428':
        'gU-mkuMU428',
        '@@@-':
        '-',
        'ghslkdfjghklsdjfghksldjfdskljfghskdljfghlskdjfghsldkfjghsldkfjghsfldgjkshdlkfg':
        'ghslkdfjghklsdjfghks',
        '$$$$$????++++-':
        '-',
        '| rm -rf / ':
        'rm-rf',
        '"""-':
        '-'
    }

    login(driver)

    print("Going to the expert interface...")
    expert_interface_btn = driver.find_element_by_id('expert_interface')
    expert_interface_btn.click()

    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located((By.ID, 'id_expert_rating_page')))

    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located((By.ID, 'id_no_pending_expert')))

    def get_input_elem(vid):
        """Get the input element for a video selector."""
        print("Processing selector", vid)

        WebDriverWait(driver, TIME_WAIT).until(
            EC.presence_of_element_located((By.ID, vid)))

        # refreshing videos
        selector = driver.find_element_by_id(vid)

        WebDriverWait(driver, TIME_WAIT).until(
            EC.presence_of_element_located(
                (By.CLASS_NAME, 'video_id_text_field')))

        print("Obtaining element...")
        elem = selector.find_element_by_class_name('video_id_text_field')
        elem = elem.find_element_by_tag_name('input')

        return elem

    # creating the left video
    with django_db_blocker.unblock():
        video_id_left = create_test_video()

    def process_video_selector(vid, video_enter):
        """Load new video."""
        elem = get_input_elem(vid)
        elem.clear()
        clipboard.copy(video_enter)
        print("Copying text", video_enter, "into", vid)
        elem.send_keys(Keys.LEFT_CONTROL, "v")

    for text_enter, resulting_id in ids_to_insert.items():
        with django_db_blocker.unblock():
            ExpertRating.objects.filter(
                user__user__username=test_username).delete()

        print("Entering", text_enter, "expecting", resulting_id)

        process_video_selector('video-left', video_id_left)

        WebDriverWait(driver, TIME_WAIT).until(
            EC.presence_of_element_located((By.ID, 'id_no_pending_expert')))

        process_video_selector('video-right', text_enter)

        WebDriverWait(driver, TIME_WAIT).until(
            EC.presence_of_element_located((By.ID, 'id_no_pending_expert')))

        print("Submitting the rating...")
        expert_submit_btn = driver.find_element_by_id('expert_submit_btn')
        expert_submit_btn.click()

        WebDriverWait(driver, TIME_WAIT).until(
            EC.presence_of_element_located((By.ID, 'id_no_pending_expert')))

        WebDriverWait(driver, TIME_WAIT).until(
            EC.presence_of_element_located((By.ID, 'id_no_pending_submit')))

        if resulting_id is not None:
            with django_db_blocker.unblock():
                get_object_with_timeout(ExpertRating,
                                        video_1__video_id=video_id_left,
                                        video_2__video_id=resulting_id,
                                        user__user__username=test_username)
        else:
            with django_db_blocker.unblock():
                assert ExpertRating.objects.filter(
                    user__user__username=test_username).count() == 0

    logout(driver)
def test_rate_later_top_k(driver, django_db_blocker):
    # creating popular videos...
    with django_db_blocker.unblock():

        # determining current max views...
        max_views = 0
        if Video.objects.all().count() > 0:
            max_views = Video.objects.all().aggregate(Max(F('views')))['views__max']

        video_ids = [random_alphanumeric() for _ in range(n_top_popular)]
        Video.objects.bulk_create([Video(video_id=vid, views=max_views + 1)
                                   for vid in video_ids])
        VideoRateLater.objects.filter(user__user__username=test_username).delete()
        video_ids_set = set(video_ids)

    login(driver)

    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located((By.ID, 'rate_later_menu')))

    print("Going to the rate later page")
    expert_interface_btn = driver.find_element_by_id('rate_later_menu')
    expert_interface_btn.click()

    assert not element_present_now(driver, 'id_controls_prev_next')
    assert not element_present_now(driver, 'id_big_expert_interface')

    def add_from_topk():
        # requesting new video
        WebDriverWait(driver, TIME_WAIT).until(
            EC.presence_of_element_located((By.CLASS_NAME, 'new_video_button')))

        elems = driver.find_elements_by_class_name('new_video_button')
        assert len(elems) == 1
        elems[0].click()

        WebDriverWait(driver, TIME_WAIT).until(
            EC.presence_of_element_located((By.ID, 'id_top_video_videocard')))

        WebDriverWait(driver, TIME_WAIT).until(
            EC.presence_of_element_located((By.ID, 'id_big_add_rate_later')))

        driver.find_element_by_id('id_big_add_rate_later').click()

        WebDriverWait(driver, TIME_WAIT).until(
            EC.presence_of_element_located((By.ID, 'id_rate_later_submit_ok')))

        with django_db_blocker.unblock():
            ids_vrl = list(VideoRateLater.objects.filter(
                user__user__username=test_username).values('video__video_id'))
            ids_vrl = [x['video__video_id'] for x in ids_vrl]
        assert set(ids_vrl).issubset(video_ids_set)
        return len(ids_vrl)

    for i in range(1, minNumRateLater + 2):
        assert add_from_topk() == i

        if i >= minNumRateLater:
            WebDriverWait(driver, TIME_WAIT).until(
                EC.presence_of_element_located((By.ID, 'id_big_expert_interface')))
        else:
            WebDriverWait(driver, TIME_WAIT).until(
                EC.presence_of_element_located((By.ID, 'id_recommend_add_more')))

    # trying to add manually now...

    elem = driver.find_element_by_class_name('video_id_text_field')
    elem = elem.find_element_by_tag_name('input')

    elem.clear()
    elem.send_keys('abacaba')

    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located((By.ID, 'id_big_add_rate_later')))

    driver.find_element_by_id('id_big_add_rate_later').click()

    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located((By.ID, 'id_rate_later_submit_ok')))

    with django_db_blocker.unblock():
        get_object_with_timeout(VideoRateLater, user__user__username=test_username,
                                video__video_id='abacaba')

    logout(driver)
示例#7
0
def test_thank_unthank(driver, django_db_blocker):
    with django_db_blocker.unblock():
        video_id = create_test_video()
        video = Video.objects.get(video_id=video_id)

        video_id1 = create_test_video()
        video1 = Video.objects.get(video_id=video_id1)

        domain = EmailDomain.objects.create(status=EmailDomain.STATUS_ACCEPTED,
                                            domain="@" +
                                            random_alphanumeric() + ".com")

        # creating a certified user with ratings of the video
        other_user = DjangoUser.objects.create_user(
            username=random_alphanumeric(), is_active=True)
        oup = UserPreferences.objects.create(user=other_user)
        oui = UserInformation.objects.create(user=other_user)

        ExpertRating.objects.create(user=oup, video_1=video, video_2=video1)

        ve = VerifiableEmail.objects.create(user=oui,
                                            email="aba" + domain.domain,
                                            is_verified=True)

    login(driver)

    open_more_menu(driver)

    WebDriverWait(driver, TIME_WAIT).until(
        EC.visibility_of_element_located((By.ID, 'video_details_menu')))

    print("Going to the details page")
    expert_interface_btn = driver.find_element_by_id('video_details_menu')
    expert_interface_btn.click()

    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located((By.CLASS_NAME, 'video_id_text_field')))

    elem = driver.find_element_by_class_name('video_id_text_field')
    elem = elem.find_element_by_tag_name('input')

    # setting the video ID
    elem.clear()
    elem.send_keys(video_id, Keys.HOME)
    if elem.get_attribute('value') != video_id:
        elem.send_keys(3 * [Keys.DELETE])

    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located((By.ID, f'id_{video_id}_thank')))

    driver.find_element_by_id(f'id_{video_id}_thank').click()

    with django_db_blocker.unblock():
        assert get_object_with_timeout(
            VideoRatingThankYou,
            video__video_id=video_id,
            thanks_from__user__username=test_username,
            thanks_to__user__username=other_user.username)
    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located((By.ID, f'id_{video_id}_unthank')))

    driver.find_element_by_id(f'id_{video_id}_unthank').click()

    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located((By.ID, f'id_{video_id}_thank')))

    with django_db_blocker.unblock():
        assert VideoRatingThankYou.objects.filter(
            video__video_id=video_id,
            thanks_from__user__username=test_username,
            thanks_to__user__username=other_user.username).count() == 0

    logout(driver)

    with django_db_blocker.unblock():
        Video.objects.filter(video_id=video_id).delete()
        Video.objects.filter(video_id=video_id1).delete()

        ve.delete()
        other_user.delete()
示例#8
0
def test_mention(driver, django_db_blocker):
    login(driver)

    with django_db_blocker.unblock():
        video_id = create_test_video()
        domain = EmailDomain.objects.create(status=EmailDomain.STATUS_ACCEPTED,
                                            domain="@" +
                                            random_alphanumeric() + ".com")
        ve = VerifiableEmail.objects.create(
            user=UserInformation.objects.get(user__username=test_username),
            email="aba" + domain.domain,
            is_verified=True)

    open_more_menu(driver)

    WebDriverWait(driver, TIME_WAIT).until(
        EC.visibility_of_element_located((By.ID, 'video_details_menu')))

    print("Going to the details page")
    expert_interface_btn = driver.find_element_by_id('video_details_menu')
    expert_interface_btn.click()

    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located((By.CLASS_NAME, 'video_id_text_field')))

    elem = driver.find_element_by_class_name('video_id_text_field')
    elem = elem.find_element_by_tag_name('input')

    # setting the video ID
    elem.clear()
    elem.send_keys(video_id, Keys.HOME)
    if elem.get_attribute('value') != video_id:
        elem.send_keys(3 * [Keys.DELETE])

    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located(
            (By.CLASS_NAME, f'comment_editor_{video_id}_undefined')))

    # sending the comment
    editor = driver.find_element_by_class_name(
        f'comment_editor_{video_id}_undefined')
    editor.find_element_by_class_name('public-DraftEditor-content').send_keys(
        '@' + test_username)

    # selecting the mention suggestion
    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located(
            (By.CLASS_NAME, 'rdw-suggestion-option')))

    elems = driver.find_elements_by_class_name('rdw-suggestion-option')
    elems = [x for x in elems if test_username in x.text]
    assert len(elems) == 1

    WebDriverWait(driver, TIME_WAIT).until(EC.visibility_of(elems[0]))

    elems[0].click()

    action = webdriver.common.action_chains.ActionChains(driver)
    action.move_to_element_with_offset(elems[0], elems[0].rect['width'] / 2,
                                       elems[0].rect['height'] / 2)
    action.click()
    action.perform()
    WebDriverWait(driver,
                  TIME_WAIT).until(EC.invisibility_of_element(elems[0]))

    driver.find_elements_by_class_name(
        f'comment_editor_submit_{video_id}_undefined')[0].click()

    with django_db_blocker.unblock():
        assert get_object_with_timeout(VideoComment, video__video_id=video_id)

    # going to mentions...
    driver.find_element_by_id('personal_info_menu').click()

    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located((By.ID, 'id_mentions')))

    driver.find_element_by_id('id_mentions').click()

    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located(
            (By.CLASS_NAME, 'class_li_comment_mention')))

    assert len(
        driver.find_elements_by_class_name('class_li_comment_mention')) == 1

    logout(driver)

    with django_db_blocker.unblock():
        Video.objects.filter(video_id=video_id).delete()
        ve.delete()
示例#9
0
def test_comments(driver, django_db_blocker):
    # creating a video

    with django_db_blocker.unblock():
        video_id = create_test_video()

    login(driver)

    open_more_menu(driver)

    with django_db_blocker.unblock():
        UserInformation.objects.filter(user__username=test_username).update(
            comment_anonymously=False)

    WebDriverWait(driver, TIME_WAIT).until(
        EC.visibility_of_element_located((By.ID, 'video_details_menu')))

    print("Going to the details page")
    expert_interface_btn = driver.find_element_by_id('video_details_menu')
    expert_interface_btn.click()

    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located((By.CLASS_NAME, 'video_id_text_field')))

    elem = driver.find_element_by_class_name('video_id_text_field')
    elem = elem.find_element_by_tag_name('input')

    # setting the video ID
    elem.clear()
    elem.send_keys(video_id, Keys.HOME)
    if elem.get_attribute('value') != video_id:
        elem.send_keys(3 * [Keys.DELETE])

    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located(
            (By.CLASS_NAME, f'comment_editor_{video_id}_undefined')))

    # sending the comment
    editor = driver.find_element_by_class_name(
        f'comment_editor_{video_id}_undefined')
    editor.find_element_by_class_name('public-DraftEditor-content').send_keys(
        'sdf')
    driver.find_elements_by_class_name(
        f'comment_editor_submit_{video_id}_undefined')[0].click()

    # checking results
    with django_db_blocker.unblock():
        comment = get_object_with_timeout(VideoComment,
                                          video__video_id=video_id,
                                          parent_comment=None)
        assert comment.comment == "<p>sdf</p>"
        assert not comment.anonymous
        cid = VideoComment.objects.filter(video__video_id=video_id).get().id

    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located(
            (By.CLASS_NAME, f'comment_{cid}_reply')))

    # replying to a comment
    driver.find_element_by_class_name(f'comment_{cid}_reply').click()
    driver.find_element_by_class_name(
        f'comment_editor_{video_id}_{cid}').find_element_by_class_name(
            'public-DraftEditor-content').send_keys('aba')
    driver.find_elements_by_class_name(
        f'comment_editor_submit_{video_id}_{cid}')[0].click()

    with django_db_blocker.unblock():
        subcid = get_object_with_timeout(VideoComment,
                                         video__video_id=video_id,
                                         parent_comment__id=cid).id

    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located(
            (By.CLASS_NAME, f'comment_{subcid}_reply')))

    # replying to a reply anonymously
    driver.find_element_by_class_name(f'comment_{subcid}_reply').click()

    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located(
            (By.CLASS_NAME, f'comment_editor_{video_id}_{subcid}')))

    driver.find_element_by_class_name(
        f'comment_editor_{video_id}_{subcid}').find_element_by_class_name(
            'public-DraftEditor-content').send_keys('zzzaaa')
    checkbox = driver.find_element_by_class_name(
        f'anonymous_comment_checkbox_class_{video_id}_{subcid}')
    if not checkbox.find_element_by_tag_name('input').get_property('checked'):
        checkbox.click()
    driver.find_elements_by_class_name(
        f'comment_editor_submit_{video_id}_{subcid}')[0].click()

    with django_db_blocker.unblock():
        assert get_object_with_timeout(
            VideoComment, video__video_id=video_id,
            parent_comment__id=cid).comment == '<p>aba</p>'

        subsubc = get_object_with_timeout(VideoComment,
                                          video__video_id=video_id,
                                          parent_comment_id=subcid)
        assert subsubc.anonymous
        assert subsubc.comment == '<p>zzzaaa</p>'
    # editing the subcomment
    with django_db_blocker.unblock():
        ecid = get_object_with_timeout(VideoComment,
                                       video__video_id=video_id,
                                       parent_comment__id=cid).id

    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located(
            (By.CLASS_NAME, f'comment_{ecid}_edit')))

    driver.find_element_by_class_name(f'comment_{ecid}_edit').click()
    elem = driver.find_element_by_class_name(
        f'comment_editor_cid_{ecid}').find_element_by_class_name(
            'public-DraftEditor-content')

    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located(
            (By.CLASS_NAME, f'comment_editor_cid_{ecid}_editing')))

    elem.click()
    elem.send_keys('xyz')
    WebDriverWait(driver, TIME_WAIT).until(
        EC.presence_of_element_located(
            (By.CLASS_NAME, f'comment_{ecid}_save_edits')))

    driver.find_element_by_class_name(f'comment_{ecid}_save_edits').click()
    with django_db_blocker.unblock():
        assert get_object_with_timeout(
            VideoComment, video__video_id=video_id,
            parent_comment__id=cid).comment.strip() == '<p>xyzaba</p>'

    # comment markers
    with django_db_blocker.unblock():
        assert VideoComment.objects.filter(
            video__video_id=video_id,
            parent_comment__id=cid).get().votes_plus == 0
    driver.find_element_by_class_name(f'vote_plus_comment_{ecid}').click()
    with django_db_blocker.unblock():
        assert VideoComment.objects.filter(
            video__video_id=video_id,
            parent_comment__id=cid).get().votes_plus == 1
    driver.find_element_by_class_name(f'vote_plus_comment_{ecid}').click()
    with django_db_blocker.unblock():
        assert VideoComment.objects.filter(
            video__video_id=video_id,
            parent_comment__id=cid).get().votes_plus == 0

    logout(driver)