<commit_before>"""
Wrapper around tests
"""
import io
import unittest

from django.contrib.auth.models import User
from django.core.files.uploadedfile import SimpleUploadedFile
from django.test import Client

from .models import *

ADMIN_PASSWORD = '<PASSWORD>'
CLAIMED_A_PASSWORD = '<PASSWORD>'
CLAIMED_B_PASSWORD = '<PASSWORD>'

def create_users():
    User.objects.create_superuser('admin',
                                  '<EMAIL>',
                                  ADMIN_PASSWORD)
    User.objects.create_user('claimed-a',
                                  '<EMAIL>',
                                  CLAIMED_A_PASSWORD)
    User.objects.create_user('claimed-b',
                                  '<EMAIL>',
                                  CLAIMED_B_PASSWORD)


def create_claimed():
    create_users()

    data = {
        "user": User.objects.get(username="claimed-b"),
        "forenames": "B",
        "surname": "B",
        "email": "<EMAIL>",
        "phone": "+441111111111",
        "gender": "M",
        "home_country": "GB",
        "home_city": "L",
        "research_area": "Y000",
        "research_area_code": "Y000",
        "affiliation": "College",
        "funding": "Self-funded",
        "work_description": "Work",
        "selected": True,
    }

    with io.BytesIO(b'000') as fake_file:
        data.update({
            "photo": SimpleUploadedFile('b_b.jpg', fake_file.read()),
        })

    claimed = Claimed(**data)
    claimed.save()

    data = {
        "user": User.objects.get(username="claimed-a"),
        "forenames": "A",
        "surname": "A",
        "email": "<EMAIL>",
        "phone": "+441111111111",
        "gender": "M",
        "home_country": "GB",
        "home_city": "L",
        "research_area": "Y000",
        "research_area_code": "Y000",
        "affiliation": "College",
        "funding": "Self-funded",
        "work_description": "Work",
        "selected": True,
    }

    with io.BytesIO(b'000') as fake_file:
        data.update({
            "photo": SimpleUploadedFile('a_a.jpg', fake_file.read()),
        })

    claimed = Claimed(**data)
    claimed.save()
    return claimed.id

def create_fund():
    claimed_id = create_claimed()
    claimed = Claimed.objects.get(id=claimed_id)
    
    data = {
        "claimed": claimed,
        "category": "A",
        "name": "Fake",
        "url": "http://fake.com",
        "country": "GB",
        "city": "L",
        "start_date": "2014-02-20",
        "end_date": "2014-02-22",
        "budget_request_travel": "100.00",
        "budget_request_attendance_fees": "0.00",
        "budget_request_subsistence_cost": "0.00",
        "budget_request_venue_hire": "0.00",
        "budget_request_catering": "0.00",
        "budget_request_others": "0.00",
        "justification": ":-)",
        "additional_info": "",
        }

    fund = Fund(**data)
    fund.save()
    return claimed_id, fund.id

def create_all():
    claimed_id, fund_id = create_fund()
    fund = Fund.objects.get(id=fund_id)

    data = {
        "fund": fund,
        "amount_claimed": "100.00",
        }

    with io.BytesIO(b'000') as fake_file:
        data.update({
            "claim": SimpleUploadedFile('fake-claim.jpg', fake_file.read()),
        })

    expense = Expense(**data)
    expense.save()

    data = {
        "fund": fund,
        "draft_url": "http://software.ac.uk",
        }

    blog = Blog(**data)
    blog.save()

    return claimed_id, fund_id, expense.id, blog.id
<commit_msg>Fix bug on testwrapper<commit_after>"""
Wrapper around tests
"""
import io
import unittest

from django.contrib.auth.models import User
from django.core.files.uploadedfile import SimpleUploadedFile
from django.test import Client

from .models import *

ADMIN_PASSWORD = '<PASSWORD>'
CLAIMED_A_PASSWORD = '<PASSWORD>'
CLAIMED_B_PASSWORD = '<PASSWORD>'

def create_users():
    User.objects.create_superuser('admin',
                                  '<EMAIL>',
                                  ADMIN_PASSWORD)
    User.objects.create_user('claimed-a',
                                  '<EMAIL>',
                                  CLAIMED_A_PASSWORD)
    User.objects.create_user('claimed-b',
                                  '<EMAIL>',
                                  CLAIMED_B_PASSWORD)


def create_claimed():
    create_users()

    data = {
        "user": User.objects.get(username="claimed-b"),
        "forenames": "B",
        "surname": "B",
        "email": "<EMAIL>",
        "phone": "+441111111111",
        "gender": "M",
        "home_country": "GB",
        "home_city": "L",
        "research_area": "Y000",
        "research_area_code": "Y000",
        "affiliation": "College",
        "funding": "Self-funded",
        "work_description": "Work",
        "selected": True,
    }

    with io.BytesIO(b'000') as fake_file:
        data.update({
            "photo": SimpleUploadedFile('b_b.jpg', fake_file.read()),
        })

    claimed = Claimed(**data)
    claimed.save()

    data = {
        "user": User.objects.get(username="claimed-a"),
        "forenames": "A",
        "surname": "A",
        "email": "<EMAIL>",
        "phone": "+441111111111",
        "gender": "M",
        "home_country": "GB",
        "home_city": "L",
        "research_area": "Y000",
        "research_area_code": "Y000",
        "affiliation": "College",
        "funding": "Self-funded",
        "work_description": "Work",
        "selected": True,
    }

    with io.BytesIO(b'000') as fake_file:
        data.update({
            "photo": SimpleUploadedFile('a_a.jpg', fake_file.read()),
        })

    claimed = Claimed(**data)
    claimed.save()
    return claimed.id

def create_fund():
    claimed_id = create_claimed()
    claimed = Claimed.objects.get(id=claimed_id)
    
    data = {
        "claimed": claimed,
        "category": "A",
        "status": "A",
        "name": "Fake",
        "url": "http://fake.com",
        "country": "GB",
        "city": "L",
        "start_date": "2014-02-20",
        "end_date": "2014-02-22",
        "budget_request_travel": "100.00",
        "budget_request_attendance_fees": "0.00",
        "budget_request_subsistence_cost": "0.00",
        "budget_request_venue_hire": "0.00",
        "budget_request_catering": "0.00",
        "budget_request_others": "0.00",
        "justification": ":-)",
        "additional_info": "",
        }

    fund = Fund(**data)
    fund.save()
    return claimed_id, fund.id

def create_all():
    claimed_id, fund_id = create_fund()
    fund = Fund.objects.get(id=fund_id)

    data = {
        "fund": fund,
        "amount_claimed": "100.00",
        }

    with io.BytesIO(b'000') as fake_file:
        data.update({
            "claim": SimpleUploadedFile('fake-claim.jpg', fake_file.read()),
        })

    expense = Expense(**data)
    expense.save()

    data = {
        "fund": fund,
        "draft_url": "http://software.ac.uk",
        }

    blog = Blog(**data)
    blog.save()

    return claimed_id, fund_id, expense.id, blog.id

{'fraction_non_alphanumeric': 0.1598639455782313, 'fraction_numerical': 0.024376417233560092, 'mean_word_length': 2.0418103448275864, 'pattern_counts': {'":': 105, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1502504', 'n_tokens_mistral': 2421, 'n_tokens_neox': 2242, 'n_words': 413}