Skip to content

Commit b19497d

Browse files
authored
Minor PR to organize migrations (#1851)
* Add missing migration from contract updates * Remove created file so tests can be idempotent
1 parent 743b53b commit b19497d

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Generated by Django 2.0.13 on 2021-08-26 19:29
2+
3+
from django.db import migrations, models
4+
import sponsors.models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
('sponsors', '0034_contract_document_docx'),
11+
]
12+
13+
operations = [
14+
migrations.AlterField(
15+
model_name='contract',
16+
name='document',
17+
field=models.FileField(blank=True, upload_to='sponsors/contracts/', verbose_name='Unsigned PDF'),
18+
),
19+
migrations.AlterField(
20+
model_name='contract',
21+
name='document_docx',
22+
field=models.FileField(blank=True, upload_to='sponsors/contracts/docx/', verbose_name='Unsigned Docx'),
23+
),
24+
migrations.AlterField(
25+
model_name='contract',
26+
name='signed_document',
27+
field=models.FileField(blank=True, upload_to=sponsors.models.signed_contract_random_path, verbose_name='Signed PDF'),
28+
),
29+
]

sponsors/tests/test_use_cases.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import os
12
from unittest.mock import Mock, patch
23
from model_bakery import baker
34
from datetime import timedelta, date
5+
from pathlib import Path
46

57
from django.conf import settings
68
from django.test import TestCase
@@ -186,6 +188,14 @@ def setUp(self):
186188
self.file = SimpleUploadedFile("contract.txt", b"Contract content")
187189
self.contract = baker.make_recipe("sponsors.tests.empty_contract", status=Contract.DRAFT)
188190

191+
def tearDown(self):
192+
try:
193+
signed_file = Path(self.contract.signed_document.path)
194+
if signed_file.exists():
195+
os.remove(str(signed_file.resolve()))
196+
except ValueError:
197+
pass
198+
189199
@patch("sponsors.models.uuid.uuid4", Mock(return_value="1234"))
190200
def test_execute_and_update_database_object(self):
191201
self.use_case.execute(self.contract, self.file)

0 commit comments

Comments
 (0)