def test_get_db_url_with_dbconfig(self): options = mock.Mock() options.violation_dburl = 'sqlite:///fake/database' options.violation_dbconfig = '/fake/path/to/db/' mocked_open = mock.Mock(spec=file) mocked_open.__enter__ = mock.Mock() mocked_open.__exit__ = mock.Mock() with mock.patch('testify.plugins.violation_collector.open', create=True, return_value=mocked_open): with mock.patch.object(SA.engine.url, 'URL') as mocked_sa_url: T.assert_not_equal(get_db_url(options), options.violation_dburl) mocked_open.read.assert_called mocked_sa_url.URL.assert_called
def test_get_db_url_with_dbconfig(self): options = mock.Mock() options.violation_dburl = 'sqlite:///fake/database' options.violation_dbconfig = '/fake/path/to/db/' mocked_open = mock.Mock(spec=file) mocked_open.__enter__ = mock.Mock() mocked_open.__exit__ = mock.Mock() with mock.patch( 'testify.plugins.violation_collector.open', create=True, return_value=mocked_open ): with mock.patch.object(SA.engine.url, 'URL') as mocked_sa_url: T.assert_not_equal(get_db_url(options), options.violation_dburl) mocked_open.read.assert_called mocked_sa_url.URL.assert_called
def test_get_db_url_with_dburl(self): options = mock.Mock() options.violation_dburl = 'sqlite:///fake/database' options.violation_dbconfig = None T.assert_equal(get_db_url(options), options.violation_dburl)