datasource.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. # Licensed to the Apache Software Foundation (ASF) under one
  2. # or more contributor license agreements. See the NOTICE file
  3. # distributed with this work for additional information
  4. # regarding copyright ownership. The ASF licenses this file
  5. # to you under the Apache License, Version 2.0 (the
  6. # "License"); you may not use this file except in compliance
  7. # with the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing,
  12. # software distributed under the License is distributed on an
  13. # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14. # KIND, either express or implied. See the License for the
  15. # specific language governing permissions and limitations
  16. # under the License.
  17. """Fixtures for test_datasource.py"""
  18. datasource_post = {
  19. "id": None,
  20. "column_formats": {"ratio": ".2%"},
  21. "description": "Adding a DESCRip",
  22. "default_endpoint": "",
  23. "filter_select_enabled": True,
  24. "name": "birth_names",
  25. "datasource_name": "birth_names",
  26. "type": "table",
  27. "schema": "",
  28. "offset": 66,
  29. "cache_timeout": 55,
  30. "sql": "",
  31. "columns": [
  32. {
  33. "id": 504,
  34. "column_name": "ds",
  35. "verbose_name": "",
  36. "description": None,
  37. "expression": "",
  38. "filterable": True,
  39. "groupby": True,
  40. "is_dttm": True,
  41. "type": "DATETIME",
  42. },
  43. {
  44. "id": 505,
  45. "column_name": "gender",
  46. "verbose_name": None,
  47. "description": None,
  48. "expression": "",
  49. "filterable": True,
  50. "groupby": True,
  51. "is_dttm": False,
  52. "type": "VARCHAR(16)",
  53. },
  54. {
  55. "id": 506,
  56. "column_name": "name",
  57. "verbose_name": None,
  58. "description": None,
  59. "expression": None,
  60. "filterable": True,
  61. "groupby": True,
  62. "is_dttm": None,
  63. "type": "VARCHAR(255)",
  64. },
  65. {
  66. "id": 508,
  67. "column_name": "state",
  68. "verbose_name": None,
  69. "description": None,
  70. "expression": None,
  71. "filterable": True,
  72. "groupby": True,
  73. "is_dttm": None,
  74. "type": "VARCHAR(10)",
  75. },
  76. {
  77. "id": 509,
  78. "column_name": "sum_boys",
  79. "verbose_name": None,
  80. "description": None,
  81. "expression": None,
  82. "filterable": True,
  83. "groupby": True,
  84. "is_dttm": None,
  85. "type": "BIGINT(20)",
  86. },
  87. {
  88. "id": 510,
  89. "column_name": "sum_girls",
  90. "verbose_name": None,
  91. "description": None,
  92. "expression": "",
  93. "filterable": False,
  94. "groupby": False,
  95. "is_dttm": False,
  96. "type": "BIGINT(20)",
  97. },
  98. {
  99. "id": 532,
  100. "column_name": "num",
  101. "verbose_name": None,
  102. "description": None,
  103. "expression": None,
  104. "filterable": True,
  105. "groupby": True,
  106. "is_dttm": None,
  107. "type": "BIGINT(20)",
  108. },
  109. {
  110. "id": 522,
  111. "column_name": "num_california",
  112. "verbose_name": None,
  113. "description": None,
  114. "expression": "CASE WHEN state = 'CA' THEN num ELSE 0 END",
  115. "filterable": False,
  116. "groupby": False,
  117. "is_dttm": False,
  118. "type": "NUMBER",
  119. },
  120. ],
  121. "metrics": [
  122. {
  123. "id": 824,
  124. "metric_name": "sum__num",
  125. "verbose_name": "Babies",
  126. "description": "",
  127. "expression": "SUM(num)",
  128. "warning_text": "",
  129. "d3format": "",
  130. },
  131. {
  132. "id": 836,
  133. "metric_name": "count",
  134. "verbose_name": "",
  135. "description": None,
  136. "expression": "count(1)",
  137. "warning_text": None,
  138. "d3format": None,
  139. },
  140. {
  141. "id": 843,
  142. "metric_name": "ratio",
  143. "verbose_name": "Ratio Boys/Girls",
  144. "description": "This represents the ratio of boys/girls",
  145. "expression": "sum(sum_boys) / sum(sum_girls)",
  146. "warning_text": "no warning",
  147. "d3format": ".2%",
  148. },
  149. ],
  150. }