MCPcopy Create free account
hub / github.com/apache/devlake / ContextBuilder

Class ContextBuilder

backend/python/pydevlake/pydevlake/testing/testing.py:30–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28
29
30class ContextBuilder:
31 def __init__(self, plugin: Plugin):
32 if isinstance(plugin, type):
33 plugin = plugin()
34 self.plugin = plugin
35 self.connection = None
36 self.scope = None
37 self.scope_config = None
38
39 def with_connection(self, id=1, name='test_connection', **kwargs):
40 self.connection = self.plugin.connection_type(id=id, name=name, **kwargs)
41 return self
42
43 def with_scope(self, id='s', name='test_scope', **kwargs):
44 self.scope = self.plugin.tool_scope_type(id=id, name=name, **kwargs)
45 if self.connection:
46 self.scope.connection_id = self.connection.id
47 return self
48
49 def with_scope_config(self, id=1, name='test_config', **kwargs):
50 self.scope_config = self.plugin.scope_config_type(id=id, name=name, **kwargs)
51 return self
52
53 def build(self):
54 return make_context(self.connection, self.scope, self.scope_config)
55
56
57def make_context(connection, scope, scope_config):

Callers 3

contextFunction · 0.90

Calls

no outgoing calls

Tested by 3

contextFunction · 0.72