Exemple #1
0
 def test_parse_args_samplerate_fail(self):
     '''Test to see if there is a command line syntax error of wth error code 2
     '''
     with self.assertRaises(SystemExit) as err:
         automate_download_freesound.parse_args([
             'automate_download_freesound.py', "dogs,cats,birds,",
             "--sample-rate", "2500"
         ])
     self.assertEqual(err.exception.code, 2)
Exemple #2
0
 def test_parse_args_samplerate_pass(self):
     args = automate_download_freesound.parse_args([
         'automate_download_freesound.py', "dogs,cats,birds,",
         "--sample-rate", "48000"
     ])
     assert int(args.samplerate) in [
         None, 11025, 16000, 22050, 44100, 48000, 88200, 96000
     ]
Exemple #3
0
 def test_parse_args_format_pass(self):
     args = automate_download_freesound.parse_args([
         'automate_download_freesound.py', "dogs,cats,birds,",
         "--file-format", "wav"
     ])
     assert args.file_format in [
         None, "wav", "flac", "aiff", "ogg", "mp3", "m4a"
     ]
Exemple #4
0
 def test_parse_args_sound_three(self):
     '''
     Test for leading/extra commas as input
     '''
     args = automate_download_freesound.parse_args(
         ['automate_download_freesound.py', "dogs,cats,birds,"])
     self.assertEqual(args.sounds, ['dogs', 'cats', 'birds'])
     self.assertEqual(args.downloadpath,
                      os.path.expanduser("~") + "/Downloads/")
     self.assertEqual(args.file_format, None)
     self.assertEqual(args.samplerate, None)
     self.assertFalse(args.advanced_filter)
Exemple #5
0
 def test_parse_args_sound_one(self):
     '''
     Basic test to test for the sound positional argument of parse_args()
     '''
     args = automate_download_freesound.parse_args(
         ['automate_download_freesound.py', 'dogs'])
     self.assertEqual(args.sounds, ['dogs'])
     self.assertEqual(args.downloadpath,
                      os.path.expanduser("~") + "/Downloads/")
     self.assertEqual(args.file_format, None)
     self.assertEqual(args.samplerate, None)
     self.assertFalse(args.advanced_filter)
Exemple #6
0
    def test_simulate_download_basic(self):
        '''
        Testing with no filters, just the one positional argument
        '''

        args = automate_download_freesound.parse_args(
            ['automate_download_freesound.py', 'toaster pop set'])
        download_count = automate_download_freesound.simulate_download(
            args.sounds[0], self.download_path, self.email, self.password,
            args)
        self.assertEqual(download_count, 2)
        update_download_path = os.path.join(self.download_path,
                                            'toaster pop set')
        self.assertEqual(len(os.listdir(update_download_path)), download_count)
Exemple #7
0
 def test_parse_args_sound_two(self):
     '''
     Test for multiple arguments that include spaces, but separated by commas
     '''
     args = automate_download_freesound.parse_args([
         'automate_download_freesound.py',
         "dogs barking loud, birds chirping loud"
     ])
     self.assertEqual(args.sounds,
                      ['dogs barking loud', 'birds chirping loud'])
     self.assertEqual(args.downloadpath,
                      os.path.expanduser("~") + "/Downloads/")
     self.assertEqual(args.file_format, None)
     self.assertEqual(args.samplerate, None)
     self.assertFalse(args.advanced_filter)
Exemple #8
0
    def test_simulate_download_optional_arguments(self):
        '''
         Testing with optional filter arguments
        '''

        args = automate_download_freesound.parse_args([
            'automate_download_freesound.py', 'tiger', '--sample-rate',
            '48000', '--file-format', 'mp3'
        ])
        download_count = automate_download_freesound.simulate_download(
            args.sounds[0], self.download_path, self.email, self.password,
            args)
        self.assertEqual(download_count, 2)
        update_download_path = os.path.join(self.download_path, 'tiger')
        self.assertEqual(len(os.listdir(update_download_path)), download_count)
Exemple #9
0
 def test_simulate_download_advanced_filters(self):
     '''
     Testing with optional arguments and advanced filters
     '''
     args = automate_download_freesound.parse_args([
         'automate_download_freesound.py', 'glass breaking',
         '--sample-rate', '48000', '--file-format', 'flac',
         '--advanced-filter', 'True'
     ])
     download_count = automate_download_freesound.simulate_download(
         args.sounds[0], self.download_path, self.email, self.password,
         args)
     self.assertEqual(download_count, 3)
     update_download_path = os.path.join(self.download_path,
                                         'glass breaking')
     self.assertEqual(len(os.listdir(update_download_path)), download_count)
Exemple #10
0
 def test_parse_args_download_path_pass(self):
     args = automate_download_freesound.parse_args(
         ['automate_download_freesound.py', "dogs,cats,birds,"])
     self.assertEqual(args.downloadpath,
                      os.path.expanduser("~") + "/Downloads/")