tests: added fixture with energy usage instead of example (#11308)

* Added energy usage fixture. Updated dashboard utils and unicode fixture with new method parameters.

* Add energy fixture to tests/access_tests.py

* Add energy fixture to tests/core_tests.py

* Add energy fixture to tests/dashboard_tests.py

* Add energy fixture to tests/datasets/api_tests.py

* Add energy fixture to tests/db_engine_specs/base_engine_spec_tests.py

* Add energy fixture to tests/import_export_tests.py

* Add energy fixture to tests/model_tests.py

* Add energy fixture to tests/query_context_tests.py

* Add energy fixture to tests/security_tests.py

* Add energy fixture to tests/charts/api_tests.py

* Changed formatting of slices' parameters in energy usage fixture

* Removed loading energy udage data from test conf file

* Add energy fixture to tests/databases/api_tests.py

* Fixes after review: removed isort:skip, load_charts->load_energy_charts, removed unused import.

* Added energy fixture to tests/charts/commands_tests.py and retrieving proper Slice by name

* Fixed charts/api_tests.py to use energy_usage from fixtures

* Fixed datasets/commands_tests.py to retrieve dataset by name and use energy_usage fixture

* Changed energy usage data to generated data and fixed chart tests which was checking energy usage data
This commit is contained in:
Kasia Kucharczyk
2020-12-09 12:02:29 -08:00
committed by GitHub
parent 6270fa2026
commit 4da47f1635
16 changed files with 259 additions and 22 deletions
+9 -2
View File
@@ -26,6 +26,7 @@ import logging
from typing import Dict, List
from urllib.parse import quote
import pytest
import pytz
import random
import re
@@ -37,7 +38,8 @@ import sqlalchemy as sqla
from superset.models.cache import CacheKey
from superset.utils.core import get_example_database
from tests.test_app import app # isort:skip
from tests.fixtures.energy_dashboard import load_energy_table_with_slice
from tests.test_app import app
import superset.views.utils
from superset import (
dataframe,
@@ -236,6 +238,7 @@ class TestCore(SupersetTestCase):
assert_admin_view_menus_in("Alpha", self.assertNotIn)
assert_admin_view_menus_in("Gamma", self.assertNotIn)
@pytest.mark.usefixtures("load_energy_table_with_slice")
def test_save_slice(self):
self.login(username="admin")
slice_name = f"Energy Sankey"
@@ -302,6 +305,7 @@ class TestCore(SupersetTestCase):
db.session.delete(slc)
db.session.commit()
@pytest.mark.usefixtures("load_energy_table_with_slice")
def test_filter_endpoint(self):
self.login(username="admin")
slice_name = "Energy Sankey"
@@ -320,7 +324,7 @@ class TestCore(SupersetTestCase):
# Changing name
resp = self.get_resp(url.format(tbl_id, slice_id))
assert len(resp) > 0
assert "Carbon Dioxide" in resp
assert "energy_target0" in resp
def test_slice_data(self):
# slice data should have some required attributes
@@ -333,6 +337,7 @@ class TestCore(SupersetTestCase):
assert "modified" in slc_data_attributes
assert "owners" in slc_data_attributes
@pytest.mark.usefixtures("load_energy_table_with_slice")
def test_slices(self):
# Testing by hitting the two supported end points for all slices
self.login(username="admin")
@@ -409,6 +414,7 @@ class TestCore(SupersetTestCase):
resp = self.client.get(url)
self.assertEqual(resp.status_code, 200)
@pytest.mark.usefixtures("load_energy_table_with_slice")
def test_slices_V2(self):
# Add explore-v2-beta role to admin user
# Test all slice urls as user with with explore-v2-beta role
@@ -570,6 +576,7 @@ class TestCore(SupersetTestCase):
database.allow_run_async = False
db.session.commit()
@pytest.mark.usefixtures("load_energy_table_with_slice")
def test_warm_up_cache(self):
self.login()
slc = self.get_slice("Girls", db.session)