Raoul Hidalgo Charman pushed to branch raoul/smarter-bot-calls at BuildGrid / buildgrid
WARNING: The push did not contain any new commits, but force pushed to delete the commits and changes below.
Deleted commits:
-
3ac72395
by Raoul Hidalgo Charman at 2018-11-09T15:27:13Z
1 changed file:
Changes:
... | ... | @@ -14,11 +14,43 @@ |
14 | 14 |
|
15 | 15 |
# pylint: disable=redefined-outer-name
|
16 | 16 |
|
17 |
+import asyncio
|
|
17 | 18 |
import uuid
|
18 |
- |
|
19 | 19 |
import pytest
|
20 | 20 |
|
21 |
+import grpc
|
|
22 |
+import mock
|
|
23 |
+ |
|
21 | 24 |
from buildgrid.bot import bot_session
|
25 |
+from buildgrid.bot import bot_interface
|
|
26 |
+from buildgrid.bot.bot_session import BotSession
|
|
27 |
+from buildgrid.bot.bot_interface import BotInterface
|
|
28 |
+ |
|
29 |
+ |
|
30 |
+@pytest.fixture
|
|
31 |
+@mock.patch.object(bot_interface, 'bots_pb2_grpc.BotsStub', autospec=True)
|
|
32 |
+def mock_interface(mock_grpc):
|
|
33 |
+ mock_channel = mock.MagicMock(spec=grpc.Channel)
|
|
34 |
+ return bot_interface.BotInterface(mock_channel, 5)
|
|
35 |
+ |
|
36 |
+ |
|
37 |
+@pytest.fixture
|
|
38 |
+def session(mock_interface):
|
|
39 |
+ sesh = BotSession("main", mock_interface)
|
|
40 |
+ sesh.add_worker(bot_session.Worker())
|
|
41 |
+ return sesh
|
|
42 |
+ |
|
43 |
+ |
|
44 |
+@pytest.fixture
|
|
45 |
+def work():
|
|
46 |
+ from buildgrid._app.bots import dummy
|
|
47 |
+ return dummy.work_dummy
|
|
48 |
+ |
|
49 |
+ |
|
50 |
+@pytest.fixture
|
|
51 |
+def context():
|
|
52 |
+ from buildgrid._app.cli import Context
|
|
53 |
+ return Context()
|
|
22 | 54 |
|
23 | 55 |
|
24 | 56 |
@pytest.mark.parametrize("docker_value", ["True", "False"])
|
... | ... | @@ -67,3 +99,13 @@ def test_create_worker_key_fail(): |
67 | 99 |
bot_session.Worker(properties)
|
68 | 100 |
with pytest.raises(KeyError):
|
69 | 101 |
bot_session.Worker(configs)
|
102 |
+ |
|
103 |
+ |
|
104 |
+@pytest.mark.asyncio
|
|
105 |
+async def test_bot_session_reconnect(session, work, context):
|
|
106 |
+ print(type(session))
|
|
107 |
+ print(type(work))
|
|
108 |
+ print(type(context))
|
|
109 |
+ # session.create_bot_session(work, context)
|
|
110 |
+ assert 0
|
|
111 |
+ |