Skip to content

Commit

Permalink
added tests for sentence generating function.
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa-mahmoud committed Nov 4, 2016
1 parent eaeef1e commit 4f1b663
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from djenerator.fields_generator import generate_positive_integer
from djenerator.fields_generator import generate_positive_small_integer
from djenerator.fields_generator import generate_small_integer
from djenerator.fields_generator import generate_sentence
from djenerator.fields_generator import generate_string
from djenerator.fields_generator import generate_time
from djenerator.generate_test_data import create_model
Expand Down Expand Up @@ -590,6 +591,19 @@ def test(self):
# Test generate_float


class TestFieldsGeneratorStringGenerators(TestCase):
def test(self):
for length in xrange(2, 50):
seperators = [['.'], ['-', '_'], ['@']]
for sep in seperators:
for _ in xrange(20):
gen_val = generate_sentence(length, sep)
self.assertEqual(gen_val.__class__, str)
self.assertLessEqual(len(gen_val), length * 2)
reg = '(?:\w+(?:%s))*\w+\.' % str.join('|', sep)
self.assertRegexpMatches(gen_val, reg)


class TestFieldsGeneratorChar(TestCase):
def test(self):
#Test generate_email, generate_string, generate_sentence, generate_text
Expand Down

0 comments on commit 4f1b663

Please sign in to comment.