def run(self, users, sentences): ''' Execute the comand ''' FILE_PATH = DB_PATH + DB_FILE if os.path.exists(FILE_PATH): rename(FILE_PATH, FILE_PATH + '.backup') dbfill(int(users), int(sentences))
def test_dbfill(self): ''' Test the entire filling of the database ''' dbfill(USER_NUM, SENTENCE_NUM) languages = Language.query.all() users = User.query.all() sentences = Sentence.query.all() user_sentence_sum = sum([len(user.sentences) for user in users]) self.assertEqual(len(languages), len(LANG_DICT)) self.assertEqual(len(users), USER_NUM) self.assertEqual(len(sentences), user_sentence_sum)