|
6 | 6 |
|
7 | 7 | # first party |
8 | 8 | from delphi_changehc.download_ftp_files import * |
| 9 | +from delphi_changehc.constants import EXPECTED_FILES_PER_DROP |
9 | 10 |
|
10 | 11 | class TestDownloadFTPFiles: |
11 | 12 |
|
@@ -51,22 +52,18 @@ def test_get_files(self, mock_path): |
51 | 52 | get_files_from_dir(one_new_one_old, "00005566", "") |
52 | 53 | assert one_new_one_old.num_gets == 1 |
53 | 54 |
|
54 | | - # When seven new files are present, AssertionError |
55 | | - new_file1 = self.FileAttr(dt.timestamp(dt.now()), "00001122_foo1") |
56 | | - new_file2 = self.FileAttr(dt.timestamp(dt.now()), "00001122_foo2") |
57 | | - new_file3 = self.FileAttr(dt.timestamp(dt.now()), "00001122_foo3") |
58 | | - new_file4 = self.FileAttr(dt.timestamp(dt.now()), "00001122_foo4") |
59 | | - new_file5 = self.FileAttr(dt.timestamp(dt.now()), "00001122_foo5") |
60 | | - new_file6 = self.FileAttr(dt.timestamp(dt.now()), "00001122_foo6") |
61 | | - new_file7 = self.FileAttr(dt.timestamp(dt.now()), "00001122_foo7") |
62 | | - seven_new = self.MockSFTP([new_file1, new_file2, new_file3, new_file4, |
63 | | - new_file5, new_file6, new_file7]) |
| 55 | + # When too many new files are present, AssertionError |
| 56 | + file_batch = [ |
| 57 | + self.FileAttr(dt.timestamp(dt.now()), f"00001122_foo{i}") |
| 58 | + for i in range(EXPECTED_FILES_PER_DROP + 1) |
| 59 | + ] |
| 60 | + too_many_new = self.MockSFTP(file_batch) |
64 | 61 | with pytest.raises(AssertionError): |
65 | | - get_files_from_dir(seven_new, "00001122", "") |
| 62 | + get_files_from_dir(too_many_new, "00001122", "") |
66 | 63 |
|
67 | 64 | # When the file already exists, no files are downloaded |
68 | 65 | mock_path.exists.return_value = True |
69 | | - one_exists = self.MockSFTP([new_file1]) |
| 66 | + one_exists = self.MockSFTP([file_batch[0]]) |
70 | 67 | get_files_from_dir(one_new, "00001122", "") |
71 | 68 | assert one_exists.num_gets == 0 |
72 | 69 |
|
0 commit comments