Skip to content

Commit

Permalink
testrunner cleanup, chomsky added to factory
Browse files Browse the repository at this point in the history
  • Loading branch information
skoczen committed Oct 30, 2011
1 parent 0a13cb6 commit d7ddf59
Show file tree
Hide file tree
Showing 7 changed files with 950 additions and 14 deletions.
5 changes: 5 additions & 0 deletions functional_tests/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from decimal import getcontext, Decimal
getcontext().prec = 7
from django.contrib.localflavor.us.us_states import STATE_CHOICES
from functional_tests.lib.chomsky import generate_chomsky

class DjangoFunctionalFactory:
@classmethod
Expand Down Expand Up @@ -75,6 +76,10 @@ def test_cc_number(cls, valid=True):
else:
return cls.invalid_test_cc_number()

@classmethod
def random_conversation(cls, paragraphs=3):
return generate_chomsky(paragraphs)




Expand Down
Empty file.
130 changes: 130 additions & 0 deletions functional_tests/lib/chomsky.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Chomsky random text generator, version 1.1, Raymond Hettinger, 2005/09/13
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/440546

import string

"""CHOMSKY is an aid to writing linguistic papers in the style
of the great master. It is based on selected phrases taken
from actual books and articles written by Noam Chomsky.
Upon request, it assembles the phrases in the elegant
stylistic patterns that Chomsky is noted for.
To generate n sentences of linguistic wisdom, type
(CHOMSKY n) -- for example
(CHOMSKY 5) generates half a screen of linguistic truth."""

leadins = """To characterize a linguistic level L,
On the other hand,
This suggests that
It appears that
Furthermore,
We will bring evidence in favor of the following thesis:
To provide a constituent structure for T(Z,K),
From C1, it follows that
For any transformation which is sufficiently diversified in \
application to be of any interest,
Analogously,
Clearly,
Note that
Of course,
Suppose, for instance, that
Thus
With this clarification,
Conversely,
We have already seen that
By combining adjunctions and certain deformations,
I suggested that these results would follow from the assumption that
If the position of the trace in (99c) were only relatively \
inaccessible to movement,
However, this assumption is not correct, since
Comparing these examples with their parasitic gap counterparts in \
(96) and (97), we see that
In the discussion of resumptive pronouns following (81),
So far,
Nevertheless,
For one thing,
Summarizing, then, we assume that
A consequence of the approach just outlined is that
Presumably,
On our assumptions,
It may be, then, that
It must be emphasized, once again, that
Let us continue to suppose that
Notice, incidentally, that """
# List of LEADINs to buy time.

subjects = """ the notion of level of grammaticalness
a case of semigrammaticalness of a different sort
most of the methodological work in modern linguistics
a subset of English sentences interesting on quite independent grounds
the natural general principle that will subsume this case
an important property of these three types of EC
any associated supporting element
the appearance of parasitic gaps in domains relatively inaccessible \
to ordinary extraction
the speaker-hearer's linguistic intuition
the descriptive power of the base component
the earlier discussion of deviance
this analysis of a formative as a pair of sets of features
this selectionally introduced contextual feature
a descriptively adequate grammar
the fundamental error of regarding functional notions as categorial
relational information
the systematic use of complex symbols
the theory of syntactic features developed earlier"""
# List of SUBJECTs chosen for maximum professorial macho.

verbs = """can be defined in such a way as to impose
delimits
suffices to account for
cannot be arbitrary in
is not subject to
does not readily tolerate
raises serious doubts about
is not quite equivalent to
does not affect the structure of
may remedy and, at the same time, eliminate
is not to be considered in determining
is to be regarded as
is unspecified with respect to
is, apparently, determined by
is necessary to impose an interpretation on
appears to correlate rather closely with
is rather different from"""
#List of VERBs chosen for autorecursive obfuscation.

objects = """ problems of phonemic and morphological analysis.
a corpus of utterance tokens upon which conformity has been defined \
by the paired utterance test.
the traditional practice of grammarians.
the levels of acceptability from fairly high (e.g. (99a)) to virtual \
gibberish (e.g. (98d)).
a stipulation to place the constructions into these various categories.
a descriptive fact.
a parasitic gap construction.
the extended c-command discussed in connection with (34).
the ultimate standard that determines the accuracy of any proposed grammar.
the system of base rules exclusive of the lexicon.
irrelevant intervening contexts in selectional rules.
nondistinctness in the sense of distinctive feature theory.
a general convention regarding the forms of the grammar.
an abstract underlying order.
an important distinction in language use.
the requirement that branching is not tolerated within the dominance \
scope of a complex symbol.
the strong generative capacity of the theory."""
# List of OBJECTs selected for profound sententiousness.

import textwrap, random
from itertools import chain, islice, izip

def generate_chomsky(times=5, line_length=72):
parts = []
for part in (leadins, subjects, verbs, objects):
phraselist = map(str.strip, part.splitlines())
random.shuffle(phraselist)
parts.append(phraselist)
output = chain(*islice(izip(*parts), 0, times))
return textwrap.fill(string.join(output), line_length)

if __name__ == '__main__':
generate_chomsky()
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ def handle(self, *args, **options):
celery_subprocess = subprocess.Popen(cel_command,shell=True, **outputs)
file_uploader_subprocess = subprocess.Popen(file_uploader_command,shell=True, cwd=join(settings.PROJECT_ROOT,"templates/test_file_uploads"), **outputs )

from django.core.cache import cache
cache.clear()

# Give everything time to spin up. Ridiculous, but necessary.
time.sleep(10)

Expand Down
17 changes: 6 additions & 11 deletions functional_tests/management/commands/selenium_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ def handle(self, *args, **options):
"stderr":output,
"stdout":output,
}




lots_of_options_dict = {
've_path': settings.VIRTUALENV_PATH,
Expand All @@ -32,19 +31,15 @@ def handle(self, *args, **options):
}

sel_command = "java -jar %(lib_path)s/selenium-server.jar -timeout 30 -port %(selenium_port)s -userExtensions %(lib_path)s/user-extensions.js" % lots_of_options_dict
gun_command = "sleep 17s; %(ve_path)s/bin/python manage.py run_gunicorn -w 2 -b 0.0.0.0:%(http_port)s --settings=envs.%(test_server_settings)s" % lots_of_options_dict
cel_command = "sleep 17s; %(ve_path)s/bin/python manage.py celeryd --settings=envs.%(test_server_settings)s" % lots_of_options_dict
gun_command = "%(ve_path)s/bin/python manage.py run_gunicorn -w 2 -b 0.0.0.0:%(http_port)s --settings=envs.%(test_server_settings)s" % lots_of_options_dict
cel_command = "%(ve_path)s/bin/python manage.py celeryd --settings=envs.%(test_server_settings)s" % lots_of_options_dict
file_uploader_command = "%(ve_path)s/bin/python -m SimpleHTTPServer 8199" % lots_of_options_dict

selenium_subprocess = subprocess.Popen(sel_command,shell=True, **outputs )
file_uploader_subprocess = subprocess.Popen(file_uploader_command,shell=True, cwd=join(settings.PROJECT_ROOT,"templates/test_file_uploads"), **outputs )
time.sleep(10)
gunicorn_subprocess = subprocess.Popen(gun_command,shell=True, **outputs )
celery_subprocess = subprocess.Popen(cel_command,shell=True, **outputs )
file_uploader_subprocess = subprocess.Popen(file_uploader_command,shell=True, cwd=join(settings.PROJECT_ROOT,"templates/test_file_uploads"), **outputs )

from django.core.cache import cache
cache.clear()

# Give everything time to spin up. Ridiculous, but necessary.
time.sleep(15)

try:
call_command('test', "--with-selenium", *args, **options )
Expand Down
Loading

0 comments on commit d7ddf59

Please sign in to comment.