Esempio n. 1
0
 def getValue(self):
   #TODO(sttwister): This could be improved
   markdown = ''
   for _ in range(random.randint(5, 10)):
     markdown += RandomPhraseProvider.getValue(self) + '\n===\n\n'
     markdown += RandomParagraphProvider.getValue(self) + '\n\n'
   return markdown
Esempio n. 2
0
 def getValue(self):
   #TODO(sttwister): This could be improved
   markdown = ''
   for _ in range(random.randint(5, 10)):
     markdown += RandomPhraseProvider.getValue(self) + '\n===\n\n'
     markdown += RandomParagraphProvider.getValue(self) + '\n\n'
   return markdown
Esempio n. 3
0
 def getValue(self):
   #TODO(sttwister): This could be improved
   html = '<html><body>'
   for _ in range(random.randint(5, 10)):
     html += '<h1>' + RandomPhraseProvider.getValue(self) + '</h1>'
     html += '<p>' + RandomParagraphProvider.getValue(self) + '</p>'
   html += '</body></html>'
   return html
Esempio n. 4
0
 def getValue(self):
   #TODO(sttwister): This could be improved
   html = '<html><body>'
   for _ in range(random.randint(5, 10)):
     html += '<h1>' + RandomPhraseProvider.getValue(self) + '</h1>'
     html += '<p>' + RandomParagraphProvider.getValue(self) + '</p>'
   html += '</body></html>'
   return html
Esempio n. 5
0
class RandomPhraseProviderTest(unittest.TestCase):
  """Test class for RandomPhraseProvider.
  """

  def setUp(self):
    self.provider = RandomPhraseProvider()

  def testGetValue(self):
    """Tests getValue().
    """
    value = self.provider.getValue()
    self.assertTrue(self.provider.DEFAULT_MIN_WORDS <= len(value.split(' ')) <=
                    self.provider.DEFAULT_MAX_WORDS)

  def testInvalidParameters(self):
    """Tests getValue() with invalid user supplied parameters.
    """
    min_words = 'asdf'
    max_words = None
    self.provider.param_values = {'min_words': min_words,
                                  'max_words': max_words}
    self.assertRaises(ParameterValueError, self.provider.getValue)
Esempio n. 6
0
 def getValue(self):
   return ' '.join(RandomPhraseProvider.getValue(self)
                   for _ in range(random.randint(5, 10)))
Esempio n. 7
0
 def getValue(self):
   return ' '.join(RandomPhraseProvider.getValue(self)
                   for _ in range(random.randint(5, 10)))
Esempio n. 8
0
 def setUp(self):
   self.provider = RandomPhraseProvider()