Esempio n. 1
0
 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")
Esempio n. 2
0
 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")
Esempio n. 3
0
 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")
Esempio n. 4
0
 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")])
Esempio n. 5
0
 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")])
Esempio n. 6
0
 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")
Esempio n. 7
0
 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")
     ])
Esempio n. 8
0
 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")
     ])
Esempio n. 9
0
 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++")])
Esempio n. 10
0
 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++")
     ])
Esempio n. 11
0
 def test_empty(self):
     self.assertEqual(extract_files_from_tornado(dict()), list())
Esempio n. 12
0
 def test_empty(self):
     self.assertEqual(extract_files_from_tornado(dict()), list())