def test_word_name_init_invalid_filename(self): ''' TODO: review this later the double .mp3 might break in android studio but i'm pretty sure that it would still work on any os ''' audio_file = 'January.mp3.mp3' word = Word(audio_file) self.assertEqual('January', word.getDisplayName()) self.assertEqual('january.mp3.mp3', word.getAndroidFilename())
def setUp(self): audio_file = 'January.mp3' word = Word(audio_file) self.category = Category('Months') self.category.addWord(word) audio_file = 'February.mp3' word = Word(audio_file) self.category.addWord(word) self.library = Library() self.library.addCategory(self.category)
def main( **args ): cwd = os.getcwd() print(f'we are currently here {cwd}') # print(f'{ args }') # for key, value in args.items(): # print(key) # active_dir = findDirectory(cwd) # print(f"ok let's work with {active_dir}") active_dir = FILE_DIR library = Library() f = open('ouput.txt', 'w+') f.write("\tprivate String[] categories = {\n\t") for directory in os.listdir(FILE_DIR): f.write(f'\t\"{directory}\",\n\t') f.write(f"}};\n\t") audiof = open('output_filenames.txt', 'w+') # Assuming that we are in the correct directory, now we can go through them directories = os.listdir(FILE_DIR) directories.remove('__pycache__') for directory in directories: f.write(f"private String[] {directory.lower()}_words = {{\n\t") audiof.write(f"private Integer[] {directory.lower()}_audio = {{\n\t") # Let's start with finding audio files category = Category(directory) directory_path = getPathTo([FILE_DIR, directory]) # Let's go through each file in here and build the vocabulary for audio_file in os.listdir(directory_path): if (idAudioFile(audio_file)): f.write(f'\t\"{audio_file}\",\n\t') src = path.join(directory_path, audio_file) word = Word(audio_file) category.addWord(word) dst = path.join(OUTPUT_DIR, word.getAndroidFilename()) audiof.write(f"\tR.raw.{word.getAndroidFilename()},\n\t") copyfile(src, dst) f.write(f"}};\n\n\n\t") audiof.write(f"}};\n\n\n\t") library.addCategory(category) # end of loop let's see what we've got f.close() audiof.close()
def test_get_work_category_content(self): category = Category("test_work") word = Word('Jordan.mp3') category.addWord(word) word = Word('Dysart.mp3') category.addWord(word) library = Library() library.addCategory(category) template_writer = TemplateWriter(library) test_data = ['6', "words"] template_writer.planWork(*test_data) expected_result = '"jordan",\n\t\t"dysart",' self.assertEqual(expected_result, template_writer.prepLibrary())
def test_get_category_dictionary_with_more(self): category = self.category audio_file = 'December.flac' word = Word(audio_file) category.addWord(word) self.assertDictEqual({\ 'January': 'january.mp3',\ 'December':'december.flac'\ }, category.getCategoryDictionary())
def setUp(self): ''' create a library to use for these tests. ''' words = [Word(f"word_{count+1}") for count in range(10)] categories = [Category(f"category_{count+1}") for count in range(10)] library = Library() for category in categories: library.addCategory(category) for word in words: category.addWord(word) self.tw = TemplateWriter(library) self.testtemplate = "tests/test_template.txt"
def test_word_name_init_simple(self): audio_file = 'January.mp3' word = Word(audio_file) self.assertEqual('January', word.getDisplayName()) self.assertEqual('january.mp3', word.getAndroidFilename())
def test_get_android_filename(self): audio_file = 'December.flac' word = Word(audio_file) self.category.addWord(word) self.assertEqual(['january.mp3', 'december.flac'], self.category.printFilenames())
def setUp(self): audio_file = 'January.mp3' word = Word(audio_file) self.category = Category('Months') self.category.addWord(word)