Example #1
0
    def test_temp_writes(self):
        django_read_only.disable_writes()

        with django_read_only.temp_writes():
            Site.objects.create(domain="example.org", name="Example org")

        with pytest.raises(django_read_only.DjangoReadOnlyError):
            Site.objects.create(domain="example.co", name="Example co")
Example #2
0
    def test_disable_writes_allows_atomics_around_reads(self):
        django_read_only.disable_writes()

        with transaction.atomic():
            Site.objects.count()
Example #3
0
    def test_disable_writes_allows_newline_prefix(self):
        django_read_only.disable_writes()

        with connection.cursor() as cursor:
            cursor.execute("\nSELECT 1")
Example #4
0
    def test_disable_writes_allows_selects(self):
        django_read_only.disable_writes()

        Site.objects.count()
Example #5
0
    def test_disable_writes_allows_union(self):
        django_read_only.disable_writes()

        Site.objects.order_by().union(Site.objects.order_by()).count()