Completed
Push — master ( 1cff91...86fea4 )
by Chris
04:08
created

test_only_nouns()   A

Complexity

Conditions 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 4
rs 10
1
import unittest
2
from namebot import metrics
3
4
5
class GetNamedNumbersTestCase(unittest.TestCase):
6
7
    def test_basic(self):
8
        res = metrics.get_named_numbers_1_10(
9
            ['360 networks', 'Three Sixty networks'])
10
        self.assertEqual(res['data'], ['Three Sixty networks'])
11
        self.assertEqual(res['summary'], 'Of 2 words, 1 matched')
12
13
14
class NameLengthTestCase(unittest.TestCase):
15
16
    def test_basic(self):
17
        res = metrics.name_length(['short', 'medium', 'veryveryverylong'])
18
        self.assertEqual(res['data'], [5, 6, 16])
19
        self.assertEqual(
20
            res['summary'], 'Of 3 words, the average length of names is...9.0')
21
22
23
class NameVowelCountTestCase(unittest.TestCase):
24
25
    def test_basic(self):
26
        res = metrics.name_vowel_count(['neato'])
27
        self.assertEqual(res['data']['a'], 1)
28
        self.assertEqual(res['data']['e'], 1)
29
        self.assertEqual(res['data']['o'], 1)
30
        self.assertEqual(res['data']['i'], 0)
31
32
33
class NameStartsWithVowelTestCase(unittest.TestCase):
34
35
    def test_basic(self):
36
        res = metrics.name_starts_with_vowel(['aardvark', 'apple', 'banana'])
37
        self.assertEqual(res['data'], None)
38
        self.assertEqual(
39
            res['summary'],
40
            'Of 3 words, 2 or 67.0% are vowels as the first letter.')
41
42
    def test_diff_percentage(self):
43
        words = ['aardvark', 'apple', 'banana', 'fruit', 'orange', 'grape']
44
        res = metrics.name_starts_with_vowel(words)
45
        self.assertEqual(res['data'], None)
46
        self.assertEqual(
47
            res['summary'],
48
            'Of 6 words, 3 or 50.0% are vowels as the first letter.')
49
50
51
class GetSearchResultsTestCase(unittest.TestCase):
52
53
    def test_basic(self):
54
        pass
55
56
57
class GetDigitsFrequencyTestCase(unittest.TestCase):
58
59
    def test_basic(self):
60
        msg = ('Of 3 words, 3 have numbers in them, with a'
61
               ' total of 5 numbers found.')
62
        res = metrics.get_digits_frequency(['7-11', '24/7Networks', '360corp'])
63
        self.assertEqual(res['data'], ['7', '11', '24', '7', '360'])
64
        self.assertEqual(res['summary'], msg)
65
66
67
class GetFirstLetterFrequencyTestCase(unittest.TestCase):
68
69
    def test_basic(self):
70
        res = metrics.get_first_letter_frequency(['fjord', 'flower', 'apple'])
71
        self.assertEqual(res['data']['f'], 2)
72
        self.assertEqual(res['data']['a'], 1)
73
74
75
class GetSpecialCharsTestCase(unittest.TestCase):
76
77
    def test_basic(self):
78
        res = metrics.get_special_chars(['de.li.c.ious', 'flip-to', 'bit.ly'])
79
        self.assertEqual(res['data'], ['.', '.', '.', '-', '.'])
80
        self.assertEqual(
81
            res['summary'],
82
            '5 occurrences of special characters were found in 3 words.')
83
84
85
class GetWordTypesTestCase(unittest.TestCase):
86
87
    def test_basic(self):
88
        res = metrics.get_word_types(['apple', 'cat'])
89
        self.assertEqual(res['data'], [u'apple/NN', u'cat/NN'])
90
91
92
class GetNameSpacesTestCase(unittest.TestCase):
93
94
    def test_basic(self):
95
        res = metrics.get_name_spaces(
96
            ['Itsy bitsy spider co', 'Nifty widgets, Inc'])
97
        self.assertEqual(res['data'][0]['spaces'], 4)
98
        self.assertEqual(res['data'][1]['spaces'], 3)
99
100
101
class GetConsonantRepeatFrequencyTestCase(unittest.TestCase):
102
103
    def test_basic(self):
104
        words = ['cat']
105
        res = metrics.get_consonant_repeat_frequency(words)
106
        self.assertEqual(res, {
107
            'data': 1,
108
            'summary': None
109
        })
110
111
    def test_multiple(self):
112
        words = ['cat', 'foo', 'bar', 'quux']
113
        res = metrics.get_consonant_repeat_frequency(words)
114
        self.assertEqual(res, {
115
            'data': 4,
116
            'summary': None
117
        })
118
119
    def test_none(self):
120
        words = []
121
        res = metrics.get_consonant_repeat_frequency(words)
122
        self.assertEqual(res, {
123
            'data': 0,
124
            'summary': None
125
        })
126
127
128
class GetConsonantDuplicateRepeatFrequencyTestCase(unittest.TestCase):
129
130
    def test_basic(self):
131
        res = metrics.get_consonant_duplicate_repeat_frequency(
132
            ['cannon', 'fodder', 'grapple'])
133
        self.assertEqual(res['data'], 3)
134
135
136
class GetVowelRepeatFrequencyTestCase(unittest.TestCase):
137
138
    def test_basic(self):
139
        res = metrics.get_consonant_duplicate_repeat_frequency(
140
            ['food', 'beef', 'cheese'])
141
        self.assertEqual(res['data'], 3)
142
143
144
class GetAdjectiveVerbOrNounTestCase(unittest.TestCase):
145
146
    def test_only_nouns(self):
147
        res = metrics.get_adjective_verb_or_noun(['cat', 'dog'])
148
        self.assertEqual(res['data']['nouns'], 2)
149
        self.assertEqual(res['data']['verbs'], 0)
150
151
    def test_only_verbs(self):
152
        res = metrics.get_adjective_verb_or_noun(['jumping', 'flying'])
153
        self.assertEqual(res['data']['nouns'], 0)
154
        self.assertEqual(res['data']['verbs'], 2)
155
156
    def test_noun_verbs(self):
157
        res = metrics.get_adjective_verb_or_noun(['jumping', 'dog'])
158
        self.assertEqual(res['data']['nouns'], 1)
159
        self.assertEqual(res['data']['verbs'], 1)
160
161
162
class GetKeywordRelevancyMapTestCase(unittest.TestCase):
163
    # TODO
164
165
    def test_basic(self):
166
        pass
167
168
169
class CheckTrademarkRegistrationTestCase(unittest.TestCase):
170
    # TODO
171
172
    def test_basic(self):
173
        pass
174
175
176
class CheckDomainSearchesTestCase(unittest.TestCase):
177
    # TODO
178
179
    def test_basic(self):
180
        pass
181
182
183
class GetSearchResultCountTestCase(unittest.TestCase):
184
    # TODO
185
186
    def test_basic(self):
187
        pass
188
189
190
class CategorizeWordType(unittest.TestCase):
191
    # TODO
192
193
    def test_basic(self):
194
        pass
195
196
197
class GetWordRankingTestCase(unittest.TestCase):
198
    # TODO
199
200
    def test_basic(self):
201
        pass
202