Skip to content
Snippets Groups Projects
Commit 61864481 authored by Cam Saul's avatar Cam Saul
Browse files

test fix

parent 2933dcd3
Branches
Tags
No related merge requests found
......@@ -78,134 +78,120 @@ CardServices.factory('Card', ['$resource', '$cookies', function($resource, $cook
return $cookies.csrftoken;
}
}
},
cards_for_db: {
url: '/api/card/for_db/:dbId',
method: 'GET',
params: {
dashId: '@dbId'
},
isArray: true
}
});
}]);
CardServices.service('VisualizationUtils', [ function () {
this.visualizationTypes = {
scalar: {
display: 'scalar',
label: 'Scalar',
available: false,
notAvailableReasons: []
},
table: {
display: 'table',
label: 'Table',
available: false,
notAvailableReasons: []
},
pie: {
display: 'pie',
label: 'Pie Chart',
available: false,
notAvailableReasons: []
},
bar: {
display: 'bar',
label: 'Bar Chart',
available: false,
notAvailableReasons: []
},
line: {
display: 'line',
label: 'Line Chart',
available: false,
notAvailableReasons: []
},
area: {
display: 'area',
label: 'Area Chart',
available: false,
notAvailableReasons: []
},
timeseries: {
display: 'timeseries',
label: 'Time Series',
available: false,
notAvailableReasons: []
},
pin_map: {
display: 'pin_map',
label: 'Pin Map',
available: false,
notAvailableReasons: []
},
state: {
display: 'state',
label: 'State Heatmap',
available: false,
notAvailableReasons: []
},
country: {
display: 'country',
label: 'World Heatmap',
available: false,
notAvailableReasons: []
}
};
CardServices.service('VisualizationUtils', [function() {
this.visualizationTypes = {
scalar: {
display: 'scalar',
label: 'Scalar',
available: false,
notAvailableReasons: []
},
table: {
display: 'table',
label: 'Table',
available: false,
notAvailableReasons: []
},
pie: {
display: 'pie',
label: 'Pie Chart',
available: false,
notAvailableReasons: []
},
bar: {
display: 'bar',
label: 'Bar Chart',
available: false,
notAvailableReasons: []
},
line: {
display: 'line',
label: 'Line Chart',
available: false,
notAvailableReasons: []
},
area: {
display: 'area',
label: 'Area Chart',
available: false,
notAvailableReasons: []
},
timeseries: {
display: 'timeseries',
label: 'Time Series',
available: false,
notAvailableReasons: []
},
pin_map: {
display: 'pin_map',
label: 'Pin Map',
available: false,
notAvailableReasons: []
},
state: {
display: 'state',
label: 'State Heatmap',
available: false,
notAvailableReasons: []
},
country: {
display: 'country',
label: 'World Heatmap',
available: false,
notAvailableReasons: []
}
};
this.zoomTypes = [
{
'label': 'Disabled',
'value': null
}, {
'label': 'X',
'value': 'x'
}, {
'label': 'Y',
'value': 'y'
}, {
'label': 'XY',
'value': 'xy'
}
];
this.zoomTypes = [{
'label': 'Disabled',
'value': null
}, {
'label': 'X',
'value': 'x'
}, {
'label': 'Y',
'value': 'y'
}, {
'label': 'XY',
'value': 'xy'
}];
}]);
CardServices.service('QueryUtils', function () {
this.limitOptions = [
{
label: "1",
value: 1
}, {
label: "10",
value: 10
}, {
label: "25",
value: 25
}, {
label: "50",
value: 50
}, {
label: "100",
value: 100
}, {
label: "1000",
value: 1000
}
];
this.emptyQuery = function () {
CardServices.service('QueryUtils', function() {
this.limitOptions = [{
label: "1",
value: 1
}, {
label: "10",
value: 10
}, {
label: "25",
value: 25
}, {
label: "50",
value: 50
}, {
label: "100",
value: 100
}, {
label: "1000",
value: 1000
}];
this.emptyQuery = function() {
return {
filter: [
null,
null
],
source_table: null,
breakout: [
],
breakout: [],
limit: null,
aggregation: [
],
aggregation: [],
database: 1,
type: null,
native: {}
......@@ -223,7 +209,7 @@ CardServices.service('QueryUtils', function () {
"allowTitleEdits": false
};
this.populateQueryOptions = function (table) {
this.populateQueryOptions = function(table) {
// create empty objects to store our lookups
table.fields_lookup = {};
table.aggregation_lookup = {};
......@@ -551,4 +537,4 @@ CardServices.service('VisualizationSettings', [function() {
return defaults;
};
}]);
}]);
\ No newline at end of file
......@@ -21,8 +21,7 @@
;; Check that we can fetch all Settings for Org
(expect-eval-actual-first
[{:key "test-setting-1", :value nil, :description "Test setting - this only shows up in dev (1)"}
{:key "test-setting-2", :value "FANCY", :description "Test setting - this only shows up in dev (2)"}
{:key "test-setting-3", :value nil, :description "Test setting - this only shows up in dev (3)"}]
{:key "test-setting-2", :value "FANCY", :description "Test setting - this only shows up in dev (2)"}]
(do (set-settings nil "FANCY" nil)
(fetch-all-settings)))
......@@ -43,13 +42,13 @@
(expect-eval-actual-first
["NICE!"
"NICE!"]
(do ((user->client :rasta) :put 200 "setting/test-setting-1" {:value "NICE!"})
(do ((user->client :rasta) :put 200 "setting/test-setting-1" :org @org-id {:value "NICE!"})
[(test-setting-1 @org-id)
(fetch-setting :test-setting-1)]))
;; ## Check non-admin can't set a Setting
(expect "You don't have permissions to do that."
((user->client :lucky) :put 403 "setting/test-setting-1" {:value "NICE!"}))
((user->client :lucky) :put 403 "setting/test-setting-1" :org @org-id {:value "NICE!"}))
;; ## DELETE /api/setting/:key
(expect-eval-actual-first
......
......@@ -10,7 +10,6 @@
(defsetting test-setting-1 "Test setting - this only shows up in dev (1)")
(defsetting test-setting-2 "Test setting - this only shows up in dev (2)")
(defsetting test-setting-3 "Test setting - this only shows up in dev (3)")
;; ## HELPER FUNCTIONS
......@@ -23,10 +22,9 @@
(defn setting-exists? [setting-name]
(exists? Setting :key (name setting-name) :organization_id @org-id))
(defn set-settings [setting-1-value setting-2-value setting-3-value]
(defn set-settings [setting-1-value setting-2-value]
(test-setting-1 @org-id setting-1-value)
(test-setting-2 @org-id setting-2-value)
(test-setting-3 @org-id setting-3-value))
(test-setting-2 @org-id setting-2-value))
;; ## GETTERS
......@@ -42,23 +40,19 @@
;; ## SETTERS
;; Test defsetting setter fn
(expect-eval-actual-first
[nil
"FANCY NEW VALUE <3"
["FANCY NEW VALUE <3"
"FANCY NEW VALUE <3"]
[(test-setting-2 @org-id)
(do (test-setting-2 @org-id "FANCY NEW VALUE <3")
[(do (test-setting-2 @org-id "FANCY NEW VALUE <3")
(test-setting-2 @org-id))
(db-fetch-setting :test-setting-2)])
;; Test `set` function
(expect-eval-actual-first
[nil
"WHAT A NICE VALUE <3"
["WHAT A NICE VALUE <3"
"WHAT A NICE VALUE <3"]
[(test-setting-3 @org-id)
(do (setting/set @org-id :test-setting-3 "WHAT A NICE VALUE <3")
(test-setting-3 @org-id))
(db-fetch-setting :test-setting-3)])
[(do (setting/set @org-id :test-setting-2 "WHAT A NICE VALUE <3")
(test-setting-2 @org-id))
(db-fetch-setting :test-setting-2)])
;; ## DELETE
......@@ -92,18 +86,16 @@
;; all
(expect-eval-actual-first
{:test-setting-2 "BIRDS<3"
:test-setting-3 "TOUCANS"}
(do (set-settings nil "BIRDS<3" "TOUCANS")
{:test-setting-2 "TOUCANS"}
(do (set-settings nil "TOUCANS")
(m/filter-keys #(re-find #"^test-setting-\d$" (name %)) ; filter out any non-test settings
(setting/all @org-id))))
;; all-with-descriptions
(expect-eval-actual-first
[{:key :test-setting-1, :value nil, :description "Test setting - this only shows up in dev (1)"}
{:key :test-setting-2, :value "S2", :description "Test setting - this only shows up in dev (2)"}
{:key :test-setting-3, :value "S3", :description "Test setting - this only shows up in dev (3)"}]
(do (set-settings nil "S2" "S3")
{:key :test-setting-2, :value "S2", :description "Test setting - this only shows up in dev (2)"}]
(do (set-settings nil "S2")
(filter (fn [{k :key}]
(re-find #"^test-setting-\d$" (name k)))
(setting/all-with-descriptions @org-id))))
(ns metabase.test-utils
(ns metabase.test-utils ; TODO - rename to setup
"Functions that run before + after unit tests (setup DB, start web server, load test data)."
(:require [clojure.java.io :as io]
[clojure.tools.logging :as log]
[expectations :refer :all]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment