|
14 | 14 | # License for the specific language governing permissions and limitations
|
15 | 15 | # under the License.
|
16 | 16 |
|
17 |
| -import os |
18 |
| -import shutil |
19 | 17 | import sys
|
20 |
| -import urllib.request |
21 | 18 |
|
22 | 19 | import mock
|
23 | 20 |
|
24 |
| -from deepaas.cmd import execute |
25 | 21 | from deepaas.cmd import run
|
26 | 22 | from deepaas.tests import base
|
27 | 23 |
|
@@ -62,53 +58,3 @@ def test_run_custom_ip_port(self, m_get_app, m_run_app, m_handle_signals):
|
62 | 58 | port=port,
|
63 | 59 | )
|
64 | 60 | m_handle_signals.assert_called_once()
|
65 |
| - |
66 |
| - |
67 |
| -class TestExecute(base.TestCase): |
68 |
| - @mock.patch("deepaas.cmd.execute.prediction") |
69 |
| - def test_execute_data(self, m_out_pred): |
70 |
| - in_file = "file" |
71 |
| - out_file = "deepaas/tests/out_test/" |
72 |
| - self.flags(input_file=in_file) |
73 |
| - self.flags(output=out_file) |
74 |
| - m_out_pred.return_value = [{"value1": {"pred": 1}, "value2": {"pred": 0.9}}] |
75 |
| - with mock.patch.object(sys, "argv", ["deepaas-predict"]): |
76 |
| - execute.main() |
77 |
| - |
78 |
| - @mock.patch("deepaas.cmd.execute.prediction") |
79 |
| - def test_execute_url(self, m_out_pred): |
80 |
| - in_file = "https://xxxxxxxxxx" |
81 |
| - out_file = "deepaas/tests/out_test/" |
82 |
| - self.flags(input_file=in_file) |
83 |
| - self.flags(output=out_file) |
84 |
| - self.flags(url=True) |
85 |
| - m_out_pred.return_value = [{"value1": {"pred": 1}, "value2": {"pred": 0.9}}] |
86 |
| - with mock.patch.object(sys, "argv", ["deepaas-predict"]): |
87 |
| - execute.main() |
88 |
| - |
89 |
| - @mock.patch("deepaas.cmd.execute.prediction") |
90 |
| - def test_execute_ct(self, m_out_pred): |
91 |
| - in_file = "file" |
92 |
| - out_file = "deepaas/tests/out_test/" |
93 |
| - cont_type = "application/zip" |
94 |
| - self.flags(input_file=in_file) |
95 |
| - self.flags(output=out_file) |
96 |
| - self.flags(content_type=cont_type) |
97 |
| - output_dir = "deepaas/tests/tmp_dir" |
98 |
| - if os.path.exists(output_dir): |
99 |
| - shutil.rmtree(output_dir) |
100 |
| - os.mkdir(output_dir) |
101 |
| - out_json = [{"value1": {"pred": 1}, "value2": {"pred": 0.9}}] |
102 |
| - f_json = open(output_dir + "output" + ".json", "w+") |
103 |
| - f_json.write(repr(out_json) + "\n") |
104 |
| - f_json.close |
105 |
| - url = "https://storage.googleapis.com/" "tfjs-models/assets/posenet/frisbee.jpg" |
106 |
| - urllib.request.urlretrieve(url, "example_image.jpg") |
107 |
| - shutil.move(f_json.name, output_dir) |
108 |
| - shutil.move("example_image.jpg", output_dir) |
109 |
| - f = shutil.make_archive(base_name=output_dir, format="zip", root_dir=output_dir) |
110 |
| - m_out_pred.return_value = open(f, "rb") |
111 |
| - with mock.patch.object(sys, "argv", ["deepaas-predict"]): |
112 |
| - execute.main() |
113 |
| - shutil.rmtree(output_dir) |
114 |
| - os.remove(output_dir + ".zip") |
0 commit comments