def mockBuilder(master, master_status, buildername, proj):
    def CalculatedBuildTag(properties):
        return BuildTag('buildtag1')

    builder = mock.Mock()
    builder.config = BuilderConfig(name=buildername,
                                   friendly_name=buildername,
                                   project=proj,
                                   slavenames=['build-slave-01'],
                                   factory=BuildFactory(),
                                   description="Describing my builder",
                                   slavebuilddir="test",
                                   tags=['tag1', 'tag2'],
                                   build_tags=[
                                       CalculatedBuildTag,
                                       BuildTag('buildtag2', 'buildtag2desc')
                                   ])
    builder.builder_status = BuilderStatus(buildername,
                                           None,
                                           master,
                                           description="Describing my builder")
    builder.builder_status.setSlavenames(['build-slave-01'])
    builder.builder_status.setTags(['tag1', 'tag2'])
    builder.builder_status.status = master_status
    builder.builder_status.project = proj
    builder.builder_status.pendingBuildsCache = PendingBuildsCache(
        builder.builder_status)
    builder.builder_status.nextBuildNumber = 1
    builder.builder_status.basedir = '/basedir'
    builder.builder_status.saveYourself = lambda skipBuilds=True: True

    master.botmaster.builders[buildername] = builder

    return builder
 def CalculatedBuildTag(properties):
     return BuildTag('buildtag1')