def test_mkdirs(self, mocked):
        """
        When writing the results, subdirectories of hostname
        and topic should be created

        """
        config = {}
        path = '/path/%s/%s' % (self.hostname, self.topic)
        o = FileOutput(config)
        o._mkdirs(path)
        mocked.assert_called_with(path)
    def test_mkdirs_already_exists(self, mocked_isdir, mocked_makedirs):
        """
        Tests that mkdirs is still successful if directory already
        exists.

        """
        config = {}
        path = '/path/%s/%s' % (self.hostname, self.topic)
        o = FileOutput(config)
        o._mkdirs(path)
        mocked_makedirs.assert_called_with(path)
    def test_mkdirs_other_error(self, mocked_isdir, mocked_makedirs):
        """
        Tests that mkdirs raises OSError if not related to directory
        already existing.

        """
        config = {}
        path = '/path/%s/%s' % (self.hostname, self.topic)
        o = FileOutput(config)
        with self.assertRaises(OSError):
            o._mkdirs(path)