# Path: badwolf/utils.py
# def to_text(value, encoding='utf-8', errors='ignore'):
#     """Convert value to unicode, default encoding is utf-8
# 
#     :param value: Value to be converted
#     :param encoding: Desired encoding
#     """
#     if not value:
#         return ''
#     if isinstance(value, str):
#         return value
#     if isinstance(value, bytes):
#         return value.decode(encoding, errors)
#     return str(value)


import json
import unittest.mock as mock
from concurrent.futures import Future
from flask import url_for
from badwolf.utils import to_text
    payload = json.dumps({
        'repository': {
            'full_name': 'deepanalyzer/badwolf',
            'scm': 'git',
        },
        'push': {
            'changes': [
                {
                    'new': {
                        'type': 'branch',
                    },
                    'commits': [
                        {
                            'hash': '2cedc1af762',
                            'message': 'Test [ci skip]',
                        }
                    ],
                }
            ]
        }
    })
    res = test_client.post(
        url_for('webhook.webhook_push'),
        data=payload,
        headers={
            'User-Agent': 'Bitbucket-Webhooks/2.0',
            'X-Event-Key': 'repo:push',
        }
    )
    assert res.status_code == 200

# Path: badwolf/utils.py
# def to_text(value, encoding='utf-8', errors='ignore'):
#     """Convert value to unicode, default encoding is utf-8
# 
#     :param value: Value to be converted
#     :param encoding: Desired encoding
#     """
#     if not value:
#         return ''
#     if isinstance(value, str):
#         return value
#     if isinstance(value, bytes):
#         return value.decode(encoding, errors)
#     return str(value)


# Path: tests/test_bitbucket_webhook_repo_push.py
import json
import unittest.mock as mock
from concurrent.futures import Future
from flask import url_for
from badwolf.utils import to_text

    payload = json.dumps({
        'repository': {
            'full_name': 'deepanalyzer/badwolf',
            'scm': 'git',
        },
        'push': {
            'changes': [
                {
                    'new': {
                        'type': 'branch',
                    },
                    'commits': [
                        {
                            'hash': '2cedc1af762',
                            'message': 'Test [ci skip]',
                        }
                    ],
                }
            ]
        }
    })
    res = test_client.post(
        url_for('webhook.webhook_push'),
        data=payload,
        headers={
            'User-Agent': 'Bitbucket-Webhooks/2.0',
            'X-Event-Key': 'repo:push',
        }
    )
    assert res.status_code == 200

    assert to_text(res.data) == ''