Ejemplo 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")
Ejemplo 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")
Ejemplo 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")
Ejemplo 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")])
Ejemplo 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")])
Ejemplo 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")
Ejemplo 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")
     ])
Ejemplo 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")
     ])
Ejemplo 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++")])
Ejemplo 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++")
     ])
Ejemplo n.º 11
0
 def test_empty(self):
     self.assertEqual(extract_files_from_tornado(dict()), list())
Ejemplo n.º 12
0
 def test_empty(self):
     self.assertEqual(extract_files_from_tornado(dict()), list())