2022-12-14 09:15:46 -08:00
|
|
|
import pytest
|
|
|
|
from pytest_django.asserts import assertContains, assertNotContains
|
|
|
|
|
|
|
|
from core.models.config import Config
|
|
|
|
from users.models import Follow
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.django_db
|
|
|
|
def test_stats(client, identity, other_identity):
|
|
|
|
"""
|
|
|
|
Tests that follow stats are visible
|
|
|
|
"""
|
|
|
|
Follow.objects.create(source=other_identity, target=identity)
|
|
|
|
Config.set_identity(identity, "visible_follows", True)
|
|
|
|
response = client.get(identity.urls.view)
|
2022-12-21 11:57:14 -08:00
|
|
|
assertContains(response, "<strong>1</strong> follower", status_code=200)
|
2022-12-14 09:15:46 -08:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.django_db
|
|
|
|
def test_visible_follows_disabled(client, identity):
|
|
|
|
"""
|
|
|
|
Tests that disabling visible follows hides it from profile
|
|
|
|
"""
|
2022-12-21 12:36:10 -08:00
|
|
|
Config.set_identity(identity, "visible_follows", True)
|
|
|
|
response = client.get(identity.urls.view)
|
2023-02-04 10:55:48 -08:00
|
|
|
assertContains(response, 'follower', status_code=200)
|
2022-12-14 09:15:46 -08:00
|
|
|
Config.set_identity(identity, "visible_follows", False)
|
|
|
|
response = client.get(identity.urls.view)
|
2023-02-04 10:55:48 -08:00
|
|
|
assertNotContains(response, 'follower', status_code=200)
|