(self, items, logs)
| 103 | return crawler |
| 104 | |
| 105 | def _assert_files_downloaded(self, items, logs): |
| 106 | assert len(items) == 1 |
| 107 | assert self.media_key in items[0] |
| 108 | |
| 109 | # check that logs show the expected number of successful file downloads |
| 110 | file_dl_success = "File (downloaded): Downloaded file from" |
| 111 | assert logs.count(file_dl_success) == 3 |
| 112 | |
| 113 | # check that the images/files status is `downloaded` |
| 114 | for item in items: |
| 115 | for i in item[self.media_key]: |
| 116 | assert i["status"] == "downloaded" |
| 117 | |
| 118 | # check that the images/files checksums are what we know they should be |
| 119 | if self.expected_checksums is not None: |
| 120 | checksums = {i["checksum"] for item in items for i in item[self.media_key]} |
| 121 | assert checksums == self.expected_checksums |
| 122 | |
| 123 | # check that the image files where actually written to the media store |
| 124 | for item in items: |
| 125 | for i in item[self.media_key]: |
| 126 | assert (self.tmpmediastore / i["path"]).exists() |
| 127 | |
| 128 | def _assert_files_download_failure(self, crawler, items, code, logs): |
| 129 | # check that the item does NOT have the "images/files" field populated |
no outgoing calls
no test coverage detected