Commits

Frederic De Groef committed 658d7f9

better feedback in unit test generator

  • Participants
  • Parent commits 5e0541b

Comments (0)

Files changed (2)

File csxj/datasources/helpers/unittest_generator.py

             index['test_data'].append((source_url, test_name + ".html"))
             with open(full_index_name, 'w') as f:
                 json.dump(index, f, indent=2)
+    else:
+        print("Provided root path '{0}' does not exist".format(root_path))
 
 
 def generate_unittest(test_name, parser_name, urls_by_group, html_data, source_url, test_data_root_path, save_file=False):

File csxj/datasources/parser_tools/media_utils.py

         return v
     else:
         raise ValueError("A DewPlayer object was instantiated with an unhandled query. Fix your parser")
+
+
+def extract_source_url_from_bs3_youtube_object(bs3_youtube_object):
+    """ Extracts the source url from an embedded youtube object (parsed By BeautifulSoup3)"""
+    if bs3_youtube_object.a:
+        return bs3_youtube_object.a.get('href')
+    elif bs3_youtube_object.get('data'):
+        data = bs3_youtube_object.get('data')
+        if data.startswith('http'):
+            return data
+        else:
+            raise ValueError("The data attribute of that youtube object does not look like a url. Update the parser.")
+    else:
+        raise ValueError("Could not find a source url for this youtube object" )