Skip to content

Commit

Permalink
Fixes #5252 by removing testing of legacy functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Bach committed Sep 5, 2016
1 parent 17d46ec commit 20610be
Showing 1 changed file with 0 additions and 64 deletions.
64 changes: 0 additions & 64 deletions kalite/contentload/tests/unpack_assessment_zip.py
Expand Up @@ -35,70 +35,6 @@
contentload_settings.KHAN_ASSESSMENT_ITEM_JSON_PATH = os.path.join(TEMP_CONTENT_PATH, 'assessmentitems.json')


@override_settings(CONTENT_ROOT=TEMP_CONTENT_PATH)
class UnpackAssessmentZipCommandTests(KALiteTestCase):

def setUp(self):

reset_content_db()

# Create a dummy assessment item zip
_, self.zipfile_path = tempfile.mkstemp()
with open(self.zipfile_path, "w") as f:
zf = zipfile.ZipFile(f, "w")
zf.writestr("assessmentitems.version", version.SHORTVERSION)
zf.close()

def tearDown(self):
os.unlink(self.zipfile_path)

@patch("%s.open" % mod.__name__, mock_open(), create=True)
@patch.object(requests, "get")
@patch.object(mod, "should_upgrade_assessment_items")
def test_command_should_skip(self, upgrade_method, get_method):
upgrade_method.return_value = False

# test that we don't update when given a url
url = "http://fakeurl.com/test.zip"
call_command("unpack_assessment_zip", url)
self.assertEqual(get_method.call_count, 0, "requests.get was called even if we should've skipped!")

filename = "/fake/file/somewhere.zip"
call_command("unpack_assessment_zip", filename)
self.assertEqual(mod.open.call_count, 0, "open was called even if we should've skipped!")

@unittest.skipIf(os.environ.get('CIRCLECI', False), "Skipping on Circle CI")
@patch.object(requests, "get", autospec=True)
def test_command_with_url(self, get_method):
# Skipped because of concurrency issues when running
url = "http://fakeurl.com/test.zip"

with open(self.zipfile_path) as f:
zip_raw_data = f.read()
zf = zipfile.ZipFile(StringIO.StringIO(zip_raw_data))
get_method.return_value.iter_content = MagicMock(return_value=zip_raw_data)

call_command(
"unpack_assessment_zip",
url,
force_download=True # always force the download, so we can be sure the get method gets called
)

get_method.assert_called_once_with(url, stream=True)

# verify that the other items are written to the content directory
for filename in zf.namelist():
# already verified above; no need to double-dip
if "assessmentitems" in filename:
continue
else:
filename_path = os.path.join(mod.CONTENT_ROOT, filename)
self.assertTrue(os.path.exists(filename_path), "%s wasn't extracted to %s" % (filename, mod.CONTENT_ROOT))

def test_command_with_local_path(self):
pass


@override_settings(CONTENT_ROOT=TEMP_CONTENT_PATH)
class UnpackAssessmentZipUtilityFunctionTests(KALiteTestCase):

Expand Down

0 comments on commit 20610be

Please sign in to comment.