Exemple #1
0
def test_parse_one_model(mocker, should_fail, model_version_policy, exceptions,
                         unexpected_exception):
    arguments = MockedArgs('test', 'test', None, None, model_version_policy,
                           9000, 5555)
    if should_fail:
        if unexpected_exception:
            builder_mocker = mocker.patch('ie_serving.main.'
                                          'ModelBuilder.build')
            builder_mocker.side_effect = Exception
            with pytest.raises(exceptions):
                main.parse_one_model(arguments)
            assert builder_mocker.called
        else:
            with pytest.raises(exceptions):
                main.parse_one_model(arguments)
    else:
        start_server_mocker = mocker.patch('ie_serving.main.start_server')
        builder_mocker = mocker.patch('ie_serving.main.ModelBuilder.build')
        main.parse_one_model(arguments)
        assert start_server_mocker.called
        assert builder_mocker.called
def test_parse_one_model(mocker, should_fail, model_version_policy, exceptions,
                         unexpected_exception):
    args = collections.namedtuple(
        'args', 'model_name model_path batch_size'
        ' model_version_policy port')
    arguments = args('test', 'test', None, model_version_policy, 9000)
    if should_fail:
        if unexpected_exception:
            builder_mocker = mocker.patch('ie_serving.main.'
                                          'ModelBuilder.build')
            builder_mocker.side_effect = Exception
            with pytest.raises(exceptions):
                main.parse_one_model(arguments)
            assert builder_mocker.called
        else:
            with pytest.raises(exceptions):
                main.parse_one_model(arguments)
    else:
        start_server_mocker = mocker.patch('ie_serving.main.start_server')
        builder_mocker = mocker.patch('ie_serving.main.ModelBuilder.build')
        main.parse_one_model(arguments)
        assert start_server_mocker.called
        assert builder_mocker.called