+def test_fetch_existing_words_phrases_basic(special_phrases_importer, word_table,
+ temp_db_conn):
+ """
+ Check for the fetch_existing_words_phrases() method.
+ It should return special phrase term added to the word
+ table.
+ """
+ with temp_db_conn.cursor() as temp_db_cursor:
+ query ="""
+ INSERT INTO word VALUES(99999, 'lookup_token', 'normalized_word',
+ 'class', 'type', null, 0, 'near');
+ """
+ temp_db_cursor.execute(query)
+
+ assert not special_phrases_importer.words_phrases_to_delete
+ special_phrases_importer._fetch_existing_words_phrases()
+ contained_phrase = special_phrases_importer.words_phrases_to_delete.pop()
+ assert contained_phrase == ('normalized_word', 'class', 'type', 'near')
+
+def test_fetch_existing_words_phrases_housenumber(special_phrases_importer, word_table,
+ temp_db_conn):
+ """
+ Check for the fetch_existing_words_phrases() method.
+ It should return nothing as the term added correspond
+ to a housenumber term.
+ """
+ with temp_db_conn.cursor() as temp_db_cursor:
+ query ="""
+ INSERT INTO word VALUES(99999, 'lookup_token', 'normalized_word',
+ 'place', 'house', null, 0, 'near');
+ """
+ temp_db_cursor.execute(query)
+
+ special_phrases_importer._fetch_existing_words_phrases()
+ assert not special_phrases_importer.words_phrases_to_delete
+
+def test_fetch_existing_words_phrases_postcode(special_phrases_importer, word_table,
+ temp_db_conn):
+ """
+ Check for the fetch_existing_words_phrases() method.
+ It should return nothing as the term added correspond
+ to a postcode term.
+ """
+ with temp_db_conn.cursor() as temp_db_cursor:
+ query ="""
+ INSERT INTO word VALUES(99999, 'lookup_token', 'normalized_word',
+ 'place', 'postcode', null, 0, 'near');
+ """
+ temp_db_cursor.execute(query)
+
+ special_phrases_importer._fetch_existing_words_phrases()
+ assert not special_phrases_importer.words_phrases_to_delete
+
+def test_fetch_existing_place_classtype_tables(special_phrases_importer, temp_db_conn):
+ """
+ Check for the fetch_existing_place_classtype_tables() method.
+ It should return the table just created.
+ """
+ with temp_db_conn.cursor() as temp_db_cursor:
+ query = 'CREATE TABLE place_classtype_testclasstypetable()'
+ temp_db_cursor.execute(query)
+
+ special_phrases_importer._fetch_existing_place_classtype_tables()
+ contained_table = special_phrases_importer.table_phrases_to_delete.pop()
+ assert contained_table == 'place_classtype_testclasstypetable'
+