(self)
| 160 | self.assertEqual(response.status_code, 200) |
| 161 | |
| 162 | def test_image(self): |
| 163 | import requests |
| 164 | rsp = requests.get( |
| 165 | 'https://www.python.org/static/img/python-logo.png') |
| 166 | imagepath = os.path.join(settings.BASE_DIR, 'python.png') |
| 167 | with open(imagepath, 'wb') as file: |
| 168 | file.write(rsp.content) |
| 169 | rsp = self.client.post('/upload') |
| 170 | self.assertEqual(rsp.status_code, 403) |
| 171 | sign = get_sha256(get_sha256(settings.SECRET_KEY)) |
| 172 | with open(imagepath, 'rb') as file: |
| 173 | imgfile = SimpleUploadedFile( |
| 174 | 'python.png', file.read(), content_type='image/jpg') |
| 175 | form_data = {'python.png': imgfile} |
| 176 | rsp = self.client.post( |
| 177 | '/upload?sign=' + sign, form_data, follow=True) |
| 178 | self.assertEqual(rsp.status_code, 200) |
| 179 | os.remove(imagepath) |
| 180 | from djangoblog.utils import save_user_avatar, send_email |
| 181 | send_email(['qq@qq.com'], 'testTitle', 'testContent') |
| 182 | save_user_avatar( |
| 183 | 'https://www.python.org/static/img/python-logo.png') |
| 184 | |
| 185 | def test_errorpage(self): |
| 186 | rsp = self.client.get('/eee') |
nothing calls this directly
no test coverage detected