Skip to content

Commit b3c2eb8

Browse files
committed
Explicitly state app name in TestMigraitons
* The code used to determine the name of the django app to perform test migrations on is a bit arcane * By explicitly stating the app name, you can move the data migration test file to any location Signed-off-by: Jono Yang <[email protected]>
1 parent 83b2bc6 commit b3c2eb8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

vulnerabilities/tests/test_data_migrations.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818
class TestMigrations(TestCase):
1919
@property
2020
def app(self):
21-
return apps.get_containing_app_config(type(self).__module__).name
21+
return apps.get_containing_app_config(self.app_name).name
2222

23+
app_name = None
2324
migrate_from = None
2425
migrate_to = None
2526

@@ -51,6 +52,7 @@ def setUpBeforeMigration(self, apps):
5152

5253

5354
class DuplicateSeverityTestCase(TestMigrations):
55+
app_name = "vulnerabilities"
5456
migrate_from = "0013_auto_20220503_0941"
5557
migrate_to = "0014_remove_duplicate_severities"
5658

@@ -95,6 +97,7 @@ def test_remove_duplicate_rows(self):
9597

9698

9799
class DropVulnerabilityFromSeverityTestCase(TestMigrations):
100+
app_name = "vulnerabilities"
98101
migrate_from = "0014_remove_duplicate_severities"
99102
migrate_to = "0015_alter_vulnerabilityseverity_unique_together_and_more"
100103

@@ -114,6 +117,7 @@ def test_dropping_vulnerability_from_severity(self):
114117

115118

116119
class UpdateCPEURL(TestMigrations):
120+
app_name = "vulnerabilities"
117121
migrate_from = "0015_alter_vulnerabilityseverity_unique_together_and_more"
118122
migrate_to = "0016_update_cpe_url"
119123

@@ -138,6 +142,7 @@ def test_cpe_url_update(self):
138142

139143

140144
class TestCvssVectorMigrationToScoringElementComputeNewScores(TestMigrations):
145+
app_name = "vulnerabilities"
141146
migrate_from = "0031_vulnerabilityseverity_scoring_elements"
142147
migrate_to = "0032_vulnerabilityseverity_merge_cvss_score_and_vector"
143148

@@ -240,6 +245,7 @@ def test_compute_cvss(self):
240245

241246

242247
class TestCvssVectorMigrationToScoringElementMergeRows(TestMigrations):
248+
app_name = "vulnerabilities"
243249
migrate_from = "0031_vulnerabilityseverity_scoring_elements"
244250
migrate_to = "0032_vulnerabilityseverity_merge_cvss_score_and_vector"
245251

@@ -448,6 +454,7 @@ def test_merge_rows(self):
448454

449455

450456
class TestCvssVectorMigrationToScoringElementMergeRowsWithDupes(TestMigrations):
457+
app_name = "vulnerabilities"
451458
migrate_from = "0031_vulnerabilityseverity_scoring_elements"
452459
migrate_to = "0032_vulnerabilityseverity_merge_cvss_score_and_vector"
453460

0 commit comments

Comments
 (0)