<commit_before># -*- encoding: utf-8 -*-
# [call this script from a3 root with ./bin/python3.4 as interpreter.]
# FIXME: Doesn't work as requests is missing. Use a Python with requests
# installed.

import glob
import json
import os
import re
import requests

email_spool_path = os.environ['A3_ROOT'] + '/var/mail/new/'
root_uri = 'http://localhost:6541'
verbose = True

# for more javascript-ish json representation:
null = None
true = True
false = False

def register_user(user_name):
    uri = root_uri + '/principals/users/'
    headers = {
        'X-User-Token': '<PASSWORD>',
        'X-User-Path': '/principals/users/0000000/',
        'Content-Type': 'application/json;charset=UTF-8',
        'Accept': 'application/json, text/plain, */*',
        'Accept-Encoding': 'gzip,deflate',
        'Connection': 'keep-alive',
        'Accept-Language': 'en-US,en;q=0.8',
        'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36',
        'Content-Length': '238'
        }
    body = json.dumps({
            'data': {
                'adhocracy_core.sheets.principal.IPasswordAuthentication': {
                    'password': 'password'
                },
                'adhocracy_core.sheets.principal.IUserBasic': {
                'email': user_name + '@some<EMAIL>',
                'name': user_name
            }
        },
        'content_type': 'adhocracy_core.resources.principal.IUser'
    })
    response = requests.post(uri, headers=headers, data=body)
    if verbose:
        print('\n')
        print(uri)
        print(headers)
        print(body)
        print(response)
        print(response.text)

    assert response.status_code == 200


def activate_account(path):
    uri = root_uri + '/activate_account'
    headers = {
        'X-User-Token': '<PASSWORD>',
        'X-User-Path': '/principals/users/0000000/',
        'Content-Type': 'application/json;charset=UTF-8',
        'Accept': 'application/json, text/plain, */*',
        'Accept-Encoding': 'gzip,deflate',
        'Accept-Language': 'en-US,en;q=0.8,de;q=0.6',
        'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36',
        'Content-Length': '45'
    }
    body = json.dumps({
        'path': path<commit_msg>Fix example domain in fixture script<commit_after># -*- encoding: utf-8 -*-
# [call this script from a3 root with ./bin/python3.4 as interpreter.]
# FIXME: Doesn't work as requests is missing. Use a Python with requests
# installed.

import glob
import json
import os
import re
import requests

email_spool_path = os.environ['A3_ROOT'] + '/var/mail/new/'
root_uri = 'http://localhost:6541'
verbose = True

# for more javascript-ish json representation:
null = None
true = True
false = False

def register_user(user_name):
    uri = root_uri + '/principals/users/'
    headers = {
        'X-User-Token': '<PASSWORD>',
        'X-User-Path': '/principals/users/0000000/',
        'Content-Type': 'application/json;charset=UTF-8',
        'Accept': 'application/json, text/plain, */*',
        'Accept-Encoding': 'gzip,deflate',
        'Connection': 'keep-alive',
        'Accept-Language': 'en-US,en;q=0.8',
        'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36',
        'Content-Length': '238'
        }
    body = json.dumps({
            'data': {
                'adhocracy_core.sheets.principal.IPasswordAuthentication': {
                    'password': 'password'
                },
                'adhocracy_core.sheets.principal.IUserBasic': {
                'email': user_name + '@<EMAIL>',
                'name': user_name
            }
        },
        'content_type': 'adhocracy_core.resources.principal.IUser'
    })
    response = requests.post(uri, headers=headers, data=body)
    if verbose:
        print('\n')
        print(uri)
        print(headers)
        print(body)
        print(response)
        print(response.text)

    assert response.status_code == 200


def activate_account(path):
    uri = root_uri + '/activate_account'
    headers = {
        'X-User-Token': '<PASSWORD>',
        'X-User-Path': '/principals/users/0000000/',
        'Content-Type': 'application/json;charset=UTF-8',
        'Accept': 'application/json, text/plain, */*',
        'Accept-Encoding': 'gzip,deflate',
        'Accept-Language': 'en-US,en;q=0.8,de;q=0.6',
        'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36',
        'Content-Length': '45'
    }
    body = json.dumps({
        'path': path
{'fraction_non_alphanumeric': 0.15623009976650393, 'fraction_numerical': 0.04033113988537466, 'mean_word_length': 2.4444444444444446, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, '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': '7382721', 'n_tokens_mistral': 1679, 'n_tokens_neox': 1542, 'n_words': 310}