def test_bad_archive(self): tornado_files = { "submission": [MockHTTPFile("archive.zip", b"this is not a valid archive")]} self.extract_files_from_archive.side_effect = InvalidArchive with self.assertRaises(InvalidArchive): extract_files_from_tornado(tornado_files) self.extract_files_from_archive.assert_called_once_with( b"this is not a valid archive")
def test_bad_archive(self): tornado_files = { "submission": [MockHTTPFile("archive.zip", b"this is not a valid archive")] } self.extract_files_from_archive.side_effect = InvalidArchive with self.assertRaises(InvalidArchive): extract_files_from_tornado(tornado_files) self.extract_files_from_archive.assert_called_once_with( b"this is not a valid archive")
def test_good_archive(self): tornado_files = { "submission": [MockHTTPFile("archive.zip", b"this is an archive")]} self.assertIs(extract_files_from_tornado(tornado_files), self.extract_files_from_archive.return_value) self.extract_files_from_archive.assert_called_once_with( b"this is an archive")
def test_not_archive_if_other_files(self): tornado_files = { "submission": [MockHTTPFile("sub.zip", b"this is an archive"), MockHTTPFile("sub2.zip", b"this is another one")]} self.assertCountEqual(extract_files_from_tornado(tornado_files), [ ReceivedFile("submission", "sub.zip", b"this is an archive"), ReceivedFile("submission", "sub2.zip", b"this is another one")])
def test_not_archive_if_other_codenames(self): tornado_files = { "submission": [MockHTTPFile("sub.zip", b"this is an archive")], "foo.%l": [MockHTTPFile("foo.c", b"this is something else")]} self.assertCountEqual(extract_files_from_tornado(tornado_files), [ ReceivedFile("submission", "sub.zip", b"this is an archive"), ReceivedFile("foo.%l", "foo.c", b"this is something else")])
def test_good_archive(self): tornado_files = { "submission": [MockHTTPFile("archive.zip", b"this is an archive")] } self.assertIs(extract_files_from_tornado(tornado_files), self.extract_files_from_archive.return_value) self.extract_files_from_archive.assert_called_once_with( b"this is an archive")
def test_not_archive_if_other_codenames(self): tornado_files = { "submission": [MockHTTPFile("sub.zip", b"this is an archive")], "foo.%l": [MockHTTPFile("foo.c", b"this is something else")] } six.assertCountEqual(self, extract_files_from_tornado(tornado_files), [ ReceivedFile("submission", "sub.zip", b"this is an archive"), ReceivedFile("foo.%l", "foo.c", b"this is something else") ])
def test_not_archive_if_other_files(self): tornado_files = { "submission": [ MockHTTPFile("sub.zip", b"this is an archive"), MockHTTPFile("sub2.zip", b"this is another one") ] } six.assertCountEqual(self, extract_files_from_tornado(tornado_files), [ ReceivedFile("submission", "sub.zip", b"this is an archive"), ReceivedFile("submission", "sub2.zip", b"this is another one") ])
def test_success(self): tornado_files = { "foo.%l": [MockHTTPFile("foo.py", b"some python stuff")], "bar.%l": [MockHTTPFile("bar.c", b"one file in C"), MockHTTPFile("bar.cxx", b"the same file in C++")], # Make sure that empty lists have no effect. "baz": []} self.assertCountEqual(extract_files_from_tornado(tornado_files), [ ReceivedFile("foo.%l", "foo.py", b"some python stuff"), ReceivedFile("bar.%l", "bar.c", b"one file in C"), ReceivedFile("bar.%l", "bar.cxx", b"the same file in C++")])
def test_success(self): tornado_files = { "foo.%l": [MockHTTPFile("foo.py", b"some python stuff")], "bar.%l": [ MockHTTPFile("bar.c", b"one file in C"), MockHTTPFile("bar.cxx", b"the same file in C++") ], # Make sure that empty lists have no effect. "baz": [] } six.assertCountEqual(self, extract_files_from_tornado(tornado_files), [ ReceivedFile("foo.%l", "foo.py", b"some python stuff"), ReceivedFile("bar.%l", "bar.c", b"one file in C"), ReceivedFile("bar.%l", "bar.cxx", b"the same file in C++") ])
def test_empty(self): self.assertEqual(extract_files_from_tornado(dict()), list())
def test_empty(self): self.assertEqual(extract_files_from_tornado(dict()), list())