[Notes] [Git][BuildGrid/buildgrid][master] 4 commits: Freeze pytest version requirement to 3.6.4



Title: GitLab

Martin Blanchard pushed to branch master at BuildGrid / buildgrid

Commits:

11 changed files:

Changes:

  • .pylintrc
    ... ... @@ -7,7 +7,7 @@ extension-pkg-whitelist=
    7 7
     
    
    8 8
     # Add files or directories to the blacklist. They should be base names, not
    
    9 9
     # paths.
    
    10
    -#ignore=CVS,tests,doc
    
    10
    +#ignore=tests,docs
    
    11 11
     
    
    12 12
     # Add files or directories matching the regex patterns to the blacklist. The
    
    13 13
     # regex matches against base names, not paths.
    

  • app/cli.py
    ... ... @@ -60,9 +60,7 @@ class BuildGridCLI(click.MultiCommand):
    60 60
             try:
    
    61 61
                 mod = __import__(name='app.commands.cmd_{}'.format(name),
    
    62 62
                                  fromlist=['cli'])
    
    63
    -        except ModuleNotFoundError as e:
    
    64
    -            raise Exception(e)
    
    65
    -        except ImportError as e:
    
    63
    +        except ImportError:
    
    66 64
                 return None
    
    67 65
             return mod.cli
    
    68 66
     
    

  • setup.py
    ... ... @@ -89,7 +89,7 @@ tests_require = [
    89 89
         'coverage == 4.4.0',
    
    90 90
         'moto',
    
    91 91
         'pep8',
    
    92
    -    'pytest >= 3.1.0',
    
    92
    +    'pytest == 3.6.4',
    
    93 93
         'pytest-cov >= 2.5.0',
    
    94 94
         'pytest-pep8',
    
    95 95
         'pytest-pylint',
    

  • tests/action_cache.py
    ... ... @@ -15,9 +15,11 @@
    15 15
     # Authors:
    
    16 16
     #        Carter Sande <csande bloomberg net>
    
    17 17
     
    
    18
    -from buildgrid._protos.build.bazel.remote.execution.v2 import remote_execution_pb2
    
    18
    +# pylint: disable=redefined-outer-name
    
    19
    +
    
    19 20
     import pytest
    
    20 21
     
    
    22
    +from buildgrid._protos.build.bazel.remote.execution.v2 import remote_execution_pb2
    
    21 23
     from buildgrid.server import action_cache
    
    22 24
     from buildgrid.server.cas.storage import lru_memory_cache
    
    23 25
     
    

  • tests/cas/test_services.py
    ... ... @@ -15,12 +15,14 @@
    15 15
     # Authors:
    
    16 16
     #        Carter Sande <csande bloomberg net>
    
    17 17
     
    
    18
    +# pylint: disable=redefined-outer-name
    
    19
    +
    
    18 20
     import io
    
    19 21
     
    
    20
    -from buildgrid._protos.google.bytestream import bytestream_pb2
    
    21
    -from buildgrid._protos.build.bazel.remote.execution.v2 import remote_execution_pb2 as re_pb2
    
    22 22
     import pytest
    
    23 23
     
    
    24
    +from buildgrid._protos.google.bytestream import bytestream_pb2
    
    25
    +from buildgrid._protos.build.bazel.remote.execution.v2 import remote_execution_pb2 as re_pb2
    
    24 26
     from buildgrid.server.cas.storage.storage_abc import StorageABC
    
    25 27
     from buildgrid.server.cas.bytestream_service import ByteStreamService
    
    26 28
     from buildgrid.server.cas.content_addressable_storage_service import ContentAddressableStorageService
    
    ... ... @@ -33,10 +35,11 @@ class SimpleStorage(StorageABC):
    33 35
         Does not attempt to delete old entries, so this is only useful for testing.
    
    34 36
         """
    
    35 37
     
    
    36
    -    def __init__(self, existing_data=[]):
    
    38
    +    def __init__(self, existing_data=None):
    
    37 39
             self.data = {}
    
    38
    -        for datum in existing_data:
    
    39
    -            self.data[(HASH(datum).hexdigest(), len(datum))] = datum
    
    40
    +        if existing_data:
    
    41
    +            for datum in existing_data:
    
    42
    +                self.data[(HASH(datum).hexdigest(), len(datum))] = datum
    
    40 43
     
    
    41 44
         def has_blob(self, digest):
    
    42 45
             return (digest.hash, digest.size_bytes) in self.data
    
    ... ... @@ -59,7 +62,8 @@ class SimpleStorage(StorageABC):
    59 62
     
    
    60 63
     
    
    61 64
     class MockObject:
    
    62
    -    pass
    
    65
    +    def __init__(self):
    
    66
    +        self.abort = None
    
    63 67
     
    
    64 68
     
    
    65 69
     class MockException(Exception):
    
    ... ... @@ -148,7 +152,8 @@ def test_bytestream_write_rejects_wrong_hash():
    148 152
         context.abort = raise_mock_exception
    
    149 153
         with pytest.raises(MockException):
    
    150 154
             servicer.Write(requests, context)
    
    151
    -    assert len(storage.data) == 0
    
    155
    +
    
    156
    +    assert len(storage.data) is 0
    
    152 157
     
    
    153 158
     
    
    154 159
     @pytest.mark.parametrize("instance", instances)
    

  • tests/cas/test_storage.py
    ... ... @@ -15,14 +15,15 @@
    15 15
     # Authors:
    
    16 16
     #        Carter Sande <csande bloomberg net>
    
    17 17
     
    
    18
    +# pylint: disable=redefined-outer-name
    
    19
    +
    
    18 20
     import tempfile
    
    19 21
     
    
    20 22
     import boto3
    
    21
    -from buildgrid._protos.build.bazel.remote.execution.v2.remote_execution_pb2 import Digest
    
    22 23
     from moto import mock_s3
    
    23 24
     import pytest
    
    24 25
     
    
    25
    -from buildgrid.server.cas.storage.storage_abc import StorageABC
    
    26
    +from buildgrid._protos.build.bazel.remote.execution.v2.remote_execution_pb2 import Digest
    
    26 27
     from buildgrid.server.cas.storage.lru_memory_cache import LRUMemoryCache
    
    27 28
     from buildgrid.server.cas.storage.disk import DiskStorage
    
    28 29
     from buildgrid.server.cas.storage.s3 import S3Storage
    

  • tests/integration/action_cache_service.py
    ... ... @@ -15,14 +15,15 @@
    15 15
     # Authors:
    
    16 16
     #        Finn Ball <finn ball codethink co uk>
    
    17 17
     
    
    18
    -import grpc
    
    19
    -import pytest
    
    18
    +# pylint: disable=redefined-outer-name
    
    20 19
     
    
    21 20
     from unittest import mock
    
    22 21
     
    
    22
    +import grpc
    
    23 23
     from grpc._server import _Context
    
    24
    -from buildgrid._protos.build.bazel.remote.execution.v2 import remote_execution_pb2
    
    24
    +import pytest
    
    25 25
     
    
    26
    +from buildgrid._protos.build.bazel.remote.execution.v2 import remote_execution_pb2
    
    26 27
     from buildgrid.server import action_cache
    
    27 28
     from buildgrid.server.cas.storage import lru_memory_cache
    
    28 29
     from buildgrid.server.execution import action_cache_service
    

  • tests/integration/bot_session.py
    ... ... @@ -12,13 +12,13 @@
    12 12
     # See the License for the specific language governing permissions and
    
    13 13
     # limitations under the License.
    
    14 14
     
    
    15
    -import grpc
    
    16
    -import pytest
    
    15
    +# pylint: disable=redefined-outer-name
    
    16
    +
    
    17 17
     import uuid
    
    18 18
     
    
    19
    -from unittest import mock
    
    19
    +import pytest
    
    20 20
     
    
    21
    -from buildgrid.bot import bot_session, bot_interface
    
    21
    +from buildgrid.bot import bot_session
    
    22 22
     
    
    23 23
     
    
    24 24
     @pytest.mark.parametrize("docker_value", ["True", "False"])
    
    ... ... @@ -35,14 +35,14 @@ def test_create_device_key_fail():
    35 35
         properties = {'voight': 'kampff'}
    
    36 36
     
    
    37 37
         with pytest.raises(KeyError):
    
    38
    -        device = bot_session.Device(properties)
    
    38
    +        bot_session.Device(properties)
    
    39 39
     
    
    40 40
     
    
    41 41
     def test_create_device_value_fail():
    
    42 42
         properties = {'docker': True}
    
    43 43
     
    
    44 44
         with pytest.raises(ValueError):
    
    45
    -        device = bot_session.Device(properties)
    
    45
    +        bot_session.Device(properties)
    
    46 46
     
    
    47 47
     
    
    48 48
     def test_create_worker():
    

  • tests/integration/bots_service.py
    ... ... @@ -15,20 +15,20 @@
    15 15
     # Authors:
    
    16 16
     #        Finn Ball <finn ball codethink co uk>
    
    17 17
     
    
    18
    +# pylint: disable=redefined-outer-name
    
    19
    +
    
    18 20
     import copy
    
    19
    -import grpc
    
    20
    -import pytest
    
    21 21
     import uuid
    
    22
    -
    
    23 22
     from unittest import mock
    
    24 23
     
    
    24
    +import grpc
    
    25 25
     from grpc._server import _Context
    
    26
    -from buildgrid._protos.build.bazel.remote.execution.v2 import remote_execution_pb2
    
    27
    -from buildgrid._protos.google.devtools.remoteworkers.v1test2 import bots_pb2, worker_pb2
    
    28
    -from google.protobuf import any_pb2
    
    26
    +import pytest
    
    29 27
     
    
    28
    +from buildgrid._protos.build.bazel.remote.execution.v2 import remote_execution_pb2
    
    29
    +from buildgrid._protos.google.devtools.remoteworkers.v1test2 import bots_pb2
    
    30 30
     from buildgrid.server import scheduler, job
    
    31
    -from buildgrid.server.job import ExecuteStage, LeaseState
    
    31
    +from buildgrid.server.job import LeaseState
    
    32 32
     from buildgrid.server.worker import bots_interface, bots_service
    
    33 33
     
    
    34 34
     
    
    ... ... @@ -115,7 +115,7 @@ def test_update_bot_session_zombie(bot_session, context, instance):
    115 115
         request = bots_pb2.UpdateBotSessionRequest(name=bot.name,
    
    116 116
                                                    bot_session=bot)
    
    117 117
     
    
    118
    -    response = instance.UpdateBotSession(request, context)
    
    118
    +    instance.UpdateBotSession(request, context)
    
    119 119
     
    
    120 120
         context.set_code.assert_called_once_with(grpc.StatusCode.INVALID_ARGUMENT)
    
    121 121
     
    
    ... ... @@ -134,7 +134,7 @@ def test_number_of_leases(number_of_jobs, bot_session, context, instance):
    134 134
         request = bots_pb2.CreateBotSessionRequest(parent='',
    
    135 135
                                                    bot_session=bot_session)
    
    136 136
         # Inject work
    
    137
    -    for n in range(0, number_of_jobs):
    
    137
    +    for _ in range(0, number_of_jobs):
    
    138 138
             action_digest = remote_execution_pb2.Digest()
    
    139 139
             instance._instance._scheduler.append_job(job.Job(action_digest))
    
    140 140
     
    
    ... ... @@ -192,7 +192,7 @@ def test_update_leases_work_complete(bot_session, context, instance):
    192 192
                                                    bot_session=response)
    
    193 193
         response = copy.deepcopy(instance.UpdateBotSession(request, context))
    
    194 194
     
    
    195
    -    assert len(response.leases) == 0
    
    195
    +    assert len(response.leases) is 0
    
    196 196
     
    
    197 197
     
    
    198 198
     def test_work_rejected_by_bot(bot_session, context, instance):
    

  • tests/integration/execution_service.py
    ... ... @@ -15,17 +15,16 @@
    15 15
     # Authors:
    
    16 16
     #        Finn Ball <finn ball codethink co uk>
    
    17 17
     
    
    18
    -import grpc
    
    19
    -import pytest
    
    20
    -import uuid
    
    18
    +# pylint: disable=redefined-outer-name
    
    21 19
     
    
    20
    +import uuid
    
    22 21
     from unittest import mock
    
    23 22
     
    
    24 23
     from grpc._server import _Context
    
    24
    +import pytest
    
    25
    +
    
    25 26
     from buildgrid._protos.build.bazel.remote.execution.v2 import remote_execution_pb2
    
    26 27
     from buildgrid._protos.google.longrunning import operations_pb2
    
    27
    -from google.protobuf import any_pb2
    
    28
    -
    
    29 28
     from buildgrid.server import action_cache, scheduler, job
    
    30 29
     from buildgrid.server.cas.storage import lru_memory_cache
    
    31 30
     from buildgrid.server.execution import execution_instance, execution_service
    
    ... ... @@ -71,25 +70,24 @@ def test_execute(skip_cache_lookup, instance, context):
    71 70
         assert uuid.UUID(result.name, version=4)
    
    72 71
         assert result.done is False
    
    73 72
     
    
    74
    -"""
    
    75
    -def test_wait_execution(instance, context):
    
    73
    +
    
    74
    +# def test_wait_execution(instance, context):
    
    76 75
         # TODO: Figure out why next(response) hangs on the .get()
    
    77 76
         # method when running in pytest.
    
    78
    -    action_digest = remote_execution_pb2.Digest()
    
    79
    -    action_digest.hash = 'zhora'
    
    77
    +#     action_digest = remote_execution_pb2.Digest()
    
    78
    +#     action_digest.hash = 'zhora'
    
    80 79
     
    
    81
    -    j = job.Job(action_digest, None)
    
    82
    -    j._operation.done = True
    
    80
    +#     j = job.Job(action_digest, None)
    
    81
    +#     j._operation.done = True
    
    83 82
     
    
    84
    -    request = remote_execution_pb2.WaitExecutionRequest(name=j.name)
    
    83
    +#     request = remote_execution_pb2.WaitExecutionRequest(name=j.name)
    
    85 84
     
    
    86
    -    instance._instance._scheduler.jobs[j.name] = j
    
    85
    +#     instance._instance._scheduler.jobs[j.name] = j
    
    87 86
     
    
    88
    -    action_result_any = any_pb2.Any()
    
    89
    -    action_result = remote_execution_pb2.ActionResult()
    
    90
    -    action_result_any.Pack(action_result)
    
    87
    +#     action_result_any = any_pb2.Any()
    
    88
    +#     action_result = remote_execution_pb2.ActionResult()
    
    89
    +#     action_result_any.Pack(action_result)
    
    91 90
     
    
    92
    -    instance._instance._scheduler._update_execute_stage(j, job.ExecuteStage.COMPLETED)
    
    91
    +#     instance._instance._scheduler._update_execute_stage(j, job.ExecuteStage.COMPLETED)
    
    93 92
     
    
    94
    -    response = instance.WaitExecution(request, context)
    
    95
    -"""
    93
    +#     response = instance.WaitExecution(request, context)

  • tests/integration/operations_service.py
    ... ... @@ -15,19 +15,21 @@
    15 15
     # Authors:
    
    16 16
     #        Finn Ball <finn ball codethink co uk>
    
    17 17
     
    
    18
    -import grpc
    
    19
    -import pytest
    
    18
    +# pylint: disable=redefined-outer-name
    
    20 19
     
    
    21 20
     from unittest import mock
    
    22 21
     
    
    22
    +import grpc
    
    23 23
     from grpc._server import _Context
    
    24
    +import pytest
    
    25
    +
    
    26
    +from google.protobuf import any_pb2
    
    27
    +
    
    24 28
     from buildgrid._protos.build.bazel.remote.execution.v2 import remote_execution_pb2
    
    25 29
     from buildgrid._protos.google.longrunning import operations_pb2
    
    26
    -
    
    27
    -from buildgrid.server import scheduler, job
    
    30
    +from buildgrid.server import scheduler
    
    28 31
     from buildgrid.server.execution._exceptions import InvalidArgumentError
    
    29 32
     from buildgrid.server.execution import execution_instance, operations_service
    
    30
    -from google.protobuf import any_pb2
    
    31 33
     
    
    32 34
     
    
    33 35
     # Can mock this
    
    ... ... @@ -78,7 +80,7 @@ def test_get_operation(instance, execute_request, context):
    78 80
     
    
    79 81
     def test_get_operation_fail(instance, context):
    
    80 82
         request = operations_pb2.GetOperationRequest()
    
    81
    -    response = instance.GetOperation(request, context)
    
    83
    +    instance.GetOperation(request, context)
    
    82 84
     
    
    83 85
         context.set_code.assert_called_once_with(grpc.StatusCode.INVALID_ARGUMENT)
    
    84 86
     
    
    ... ... @@ -127,7 +129,7 @@ def test_delete_operation(instance, execute_request, context):
    127 129
                                                       execute_request.skip_cache_lookup)
    
    128 130
         request = operations_pb2.DeleteOperationRequest()
    
    129 131
         request.name = response_execute.name
    
    130
    -    response = instance.DeleteOperation(request, context)
    
    132
    +    instance.DeleteOperation(request, context)
    
    131 133
     
    
    132 134
         request = operations_pb2.GetOperationRequest()
    
    133 135
         request.name = response_execute.name
    
    ... ... @@ -150,6 +152,6 @@ def test_cancel_operation(instance, context):
    150 152
     
    
    151 153
     
    
    152 154
     def _pack_any(pack):
    
    153
    -    any = any_pb2.Any()
    
    154
    -    any.Pack(pack)
    
    155
    -    return any
    155
    +    some_any = any_pb2.Any()
    
    156
    +    some_any.Pack(pack)
    
    157
    +    return some_any



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]