def test_full_loop(self): """Check that annotate_all_messages processes all messages""" # add a tweet to the source_table sql_convenience.insert_tweet(TWEET1, TWEET1CLASS, config.db_conn, self.source_table) self.check_we_have_only_n_record(self.source_table, 1) ## get all tweets from source_table, via annotation, into ## destination_table self.api.annotate_all_messages() self.assertTrue(self.api.is_brand_of('apple', 234)) self.assertFalse(self.api.is_brand_of('orange', 234))
def test_add_1_annotated_row(self): cls = 0 sql_convenience.insert_tweet(tweet1, cls, config.db_conn, self.annotations_table) # now check we have the expected 1 row cursor = config.db_conn.cursor() sql = "SELECT * FROM {}".format(self.annotations_table) cursor.execute(sql) all_rows = cursor.fetchall() self.assertEqual(len(all_rows), 1, "We expect just 1 row") count = tweet_annotator.count_nbr_annotated_rows(config.db_conn, self.annotations_table) #from nose.tools import set_trace; set_trace() self.assertEqual(count, 1)
def test_add_1_annotated_row(self): cls = 0 sql_convenience.insert_tweet(tweet1, cls, config.db_conn, self.annotations_table) # now check we have the expected 1 row cursor = config.db_conn.cursor() sql = "SELECT * FROM {}".format(self.annotations_table) cursor.execute(sql) all_rows = cursor.fetchall() self.assertEqual(len(all_rows), 1, "We expect just 1 row") count = tweet_annotator.count_nbr_annotated_rows( config.db_conn, self.annotations_table) #from nose.tools import set_trace; set_trace() self.assertEqual(count, 1)
def insert_tweet(self, tweet): # add a tweet to the source_table sql_convenience.insert_tweet(tweet, tweet1class, config.db_conn, self.source_table)
def determine_class_and_insert_tweet(tweet, db_conn, annotations_table, keyword): cls = determine_class(tweet, keyword) if cls != sql_convenience.CLASS_UNKNOWN: sql_convenience.insert_tweet(tweet, cls, db_conn, annotations_table)