from unittest.mock import MagicMock from github import UnknownObjectException import pytest from tests import helpers @pytest.fixture def get_mock_dashboard_json(): """Fixture for dashboard json requests.""" return MagicMock( status_code=200, json=MagicMock(return_value=helpers.dashboard_json)) @pytest.fixture def get_mock_dashboard_list(): """Fixture for dashboard list requests.""" return MagicMock( status_code=200, json=MagicMock(return_value=helpers.list_of_dashboards)) @pytest.fixture def get_mock_query_json(): """Fixture for query requests.""" return MagicMock( status_code=200, json=MagicMock(return_value=helpers.query_json)) @pytest.fixture def get_mock_look_json(): """Fixture for look json requests.""" return MagicMock( status_code=200, json=MagicMock(return_value=helpers.look_json)) @pytest.fixture def get_mock_look_list(): """Fixture for look list requests.""" return MagicMock( status_code=200, json=MagicMock(return_value=helpers.list_of_looks)) @pytest.fixture def get_mock_filter_list(): """Fixture for dashboard filter list.""" return MagicMock( status_code=200, json=MagicMock(return_value=helpers.list_of_dashboard_filters)) @pytest.fixture def get_mock_filter_json(): """Fixture for dashboard filter json.""" return MagicMock( status_code=200, json=MagicMock(return_value=helpers.dashboard_filter)) @pytest.fixture def get_mock_element_json(): """Fixture for dashboard element json.""" return MagicMock( status_code=200, json=MagicMock(return_value=helpers.dashboard_element)) @pytest.fixture def get_mock_layout_json(): """Fixture for dashboard layout json.""" return MagicMock( status_code=200, json=MagicMock(return_value=helpers.dashboard_layout)) @pytest.fixture def get_mock_list_of_layout_components(): """Fixture for dashboard layout components list.""" return MagicMock( status_code=200, json=MagicMock(return_value=helpers.list_of_layout_components)) @pytest.fixture def get_mock_layout_component_json(): """Fixture for dashboard layout component json.""" return MagicMock( status_code=200, json=MagicMock(return_value=helpers.dashboard_layout_component)) @pytest.fixture def get_mock_model_json(): """Fixture for model json.""" return MagicMock( status_code=200, json=MagicMock(return_value=helpers.model_json)) @pytest.fixture def response_404(): """Fixture for 404 HTTP Response.""" return MagicMock(status_code=404) @pytest.fixture def get_mock_model_explore_json(): """Fixture for model explore json.""" return MagicMock( status_code=200, json=MagicMock(return_value=helpers.model_explore)) @pytest.fixture def fixture_repo(): """Fixture for a repo.""" return MagicMock( create_file=MagicMock(return_value=True), update_file=MagicMock(return_value=True), get_contents=MagicMock( return_value=MagicMock(decoded_content=b'decoded'))) @pytest.fixture def failing_repo(): """Fixture for a failing repo.""" return MagicMock( get_contents=MagicMock( return_value=MagicMock(decoded_content= UnknownObjectException), side_effect=UnknownObjectException(404, 'wrong_name')))