-
-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test and new model to test in example app
- Loading branch information
Showing
9 changed files
with
101 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
project/example_app/migrations/0004_category_blind_category.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Generated by Django 4.1.3 on 2022-11-19 17:10 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("example_app", "0003_blind_unique_name_if_provided"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="Category", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("name", models.CharField(max_length=50)), | ||
], | ||
), | ||
migrations.AddField( | ||
model_name="blind", | ||
name="category", | ||
field=models.ForeignKey( | ||
null=True, | ||
blank=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
to="example_app.category", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from django.test import TestCase | ||
|
||
from silk.config import SilkyConfig | ||
from silk.middleware import silky_reverse | ||
|
||
from .test_lib.mock_suite import MockSuite | ||
|
||
|
||
class TestViewSQL(TestCase): | ||
@classmethod | ||
def setUpClass(cls): | ||
super().setUpClass() | ||
SilkyConfig().SILKY_AUTHENTICATION = False | ||
SilkyConfig().SILKY_AUTHORISATION = False | ||
|
||
def test_duplicates_should_show(self): | ||
"""Generate a lot of duplicates and test that they are visible on the page""" | ||
request = MockSuite().mock_request() | ||
request.queries.all().delete() | ||
# Ensure we have a amount of queries with the same structure | ||
query = MockSuite().mock_sql_queries(request=request, n=1)[0] | ||
for _ in range(0, 4): | ||
query.id = None | ||
query.save() | ||
url = silky_reverse('request_sql', kwargs={'request_id': request.id}) | ||
response = self.client.get(url) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertContains(response, '<td class="right-aligned">4</td>') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters