test_unit_testing.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License in the LICENSE file at the
  6. # root of this repository, or online 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. import pytest
  16. from dbt.tests.adapter.unit_testing.test_case_insensitivity import (
  17. BaseUnitTestCaseInsensivity,
  18. )
  19. from dbt.tests.adapter.unit_testing.test_invalid_input import BaseUnitTestInvalidInput
  20. from dbt.tests.adapter.unit_testing.test_types import BaseUnitTestingTypes
  21. class TestMaterializeUnitTestingTypes(BaseUnitTestingTypes):
  22. @pytest.fixture
  23. def data_types(self):
  24. # sql_value, yaml_value
  25. return [
  26. ["1", "1"],
  27. ["'1'", "1"],
  28. ["true", "true"],
  29. ["DATE '2020-01-02'", "2020-01-02"],
  30. ["TIMESTAMP '2013-11-03 00:00:00-0'", "2013-11-03 00:00:00-0"],
  31. ["TIMESTAMPTZ '2013-11-03 00:00:00-0'", "2013-11-03 00:00:00-0"],
  32. ["'1'::numeric", "1"],
  33. [
  34. """'{"bar": "baz", "balance": 7.77, "active": false}'::json""",
  35. """'{"bar": "baz", "balance": 7.77, "active": false}'""",
  36. ],
  37. ["MZ_TIMESTAMP '2023-05-21 12:34:56'", "2023-05-21 12:34:56"],
  38. # TODO: array types
  39. # ["LIST[1, 2, 3]", """'[1, 2, 3]'"""],
  40. # ["LIST['a', 'b', 'c']", """'["a", "b", "c"]'"""],
  41. # ["ARRAY[1,2,3]", """'{1, 2, 3}'"""],
  42. # ["ARRAY[1.0,2.0,3.0]", """'{1.0, 2.0, 3.0}'"""],
  43. # ["ARRAY[1::numeric,2::numeric,3::numeric]", """'{1.0, 2.0, 3.0}'"""],
  44. # ["ARRAY['a','b','c']", """'{"a", "b", "c"}'"""],
  45. # ["ARRAY[true,true,false]", """'{true, true, false}'"""],
  46. # ["ARRAY[DATE '2020-01-02']", """'{"2020-01-02"}'"""],
  47. # ["ARRAY[TIMESTAMP '2013-11-03 00:00:00-0']", """'{"2013-11-03 00:00:00-0"}'"""],
  48. # ["ARRAY[TIMESTAMPTZ '2013-11-03 00:00:00-0']", """'{"2013-11-03 00:00:00-0"}'"""],
  49. ]
  50. class TestMaterializeUnitTestCaseInsensitivity(BaseUnitTestCaseInsensivity):
  51. pass
  52. class TestMaterializeUnitTestInvalidInput(BaseUnitTestInvalidInput):
  53. pass