Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@pytest.mark.django_db
def test_subscription_list_template(admin_client):
"""Tests for proper subscription_list template."""
response = admin_client.get(reverse('dfs_subscription_list'))
assert (
'subscriptions/subscription_list.html' in [
t.name for t in response.templates
]
@pytest.mark.django_db
def test_tinycontentfile_slug(file_upload):
assert "foobar" == file_upload.slug
import pytest
from api.base.settings.defaults import API_BASE
from osf.models import RegistrationSchema
from osf_tests.factories import (
AuthUserFactory,
)
pytestmark = pytest.mark.django_db
SCHEMA_VERSION = 2
@pytest.fixture()
def user():
return AuthUserFactory()
@pytest.fixture()
def schema():
return RegistrationSchema.objects.filter(
name='Prereg Challenge',
schema_version=SCHEMA_VERSION
).first()
class TestDeprecatedMetaSchemaDetail:
@pytest.mark.django_db
def test_plan_cost_display_billing_frequency_text_hour_singular():
"""Tests display_billing_frequency_text for singular per hour billing."""
plan = models.SubscriptionPlan.objects.create(
plan_name='Test Plan',
plan_description='This is a test plan',
)
cost = models.PlanCost.objects.create(
plan=plan, recurrence_period=1, recurrence_unit=models.HOUR
)
assert cost.display_billing_frequency_text == 'per hour'
@pytest.mark.django_db(transaction=False)
def test_category_db_queries():
"""
Tests that only the following db queries are done:
* 1 requests to get the list of all categories.
"""
for index in range(10):
Category.objects.create(name=f"category{index}")
assert count_queries(Category.get_elements) == 1
@pytest.mark.django_db
def test_command_list():
out = six.StringIO()
call_command('triggers', 'list', stdout=out)
out.seek(0)
output = out.read()
assert output.find('concurrency_demo_triggerconcurrentmodel_i')
assert output.find('concurrency_demo_triggerconcurrentmodel_u')
@pytest.mark.django_db
def test_video_valid_extension(self, game_created):
video = VideoFactory.build(game=game_created)
video.save()
assert Video.objects.last() == video
@pytest.mark.django_db
def test_data_tool_obsolete_resurrect_store(store0):
assert store0.check_data.count()
orig_stats = store0.data_tool.get_stats()
store0.makeobsolete()
assert store0.data.total_words == 0
assert store0.data.critical_checks == 0
assert not store0.check_data.count()
assert store0.data_tool.get_stats() != orig_stats
assert store0.data.max_unit_revision
store0.resurrect()
assert store0.data.total_words
assert store0.check_data.count()
assert store0.data.critical_checks
@pytest.mark.django_db
def test_settings(client):
assert_query(client, 'settings')
from unittest import mock
import pytest
from django.test import Client
from django.urls import reverse
from apps.public.journal.views_compat import get_fedora_ids_from_url_kwargs
from erudit.fedora import repository
from erudit.test.factories import IssueFactory, ArticleFactory
from erudit.test.factories import JournalFactory
pytestmark = pytest.mark.django_db
def test_can_redirect_to_retro_for_unknown_urls():
url = '/fr/test/unknown'
response = Client().get(url)
assert response.status_code == 301
@pytest.mark.django_db
class TestCanRedirectToRetro:
def test_can_redirect_to_retro_for_unknown_urls(self):
# Setup
url = '/fr/test/unknown'
# Run
response = Client().get(url)
# Check