コード例 #1
0
 def test_get_resource_types(self):
     command = DeleteRedundantStaticCommand()
     expected = {
         RESOURCE_TYPES['RAW'], RESOURCE_TYPES['IMAGE'],
         RESOURCE_TYPES['VIDEO']
     }
     self.assertEqual(expected, command.get_resource_types())
コード例 #2
0
 def test_get_needful_files_with_keep_unhashed_files_false(self):
     command = DeleteRedundantStaticCommand()
     command.keep_unhashed_files = False
     expected_response = {
         'static/tests/css/style.{}.css'.format(self.style_hash),
         'static/tests/images/dummy-static-image.{}'.format(
             self.image_hash)  # removed jpg extension
     }
     self.assertEqual(command.get_needful_files(), expected_response)
コード例 #3
0
 def test_command_removes_not_needed_file(self):
     command = DeleteRedundantStaticCommand()
     uploaded_resources = [(RESOURCE_TYPES['RAW'], ['style1.css']),
                           (RESOURCE_TYPES['IMAGE'], []),
                           (RESOURCE_TYPES['VIDEO'], [])]
     needful_files = {'style.css'}
     with mock.patch.object(command,
                            'get_uploaded_resources',
                            return_value=uploaded_resources):
         with mock.patch.object(command,
                                'get_needful_files',
                                return_value=needful_files):
             files_to_remove = command.get_files_to_remove()
     expected_response = {
         RESOURCE_TYPES['RAW']: {'style1.css'},
         RESOURCE_TYPES['IMAGE']: set(),
         RESOURCE_TYPES['VIDEO']: set()
     }
     self.assertEqual(files_to_remove, expected_response)
コード例 #4
0
 def test_get_exclude_paths_returns_empty_tuple(self):
     command = DeleteRedundantStaticCommand()
     self.assertEqual(command.get_exclude_paths(), ())
コード例 #5
0
 def test_get_file_storage(self):
     command = DeleteRedundantStaticCommand()
     storage = command.get_file_storage(RESOURCE_TYPES['IMAGE'])
     self.assertEqual(storage, command.storage)