def make_master(_): # don't create child services self.patch(master.BuildMaster, 'create_child_services', lambda self: None) # patch out a few other annoying things the master likes to do self.patch(monkeypatches, 'patch_all', lambda: None) self.patch(signal, 'signal', lambda sig, hdlr: None) # XXX temporary self.patch(master, 'Status', lambda master: mock.Mock()) master.BuildMaster.masterHeartbeatService = mock.Mock() self.reactor = self.make_reactor() self.master = master.BuildMaster(self.basedir, reactor=self.reactor, config_loader=DefaultLoader()) self.master.sendBuildbotNetUsageData = mock.Mock() self.master.botmaster = FakeBotMaster() self.db = self.master.db = fakedb.FakeDBConnector(self) self.db.setServiceParent(self.master) self.mq = self.master.mq = fakemq.FakeMQConnector(self) self.mq.setServiceParent(self.master) self.data = self.master.data = fakedata.FakeDataConnector( self.master, self) self.data.setServiceParent(self.master)
def setUp(self): self.setup_test_reactor() self.setUpLogging() self.basedir = os.path.abspath('basedir') yield self.setUpDirs(self.basedir) # don't create child services self.patch(master.BuildMaster, 'create_child_services', lambda self: None) # patch out a few other annoying things the master likes to do self.patch(monkeypatches, 'patch_all', lambda: None) self.patch(signal, 'signal', lambda sig, hdlr: None) master.BuildMaster.masterHeartbeatService = mock.Mock() self.master = master.BuildMaster(self.basedir, reactor=self.reactor, config_loader=DefaultLoader()) self.master.sendBuildbotNetUsageData = mock.Mock() self.master.botmaster = FakeBotMaster() self.db = self.master.db = fakedb.FakeDBConnector(self) yield self.db.setServiceParent(self.master) self.mq = self.master.mq = fakemq.FakeMQConnector(self) yield self.mq.setServiceParent(self.master) self.data = self.master.data = fakedata.FakeDataConnector( self.master, self) yield self.data.setServiceParent(self.master)
def make_master(testcase, wantMq=False, wantDb=False, wantData=False, wantRealReactor=False, url=None, **kwargs): if wantRealReactor: _reactor = reactor else: assert testcase is not None, "need testcase for fake reactor" # The test case must inherit from TestReactorMixin and setup it. _reactor = testcase.reactor master = FakeMaster(_reactor, **kwargs) if url: master.buildbotURL = url if wantData: wantMq = wantDb = True if wantMq: assert testcase is not None, "need testcase for wantMq" master.mq = fakemq.FakeMQConnector(testcase) master.mq.setServiceParent(master) if wantDb: assert testcase is not None, "need testcase for wantDb" master.db = fakedb.FakeDBConnector(testcase) master.db.setServiceParent(master) if wantData: master.data = fakedata.FakeDataConnector(master, testcase) return master
def make_master(testcase, wantMq=False, wantDb=False, wantData=False, wantRealReactor=False, wantGraphql=False, url=None, **kwargs): if wantRealReactor: _reactor = reactor else: assert testcase is not None, "need testcase for fake reactor" # The test case must inherit from TestReactorMixin and setup it. _reactor = testcase.reactor master = FakeMaster(_reactor, **kwargs) if url: master.buildbotURL = url if wantData: wantMq = wantDb = True if wantMq: assert testcase is not None, "need testcase for wantMq" master.mq = fakemq.FakeMQConnector(testcase) master.mq.setServiceParent(master) if wantDb: assert testcase is not None, "need testcase for wantDb" master.db = fakedb.FakeDBConnector(testcase) master.db.setServiceParent(master) if wantData: master.data = fakedata.FakeDataConnector(master, testcase) if wantGraphql: master.graphql = GraphQLConnector() master.graphql.setServiceParent(master) master.graphql.data = master.data.realConnector master.data._scanModule(endpoint) try: master.graphql.reconfigServiceWithBuildbotConfig({'www': {'graphql': {'debug': True}}}) except ImportError: pass return master
def make_master(wantMq=False, wantDb=False, wantData=False, testcase=None, **kwargs): master = FakeMaster(**kwargs) if wantData: wantMq = wantDb = True if wantMq: assert testcase is not None, "need testcase for wantMq" master.mq = fakemq.FakeMQConnector(master, testcase) if wantDb: assert testcase is not None, "need testcase for wantDb" master.db = fakedb.FakeDBConnector(master, testcase) if wantData: master.data = fakedata.FakeDataConnector(master, testcase) return master
def make_master(_): # don't create child services self.patch(master.BuildMaster, 'create_child_services', lambda self: None) # patch out a few other annoying things the master likes to do self.patch(monkeypatches, 'patch_all', lambda: None) self.patch(signal, 'signal', lambda sig, hdlr: None) self.patch(master, 'Status', lambda master: mock.Mock()) # XXX temporary self.patch(config.MasterConfig, 'loadConfig', classmethod(lambda cls, b, f: cls())) self.master = master.BuildMaster(self.basedir) self.db = self.master.db = fakedb.FakeDBConnector(self.master, self) self.mq = self.master.mq = fakemq.FakeMQConnector(self.master, self) self.data = self.master.data = fakedata.FakeDataConnector(self.master, self)
def make_master(wantMq=False, wantDb=False, wantData=False, testcase=None, url=None, **kwargs): master = FakeMaster(**kwargs) if url: master.buildbotURL = url if wantData: wantMq = wantDb = True if wantMq: assert testcase is not None, "need testcase for wantMq" master.mq = fakemq.FakeMQConnector(testcase) master.mq.setServiceParent(master) if wantDb: assert testcase is not None, "need testcase for wantDb" master.db = fakedb.FakeDBConnector(testcase) master.db.setServiceParent(master) if wantData: master.data = fakedata.FakeDataConnector(master, testcase) return master
def setUp(self): self.patch(master.BuildMaster, 'create_child_services', lambda self: None) self.master = master.BuildMaster(basedir=None) self.master.data = fakedata.FakeDataConnector(self.master, self) self.master.db = fakedb.FakeDBConnector(self.master, self) self.master.db.insertTestData([ fakedb.Change(changeid=1, author='this is a test'), ]) self.fake_Change = mock.Mock(name='fake_Change') def fromChdict(master, chdict): if chdict['author'] != 'this is a test': raise AssertionError("did not get expected chdict") return defer.succeed(self.fake_Change) self.patch(Change, 'fromChdict', staticmethod(fromChdict))