def testInfoDirExists(self):
        """
        test calling _makeInfoFiles() on basedir with fully populated
        'info' directory
        """
        self.patch(os.path, "exists", mock.Mock(return_value=True))

        create_worker._makeInfoFiles("bdir", False)

        # there should be no messages to stdout
        self.assertWasQuiet()
    def checkCreatedSuccessfully(self, quiet):
        """
        Utility function to test _makeInfoFiles() when called on
        base directory that does not have 'info' sub-directory.

        @param quiet: the value of 'quiet' argument for _makeInfoFiles()
        """
        # patch os.path.exists() to report the no dirs/files exists
        self.patch(os.path, "exists", mock.Mock(return_value=False))
        # patch os.mkdir() to do nothing
        mkdir_mock = mock.Mock()
        self.patch(os, "mkdir", mkdir_mock)
        # capture calls to open() and write()
        self.setUpOpen()

        # call _makeInfoFiles()
        create_worker._makeInfoFiles("bdir", quiet)

        # check calls to os.mkdir()
        info_path = os.path.join("bdir", "info")
        mkdir_mock.assert_called_once_with(info_path)

        # check open() calls
        self.open.assert_has_calls(
            [mock.call(os.path.join(info_path, "admin"), "wt"),
             mock.call(os.path.join(info_path, "host"), "wt")])

        # check write() calls
        self.fileobj.write.assert_has_calls(
            [mock.call("Your Name Here <*****@*****.**>\n"),
             mock.call("Please put a description of this build host here\n")])

        # check output to the log
        if quiet:
            self.assertWasQuiet()
        else:
            self.assertLogged(
                "mkdir %s" % info_path,
                "Creating %s, you need to edit it appropriately."
                % os.path.join("info", "admin"),
                "Creating %s, you need to edit it appropriately."
                % os.path.join("info", "host"),
                "Not creating %s - add it if you wish"
                % os.path.join("info", "access_ur"),
                "Please edit the files in %s appropriately." % info_path
            )