# Path: monasca_notification/common/repositories/mysql/mysql_repo.py
# class MysqlRepo(base_repo.BaseRepo):
#     def __init__(self, config):
#     def _connect_to_mysql(self):
#     def fetch_notifications(self, alarm):
#     def get_alarm_current_state(self, alarm_id):
#     def fetch_notification_method_types(self):
#     def insert_notification_method_types(self, notification_types):
#     def get_notification(self, notification_id):
# 
# Path: tests/base.py
# class DisableStatsdFixture(fixtures.Fixture):
# class ConfigFixture(oo_cfg.Config):
# class BaseTestCase(oslotest_base.BaseTestCase):
# class PluginTestCase(BaseTestCase):
#     def setUp(self):
#     def __init__(self):
#     def setUp(self):
#     def _clean_config_loaded_flag():
#     def setUp(self):
#     def conf_override(**kw):
#     def conf_default(**kw):
#     def setUp(self, register_opts=None):


from unittest import mock
from monasca_notification.common.repositories import exceptions as exc
from monasca_notification.common.repositories.mysql import mysql_repo
from tests import base
import pymysql
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.





class TestMySqlRepo(base.BaseTestCase):
    def setUp(self):
        super(TestMySqlRepo, self).setUp()
        self.conf_default(group='mysql', host='localhost',
                          port=3306, user='bar',
                          passwd='1', db='2')

    @mock.patch('monasca_notification.common.repositories.mysql.mysql_repo.pymysql')
    def testReconnect(self, mock_mysql):
        m = mock.MagicMock()

        m.cursor.side_effect = pymysql.Error

        mock_mysql.connect.return_value = m
        mock_mysql.Error = pymysql.Error


# Path: monasca_notification/common/repositories/mysql/mysql_repo.py
# class MysqlRepo(base_repo.BaseRepo):
#     def __init__(self, config):
#     def _connect_to_mysql(self):
#     def fetch_notifications(self, alarm):
#     def get_alarm_current_state(self, alarm_id):
#     def fetch_notification_method_types(self):
#     def insert_notification_method_types(self, notification_types):
#     def get_notification(self, notification_id):
# 
# Path: tests/base.py
# class DisableStatsdFixture(fixtures.Fixture):
# class ConfigFixture(oo_cfg.Config):
# class BaseTestCase(oslotest_base.BaseTestCase):
# class PluginTestCase(BaseTestCase):
#     def setUp(self):
#     def __init__(self):
#     def setUp(self):
#     def _clean_config_loaded_flag():
#     def setUp(self):
#     def conf_override(**kw):
#     def conf_default(**kw):
#     def setUp(self, register_opts=None):


# Path: tests/test_mysql_repo.py
from unittest import mock
from monasca_notification.common.repositories import exceptions as exc
from monasca_notification.common.repositories.mysql import mysql_repo
from tests import base
import pymysql

#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.





class TestMySqlRepo(base.BaseTestCase):
    def setUp(self):
        super(TestMySqlRepo, self).setUp()
        self.conf_default(group='mysql', host='localhost',
                          port=3306, user='bar',
                          passwd='1', db='2')

    @mock.patch('monasca_notification.common.repositories.mysql.mysql_repo.pymysql')
    def testReconnect(self, mock_mysql):
        m = mock.MagicMock()

        m.cursor.side_effect = pymysql.Error

        mock_mysql.connect.return_value = m
        mock_mysql.Error = pymysql.Error


        repo = mysql_repo.MysqlRepo(base.config.CONF)