test_upload.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Copyright 2019 The FATE Authors. All Rights Reserved.
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License");
  7. # you may not use this file except in compliance with the License.
  8. # You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. #
  18. import unittest
  19. import uuid
  20. from fate_arch.session import computing_session as session
  21. from pipeline.backend.config import Backend
  22. from pipeline.backend.config import WorkMode
  23. from pipeline.backend.pipeline import PipeLine
  24. class TestUpload(unittest.TestCase):
  25. def setUp(self):
  26. self.job_id = str(uuid.uuid1())
  27. session.init(self.job_id)
  28. self.file = "examples/data/breast_homo_guest.csv"
  29. self.table_name = "breast_homo_guest"
  30. self.data_count = 227
  31. def test_upload(self):
  32. upload_pipeline = PipeLine()
  33. upload_pipeline.add_upload_data(file=self.file,
  34. table_name=self.table_name, namespace=self.job_id)
  35. upload_pipeline.upload()
  36. upload_count = session.get_data_table(self.table_name, self.job_id).count()
  37. return upload_count == self.data_count
  38. def tearDown(self):
  39. session.stop()
  40. try:
  41. session.cleanup("*", self.job_id, True)
  42. except EnvironmentError:
  43. pass
  44. try:
  45. session.cleanup("*", self.job_id, False)
  46. except EnvironmentError:
  47. pass
  48. if __name__ == '__main__':
  49. unittest.main()