<commit_before>import datetime
from decimal import Decimal

from testil import eq

from dateutil.tz import tzoffset, tzlocal
from openpyxl.styles import numbers

from corehq.apps.export.const import MISSING_VALUE, EMPTY_VALUE
from couchexport.util import get_excel_format_value


def check(input, output, format, output_type):
    excel_format, value = get_excel_format_value(input)
    eq(excel_format, format)
    eq(value, output)
    eq(type(value), output_type)


def test_integers():
    yield check, '3423', 3423, numbers.FORMAT_NUMBER, int
    yield check, '-234', -234, numbers.FORMAT_NUMBER, int
    yield check, 324, 324, numbers.FORMAT_NUMBER, int


def test_decimal():
    yield check, '4.0345', 4.0345, numbers.FORMAT_NUMBER_00, float
    yield check, '-3.234', -3.234, numbers.FORMAT_NUMBER_00, float
    yield check, 5.032, 5.032, numbers.FORMAT_NUMBER_00, float
    yield check, Decimal('3.00'), 3.00, numbers.FORMAT_NUMBER_00, float


def test_boolean():
    yield check, 'TRUE', True, numbers.FORMAT_GENERAL, bool
    yield check, 'True', True, numbers.FORMAT_GENERAL, bool
    yield check, 'true', True, numbers.FORMAT_GENERAL, bool
    yield check, True, True, numbers.FORMAT_GENERAL, bool

    yield check, 'FALSE', False, numbers.FORMAT_GENERAL, bool
    yield check, 'False', False, numbers.FORMAT_GENERAL, bool
    yield check, 'false', False, numbers.FORMAT_GENERAL, bool
    yield check, False, False, numbers.FORMAT_GENERAL, bool


def test_decimal_eur():
    yield check, '6,9234', 6.9234, numbers.FORMAT_NUMBER_00, float
    yield check, '-5,342', -5.342, numbers.FORMAT_NUMBER_00, float


def test_percentage():
    yield check, '80%', 80, numbers.FORMAT_PERCENTAGE, int
    yield check, '-50%', -50, numbers.FORMAT_PERCENTAGE, int
    yield check, '3.45%', 3.45, numbers.FORMAT_PERCENTAGE_00, float
    yield check, '-4.35%', -4.35, numbers.FORMAT_PERCENTAGE_00, float


def test_comma_separated_us():
    yield check, '3,000.0234', 3000.0234, numbers.FORMAT_NUMBER_COMMA_SEPARATED1, float
    yield check, '3,234,000.342', 3234000.342, numbers.FORMAT_NUMBER_COMMA_SEPARATED1, float
    yield check, '5,000,343', 5000343, numbers.FORMAT_NUMBER_COMMA_SEPARATED1, float
    yield check, '-5,334.32', -5334.32, numbers.FORMAT_NUMBER_COMMA_SEPARATED1, float


def test_comma_separated_eur():
    yield check, '5.600,0322', 5600.0322, numbers.FORMAT_NUMBER_COMMA_SEPARATED2, float
    yield check, '5.600,0322', 5600.0322, numbers.FORMAT_NUMBER_COMMA_SEPARATED2, float
    yield check, '8.435.600,0322', 8435600.0322, numbers.FORMAT_NUMBER_COMMA_SEPARATED2, float
    yield check, '5.555.600', 5555600, numbers.FORMAT_NUMBER_COMMA_SEPARATED2, float<commit_msg>update tests to reflect division by 100<commit_after>import datetime
from decimal import Decimal

from testil import eq

from dateutil.tz import tzoffset, tzlocal
from openpyxl.styles import numbers

from corehq.apps.export.const import MISSING_VALUE, EMPTY_VALUE
from couchexport.util import get_excel_format_value


def check(input, output, format, output_type):
    excel_format, value = get_excel_format_value(input)
    eq(excel_format, format)
    eq(value, output)
    eq(type(value), output_type)


def test_integers():
    yield check, '3423', 3423, numbers.FORMAT_NUMBER, int
    yield check, '-234', -234, numbers.FORMAT_NUMBER, int
    yield check, 324, 324, numbers.FORMAT_NUMBER, int


def test_decimal():
    yield check, '4.0345', 4.0345, numbers.FORMAT_NUMBER_00, float
    yield check, '-3.234', -3.234, numbers.FORMAT_NUMBER_00, float
    yield check, 5.032, 5.032, numbers.FORMAT_NUMBER_00, float
    yield check, Decimal('3.00'), 3.00, numbers.FORMAT_NUMBER_00, float


def test_boolean():
    yield check, 'TRUE', True, numbers.FORMAT_GENERAL, bool
    yield check, 'True', True, numbers.FORMAT_GENERAL, bool
    yield check, 'true', True, numbers.FORMAT_GENERAL, bool
    yield check, True, True, numbers.FORMAT_GENERAL, bool

    yield check, 'FALSE', False, numbers.FORMAT_GENERAL, bool
    yield check, 'False', False, numbers.FORMAT_GENERAL, bool
    yield check, 'false', False, numbers.FORMAT_GENERAL, bool
    yield check, False, False, numbers.FORMAT_GENERAL, bool


def test_decimal_eur():
    yield check, '6,9234', 6.9234, numbers.FORMAT_NUMBER_00, float
    yield check, '-5,342', -5.342, numbers.FORMAT_NUMBER_00, float


def test_percentage():
    yield check, '80%', 0.8, numbers.FORMAT_PERCENTAGE, float
    yield check, '-50%', -0.5, numbers.FORMAT_PERCENTAGE, float
    yield check, '3.45%', 0.0345, numbers.FORMAT_PERCENTAGE_00, float
    yield check, '-4.35%', -0.0435, numbers.FORMAT_PERCENTAGE_00, float


def test_comma_separated_us():
    yield check, '3,000.0234', 3000.0234, numbers.FORMAT_NUMBER_COMMA_SEPARATED1, float
    yield check, '3,234,000.342', 3234000.342, numbers.FORMAT_NUMBER_COMMA_SEPARATED1, float
    yield check, '5,000,343', 5000343, numbers.FORMAT_NUMBER_COMMA_SEPARATED1, float
    yield check, '-5,334.32', -5334.32, numbers.FORMAT_NUMBER_COMMA_SEPARATED1, float


def test_comma_separated_eur():
    yield check, '5.600,0322', 5600.0322, numbers.FORMAT_NUMBER_COMMA_SEPARATED2, float
    yield check, '5.600,0322', 5600.0322, numbers.FORMAT_NUMBER_COMMA_SEPARATED2, float
    yield check, '8.435.600,0322', 8435600.0322, numbers.FORMAT_NUMBER_COMMA_SEPARATED2, float
    yield check, '5.555.600', 5555600, numbers.FORMAT_NUMBER_COMMA_SEPARATED2, float
{'fraction_non_alphanumeric': 0.11349353049907579, 'fraction_numerical': 0.09149722735674677, 'mean_word_length': 4.84972972972973, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '15592', 'n_tokens_mistral': 2164, 'n_tokens_neox': 1856, 'n_words': 465}