def test_get_verdict(self): (response_status, verdict_content) = get_verdict('TPH', '民事', '105', '重上', '608') self.assertEqual(200, response_status) target_keys = set({ 'identity', 'reason', 'adjudged_on', 'pronounced_on', 'court', 'judges_names', 'related_roles', 'lawyer_names', 'prosecutor_names', 'party_names', 'related_stories', 'original_url', 'body', 'main_content' }) verdict_keys = set({}) for key in verdict_content.keys(): verdict_keys.add(key) exist_all_keys = True if not target_keys == verdict_keys: exist_all_keys = False lack_keys = target_keys.difference(verdict_keys) print('The verdict lack %s keys' % lack_keys) self.assertTrue(exist_all_keys)
def test_get_verdict(): sentiment = {('DGB', 'digibyte'): 0.0, ('BCH', 'bitcoin cash'): -0.6} overall = 0.167 to_buy = main.get_verdict(sentiment, overall) assert to_buy == [('DGB', 'digibyte')]