<commit_before>'''
Framework for writing integration tests for xqueue and external
graders at the level of HTTP requests.
Basic xqueue communication:

1)    XQueueTestClient --(push)--> xqueue --(pull)--> GraderStub subclass

2)    GraderStub subclass --(push)--> xqueue --(push)--> GradeResponseListener

Test cases verify that the output to GradeResponseListener given
inputs specified by XQueueTestClient.


How messages get routed (ActiveGraderStub):

The test client sends messages to a particular queue.

ActiveGraderStub pulls messages from a particular queue, which
is specified by the test client.

ActiveGraderStub pushes the response back to XQueue

XQueue forwards grading responses to GradeResponseListener using
the callback_url provided by the test client.



How messages get routed (PassiveGraderStub):

The test client sends messages to a particular queue.

XQueue checks its settings and finds that the queue has
a URL associated with it.  XQueue forwards the message to that URL.

PassiveGraderStub is listening at the URL and receives POST request
from XQueue.  The stub responds synchronously with the graded response

XQueue forwards grading responses to GradeResponseListener using
the callback_url provided by the test client.


Failure injection:

This framework also makes it easy to inject failure into the system:
for example, by configuring ExternalGraderStub to stop responding
to messages, or to send invalid responses.
'''

from django.test.client import Client
import datetime
import time
import json<commit_msg>Added comment on rabbitmq requirement for integration tests<commit_after>'''
Framework for writing integration tests for xqueue and external
graders at the level of HTTP requests.
Basic xqueue communication:

1)    XQueueTestClient --(push)--> xqueue --(pull)--> GraderStub subclass

2)    GraderStub subclass --(push)--> xqueue --(push)--> GradeResponseListener

Test cases verify that the output to GradeResponseListener given
inputs specified by XQueueTestClient.


How messages get routed (ActiveGraderStub):

The test client sends messages to a particular queue.

ActiveGraderStub pulls messages from a particular queue, which
is specified by the test client.

ActiveGraderStub pushes the response back to XQueue

XQueue forwards grading responses to GradeResponseListener using
the callback_url provided by the test client.



How messages get routed (PassiveGraderStub):

The test client sends messages to a particular queue.

XQueue checks its settings and finds that the queue has
a URL associated with it.  XQueue forwards the message to that URL.

PassiveGraderStub is listening at the URL and receives POST request
from XQueue.  The stub responds synchronously with the graded response

XQueue forwards grading responses to GradeResponseListener using
the callback_url provided by the test client.


Failure injection:

This framework also makes it easy to inject failure into the system:
for example, by configuring ExternalGraderStub to stop responding
to messages, or to send invalid responses.


RabbitMQ Requirement:

Integration tests currently require that rabbitmq is running.
You can start rabbitmq using the commands:

    rabbitmq-server
    rabbitmqctl start_app

See the installation guides at http://www.rabbitmq.com/download.html
for platform-specific instructions.
'''

from django.test.client import Client
import datetime
import time
import json
{'fraction_non_alphanumeric': 0.041216018707980126, 'fraction_numerical': 0.001169248757673195, 'mean_word_length': 4.859589041095891, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3373246', 'n_tokens_mistral': 844, 'n_tokens_neox': 821, 'n_words': 445}