예제 #1
0
def generate_name():
    """main function"""
    title = choice(S_TITLE_TYPES, p=P_TITLE_TYPES)
    has_title = choice(S_TRUEFALSE, p=P_TITLE)
    has_subtitle = choice(S_TRUEFALSE, p=title['p_subtitle'])
    tokens = []

    if has_title:
        tokens.append(Factory.create_token(title['type']))
        if choice(S_TRUEFALSE, p=P_NUMERAL):
            tokens.append(Factory.create_token('Numeral'))

    if not has_title or has_subtitle:
        if has_title:
            tokens.append(":")
        tokens.append(Factory.create_token('Subtitle'))

    if choice(S_TRUEFALSE, p=P_EDITION):
        tokens.append((Factory.create_token('Edition')))

    name = " ".join([str(t) for t in tokens]).replace(" :", ":")
    return name
예제 #2
0
 def test_creation_vthes(self):
     self.assertEqual(Factory.create_token('VTheS').__class__.__name__, 'VTheS')
예제 #3
0
 def test_creation_s1vss2(self):
     self.assertEqual(Factory.create_token('S1VsS2').__class__.__name__, 'S1VsS2')
예제 #4
0
 def test_creation_nonexisting(self):
     # check that s.split fails when the separator is not a string
     with self.assertRaises(ValueError):
         Factory.create_token('NonExistingType')
예제 #5
0
 def test_creation_subtitle(self):
     self.assertEqual(Factory.create_token('Subtitle').__class__.__name__, 'Subtitle')
예제 #6
0
 def test_creation_random(self):
     self.assertEqual(Factory.create_token('RandomWord').__class__.__name__, 'RandomWord')
예제 #7
0
 def test_creation_compound(self):
     self.assertEqual(Factory.create_token('CompoundWord').__class__.__name__, 'CompoundWord')
예제 #8
0
 def test_creation_numeral(self):
     self.assertEqual(Factory.create_token('Numeral').__class__.__name__, 'Numeral')
예제 #9
0
 def test_creation_edition(self):
     self.assertEqual(Factory.create_token('Edition').__class__.__name__, 'Edition')