diff options
author | Rogelio Mita <rogeliomita@activitycentral.com> | 2013-09-19 19:18:00 (GMT) |
---|---|---|
committer | Rogelio Mita <rogeliomita@activitycentral.com> | 2013-09-19 19:19:07 (GMT) |
commit | 600d3235cda58e6c8a862ececbac1705951879bd (patch) | |
tree | 414f6fca66c5b6bcc949f0a873ef73bc385b6da8 /webapp/polls/tests/structure_tests.py | |
parent | 1851df5bc6b0bb69e2c4f32bed4643b7d21bc277 (diff) |
Cleaning tmp directory for option images
Diffstat (limited to 'webapp/polls/tests/structure_tests.py')
-rw-r--r-- | webapp/polls/tests/structure_tests.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/webapp/polls/tests/structure_tests.py b/webapp/polls/tests/structure_tests.py index 2f793c6..7508248 100644 --- a/webapp/polls/tests/structure_tests.py +++ b/webapp/polls/tests/structure_tests.py @@ -372,5 +372,31 @@ class UploadOptionImagesTest(MongoTestCase): saved_on_disk = os.path.exists(os.path.join(images_dir, img_filename)) self.assertTrue(saved_on_disk) + def test_save_imgs_when_exists_a_valid_structure_with_temp_imgs(self): + option_id = self.option_id + poll = self.poll + data = self.data + data_option = data['groups']['0']['fields']['0']['options'][option_id] + img_filename = self.img_filename + img = self.img + + data_option['img'] = img + structure = Structure(data=data, poll=poll) + structure.save_image_options(tmp=True) + images_tmp_dir = structure.get_image_options_tmp_path() + saved_on_tmp_dir = os.path.exists( + os.path.join(images_tmp_dir, img_filename)) + self.assertTrue(saved_on_tmp_dir) + + data = structure.to_python() + structure = Structure(data=data, poll=poll) + structure.save_image_options(tmp=False) + + images_dir = structure.get_image_options_path() + saved_on_right_place = os.path.exists( + os.path.join(images_dir, img_filename)) + self.assertTrue(saved_on_right_place) + self.assertFalse(os.path.exists(images_tmp_dir)) + def tearDown(self): remove_option_images_dir() |