Esempio n. 1
0
 def test_download_no_clobber(self):
     client = APIClient()
     p = client.get(
         'http://127.0.0.1/wget-submit',
         {
             #  Our config options
             u'url': self.google,
             u'output_path': self.test_dir,
             u'depth_level': u'0',
             u'recursive': u'true',
             u'no_parent': u'true',
             u'check_certificate': u'false',
             #  What type of download do we want to do if not playlist or song
             u'no_clobber': u'true',
             u'robots': u'true',
             u'mirror': u'false',
             u'accept': u'false',
             u'reject': u'false',
         },
         format='json')
     self.assertIsInstance(p, JsonResponse)
     TestCase.assertContains(
         self,
         response=p,
         text="{\"success\": \"Downloaded Files successfully\"}")
Esempio n. 2
0
 def test_login_success(self):
     response = self.client.post('/accounts/login/', {
         'username': '******',
         'password': '******'
     },
                                 follow=True)
     TC.assertContains(self, response=response, text='Logout')
Esempio n. 3
0
 def test_config_options_success(self):
     client = APIClient()
     p = client.get(
         'http://127.0.0.1/soundcloud-submit',
         {
             #  Our config options
             u'url': self.playlist_url,
             u'output_path': self.test_dir,
             u'is_playlist_or_song': u'true',
             u'continue_if_exists': u'true',
             u'only_mp3': u'true',
             u'add_artist_to_files': u'true',
             #  What type of download do we want to do if not playlist or song
             u'download_all_tracks_and_reposts': u'false',
             u'download_user_uploads': u'false',
             u'download_favorites': u'false',
             u'download_playlist': u'false',
             u'download_like_and_owned_playlists': u'false',
             u'downloaded_commented_tracks': u'false'
         },
         format='json')
     self.assertIsInstance(p, JsonResponse)
     TestCase.assertContains(
         self,
         response=p,
         text="{\"success\": \"Downloaded Files successfully\"}")
Esempio n. 4
0
 def test_login_error(self):
     response = self.client.post('/accounts/login/', {
         'username': '******',
         'password': '******'
     },
                                 follow=True)
     TC.assertContains(self, response=response, text='Login')
Esempio n. 5
0
 def test_delete(self):
     self.client.post('/accounts/login/', {
         'username': '******',
         'password': '******'
     },
                      follow=True)
     response = self.client.get('/submissions/', follow=True)
     #         print(response.content)
     TC.assertContains(self, response=response, text='Story-Three')
     response = self.client.post('/submissions/delete/3/', follow=True)
     TC.assertNotContains(self, response=response, text='Story-Three')
Esempio n. 6
0
 def test_create_unique_publisher(self):
     response = self.client.post(
         '/submissions/publisher/add/?wp_file=__all', {
             "publisher": "XXXXX",
             "web_address":
             "http://www.asimovs.com/contact-us/writers-guidelines/",
             "min_words": 1000,
             "max_words": 20000,
             "remarks": "Azimov's wants stories with some literary merit."
         },
         follow=True)
     #         print(response.content)
     TC.assertContains(self, response=response, text='XXXXX')
Esempio n. 7
0
 def test_search(self):
     response = self.client.post('/accounts/login/', {
         'username': '******',
         'password': '******'
     },
                                 follow=True)
     TC.assertContains(self, response=response, text='Story-One')
     response = self.client.post('/submissions/search/', {
         'publisher_id': 2,
         'disposition_id': 2
     },
                                 follow=True)
     TC.assertContains(self, response=response, text='Story-Two')
     TC.assertNotContains(self, response=response, text='Story-One')
Esempio n. 8
0
 def test_basic_download(self):
     client = APIClient()
     p = client.get('http://127.0.0.1/liquid-dl/youtubedl-get-formats', {
         u'url':
         u'https://www.youtube.com/playlist?list=PLBML8SXyfQ6f0HYiKTs3riLBTaQfO-sGz',
         u'output_path': u'C:/tmp/toot',
         u'make_folder': u'false',
         u'new_folder_name': u'toot',
         u'is_playlist': u'false'
     },
                    format='json')
     self.assertIsInstance(p, JsonResponse)
     TestCase.assertContains(
         self,
         response=p,
         text="{\"success\": \"Downloaded Files successfully\"}")
Esempio n. 9
0
 def test_convert_folder_success_with_clean_windows(self):
     """
     Check if folder was successfully converted on windows and cleans the folder of all old files with old file types
     """
     client = APIClient()
     p = client.get('http://127.0.0.1/ffmpeg', {
         u'operating_system': u'Windows',
         u'input_path': self.test_dir,
         u'input_format': u'jpg',
         u'output_format': u'png',
         u'delete_old_files': u'true',
         u'folder_conversion': u'true'
     },
                    format='json')
     self.assertIsInstance(p, JsonResponse)
     TestCase.assertContains(
         self,
         response=p,
         text="{\"success\": \"Conversion of Files was successful\"}")
Esempio n. 10
0
 def test_catch_unauth_add(self):
     self.client.post('/accounts/login/', {
         'username': '******',
         'password': '******'
     },
                      follow=True)
     response = self.client.get('/submissions/user/add/', follow=True)
     TC.assertContains(self, response=response, text='Add New User')
     self.client.logout()
     self.client.post('/accounts/login/', {
         'username': '******',
         'password': '******'
     },
                      follow=True)
     response = self.client.get('/submissions/user/add/', follow=True)
     TC.assertNotContains(self, response=response, text="Add New User")
     TC.assertContains(self,
                       response=response,
                       text='Only a superuser can add')
Esempio n. 11
0
 def test_convert_single_file_success_windows(self):
     """
     Check if file was successfully converted on windows 
     """
     client = APIClient()
     p = client.get('http://127.0.0.1/ffmpeg', {
         u'operating_system': u'Windows',
         u'input_path': self.test_dir + '\\bron.jpg',
         u'input_format': u'jpg',
         u'output_format': u'png',
         u'delete_old_files': False,
         u'folder_conversion': False
     },
                    format='json')
     print(os.getcwd())
     self.assertIsInstance(p, JsonResponse)
     TestCase.assertContains(
         self,
         response=p,
         text="{\"success\": \"Conversion of Files was successful\"}")
     print(p)
Esempio n. 12
0
 def test_catch_unauth_edit(self):
     self.client.post('/accounts/login/', {
         'username': '******',
         'password': '******'
     },
                      follow=True)
     response = self.client.get('/submissions/user/2', follow=True)
     TC.assertContains(self,
                       response=response,
                       text='Update User Information')
     self.client.logout()
     self.client.post('/accounts/login/', {
         'username': '******',
         'password': '******'
     },
                      follow=True)
     response = self.client.get('/submissions/user/1', follow=True)
     TC.assertNotContains(self,
                          response=response,
                          text="Update User Information")
     TC.assertContains(self,
                       response=response,
                       text='Only a superuser can update')
Esempio n. 13
0
 def test_create_submission(self):
     # Must be logged in. 'get' brings up entry page. 'post', submits data and brings up submissions page
     self.client.post('/accounts/login/', {
         'username': '******',
         'password': '******'
     },
                      follow=True)
     response = self.client.get('/submissions/add/', follow=True)
     TC.assertContains(self, response=response, text='Add New submission')
     response = self.client.post('/submissions/add/', {
         "pk": 4,
         "story": "Story-Four",
         "word_count": 4000,
         "file": "story-four.01.docx",
         "date_submitted": "1999-06-29",
         "disposition_date": "1999-06-29",
         "publisher": 3,
         "disposition": 3,
         "user": 2
     },
                                 follow=True)
     #         print(response.content)
     TC.assertContains(self, response=response, text='Story-Four')
     TC.assertNotContains(self, response=response, text='Story-One')
Esempio n. 14
0
def response_is_html(response, title=None):
    test = TestCase()
    test.assertTrue(response.content.startswith(b'<!DOCTYPE html>'))
    if title is not None:
        test.assertContains(response, '<title>%s</title>' % (title,))
    test.assertTrue(response.content.endswith(b'</html>'))
Esempio n. 15
0
def test_response_is_failed_login(test_case: TestCase, response: Response):
    test_case.assertContains(
        response=response,
        text="There was an error pre-authenticating the user",
        status_code=400)