metastore_test.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #
  2. # Copyright 2019 The FATE Authors. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. import unittest
  17. from fate_arch.metastore import base_model
  18. class TestBaseModel(unittest.TestCase):
  19. def test_auto_date_timestamp_field(self):
  20. self.assertEqual(
  21. base_model.auto_date_timestamp_field(), {
  22. 'write_access_time', 'create_time', 'read_access_time', 'end_time', 'update_time', 'start_time'})
  23. def test(self):
  24. from peewee import IntegerField, FloatField, AutoField, BigAutoField, BigIntegerField, BitField
  25. from peewee import CharField, TextField, BooleanField, BigBitField
  26. from fate_arch.metastore.base_model import JSONField, LongTextField
  27. for f in {IntegerField, FloatField, AutoField, BigAutoField, BigIntegerField, BitField}:
  28. self.assertEqual(base_model.is_continuous_field(f), True)
  29. for f in {CharField, TextField, BooleanField, BigBitField}:
  30. self.assertEqual(base_model.is_continuous_field(f), False)
  31. for f in {JSONField, LongTextField}:
  32. self.assertEqual(base_model.is_continuous_field(f), False)
  33. if __name__ == '__main__':
  34. unittest.main()