コード例 #1
0
 def test_init_pooled_pghelper(self, pool_mock):
     help = PostgreSQLHelper(host='127.0.0.1',
                             user='******',
                             password='******',
                             database='test_db',
                             pooled=True)
     assert pool_mock.mock_calls == [
         call.get_instance(host='127.0.0.1',
                           user='******',
                           password='******',
                           database='test_db',
                           database_args={}),
         call.get_instance().getconn(key=id(help)),
         call.get_instance().getconn().cursor()
     ]
コード例 #2
0
 def test_init_pooled(self, mocker):
     pool_mock = mocker.patch("nova_api.persistence.mysql_helper.MySQLPool")
     MySQLHelper(host='127.0.0.1',
                 user='******',
                 password='******',
                 database='test_db',
                 pooled=True)
     assert pool_mock.mock_calls == [
         call.get_instance(host='127.0.0.1',
                           user='******',
                           password='******',
                           database='test_db',
                           database_args={}),
         call.get_instance().get_connection(),
         call.get_instance().get_connection().cursor()
     ]
コード例 #3
0
def test_pass_multiple_batches_ids(monkeypatch):
    monkeypatch.setenv("APPLITOOLS_API_KEY", "abc")
    with patch("applitools.selenium.command_executor.CommandExecutor"
               ) as commands:
        BatchClose().set_batch_ids("test batch-id",
                                   "test-batch-second").close()
        assert commands.mock_calls == [
            call.get_instance("eyes.sdk.python", ANY),
            call.get_instance().core_close_batches({
                "batchIds": ["test batch-id", "test-batch-second"],
                "serverUrl":
                "https://eyesapi.applitools.com",
                "apiKey":
                "abc",
            }),
        ]
コード例 #4
0
def test_batch_close_uses_proxy():
    with patch("applitools.selenium.command_executor.CommandExecutor"
               ) as commands:
        BatchClose().set_batch_ids("test-id").set_proxy(
            ProxySettings("localhost", 80)).close()
        assert commands.mock_calls == [
            call.get_instance("eyes.sdk.python", ANY),
            call.get_instance().core_close_batches({
                "batchIds": ["test-id"],
                "serverUrl": "https://eyesapi.applitools.com",
                "apiKey": ANY,
                "proxy": {
                    "url": "http://localhost:80"
                },
            }),
        ]
コード例 #5
0
    def test_close_pooled(self, pool_mock, db_pooled, cursor_mock):
        db_pooled.close()
        my_conn = Mock()
        pool_mock.get_instance.return_value.getconn.return_value = my_conn

        assert call.get_instance().getconn().cursor().close() \
               in pool_mock.mock_calls
        assert pool_mock.get_instance.return_value.putconn.called_with(my_conn)
コード例 #6
0
ファイル: test_main.py プロジェクト: ykv-name/streamalert
def test_handler(mock_instance):
    """Alert Merger - Handler (Entry Point)"""
    main.handler(None, None)
    mock_instance.assert_has_calls(
        [call.get_instance(),
         call.get_instance().dispatch()])