Пример #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
Пример #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
Пример #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
Пример #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
Пример #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)
Пример #6
0
 def getValue(self):
   return ' '.join(RandomPhraseProvider.getValue(self)
                   for _ in range(random.randint(5, 10)))
Пример #7
0
 def getValue(self):
   return ' '.join(RandomPhraseProvider.getValue(self)
                   for _ in range(random.randint(5, 10)))
Пример #8
0
 def setUp(self):
   self.provider = RandomPhraseProvider()