Skip to content

Commit

Permalink
remove the tests for file download.
Browse files Browse the repository at this point in the history
I give up. On 0.13.x, import_all_child_modules still lives on, which
makes importing anything under fle_utils/internet *automatically* import
Django, which we don't need and certainly won't run! I can't think of
any way around this other than doing a lot of refactoring, which
violates the code freeze. Either way, this test lives on in develop.
  • Loading branch information
Aron Fyodor Asor committed Apr 22, 2015
1 parent bade2f5 commit 4c65369
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 35 deletions.
32 changes: 0 additions & 32 deletions python-packages/fle_utils/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
import sys
import tempfile
import unittest
from mock import patch, Mock
from unittest import TestCase

import fle_utils.videos as videos
from general import datediff, version_diff, ensure_dir


Expand Down Expand Up @@ -148,35 +146,5 @@ def test_new_dir_after_file(self):
ensure_dir(newdir)
self.assertNotExists(newdir)


class DownloadFileTests(TestCase):

@patch("videos.delete_downloaded_files", Mock)
@patch.object(videos, "delete_downloaded_files", Mock)
@patch.object(videos, "download_file")
def test_downloading_in_right_location(self, download_file_method):

download_file_method.side_effect = [
# During the download_file for videos
(
None, # doesn't matter for this test.
Mock(type="video"), # so download_video will succeed.
),
# For downloading images
(
None,
Mock(type="image"), # so download_video will succeed.
)
]

content_dir = "/tmp"
content_file = "something.mp3"
expected_path = os.path.join(content_dir, content_file)

videos.download_video("something", content_dir, format="mp3")

url, filepath, func = download_file_method.call_args_list[0][0]
self.assertEqual(filepath, expected_path)

if __name__ == '__main__':
sys.exit(unittest.main())
6 changes: 3 additions & 3 deletions python-packages/fle_utils/videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import logging
import os
import socket
from django.conf import settings; logging = settings.LOG

from general import ensure_dir
from internet.download import callback_percent_proxy, download_file, URLNotFound, DownloadCancelled

from .general import ensure_dir
from .internet import callback_percent_proxy, download_file, URLNotFound, DownloadCancelled

OUTSIDE_DOWNLOAD_BASE_URL = "http://s3.amazonaws.com/KA-youtube-converted/" # needed for redirects
OUTSIDE_DOWNLOAD_URL = OUTSIDE_DOWNLOAD_BASE_URL + "%s/%s" # needed for default behavior, below
Expand Down

0 comments on commit 4c65369

Please sign in to comment.