<commit_before>import unittest
import download_repo_run_scan
from os import path, remove
import shutil

#This tests a method that runs through the whole scanning process.
#Since it calls a few other methods, it will fail also if those methods fail.
class wholeScanTestCase(unittest.TestCase):
	url = 'https://github.com/OSSHealth/ghdata/archive/master.zip'
	spdx_file_name = ''
	def setUp(self):
		self.spdx_file_name = download_repo_run_scan.download_repo_run_scan(self.url)
	def tearDown(self):
		remove(self.spdx_file_name)
	def testWholeScan(self):
		assert path.isfile(self.spdx_file_name)

#Test that when given a valid zip file url,
#the download_github_zip will result in the creation
#of a local file at the returned location
class downloadFileTestCase(unittest.TestCase):
	file_location = ''
	url = 'https://github.com/OSSHealth/ghdata/archive/master.zip'
	def setUp(self):
		self.file_location = download_repo_run_scan.download_github_zip(self.url)

	def tearDown(self):
		remove(self.file_location)

	def testDownload(self):
		assert path.isfile(self.file_location)

#Test that we can unzip a zip file.  This requires a zip file to be present.
#For this I am using the same download method as above to get a zip file
#from GitHub, so both tests will fail if the download method fails
class unzipFileTestCase(unittest.TestCase):
	file_location = ''
	url = 'https://github.com/OSSHealth/ghdata/archive/master.zip'
	extracted_directory = ''
	def setUp(self):
		self.file_location = download_repo_run_scan.download_github_zip(self.url)
		self.extracted_directory = download_repo_run_scan.unzip_file(self.file_location)
	
	def tearDown(self):
		#Remove the zip file
		remove(self.file_location)
		#Remove the unzipped directory
		shutil.rmtree(self.extracted_directory)
	
	def testUnzip(self):
		assert 	path.isdir(self.extracted_directory)

#This tests whether a file output is produced from calling the scan method.
#It needs the download zip and extract zip methods to be working.
class scanTestCase(unittest.TestCase):
	file_location = ''
	url = 'https://github.com/OSSHealth/ghdata/archive/master.zip'
	extracted_directory = ''
	spdx_file_name = ''
	def setUp(self):
		self.file_location = download_repo_run_scan.download_github_zip(self.url)
		self.extracted_directory = download_repo_run_scan.unzip_file(self.file_location)
		#Set output file name to the directory name .SPDX
		self.spdx_file_name = self.extracted_directory[:-1] + '.SPDX'

		#scan the extracted directory and put results in a named file
		download_repo_run_scan.scan(self.extracted_directory, self.spdx_file_name)
	
	def tearDown(self):
		#Remove the zip file
		remove(self.file_location)
		#Remove the unzipped directory
		shutil.rmtree(self.extracted_directory)	
		#Remove the scan results file
		remove(self.spdx_file_name)

	def testScan(self):
		assert path.isfile(self.spdx_file_name)<commit_msg>Use local directories for tests<commit_after>import unittest
import download_repo_run_scan
from os import path, remove
import shutil	

#This tests a method that runs through the whole scanning process.
#Since it calls a few other methods, it will fail also if those methods fail.
class wholeScanTestCase(unittest.TestCase):
	url = 'https://github.com/abuhman/test_webhooks/archive/master.zip'
	spdx_file_name = ''
	def setUp(self):
		self.spdx_file_name = download_repo_run_scan.download_repo_run_scan(self.url)
	def tearDown(self):
		remove(self.spdx_file_name)
	def testWholeScan(self):
		assert path.isfile(self.spdx_file_name)

#Test that when given a valid zip file url,
#the download_github_zip will result in the creation
#of a local file at the returned location
class downloadFileTestCase(unittest.TestCase):
	file_location = ''
	url = 'https://github.com/abuhman/test_webhooks/archive/master.zip'
	def setUp(self):
		self.file_location = download_repo_run_scan.download_github_zip(self.url)

	def tearDown(self):
		remove(self.file_location)

	def testDownload(self):
		assert path.isfile(self.file_location)

#Test that we can unzip a zip file.  This requires a zip file to be present.
#For this I am using the same download method as above to get a zip file
#from GitHub, so both tests will fail if the download method fails
class unzipFileTestCase(unittest.TestCase):
	file_location = 'test.zip'
	extracted_directory = ''
	def setUp(self):
		self.extracted_directory = download_repo_run_scan.unzip_file(self.file_location)
	
	def tearDown(self):
		#Remove the unzipped directory
		shutil.rmtree(self.extracted_directory)
	
	def testUnzip(self):
		assert 	path.isdir(self.extracted_directory)

#This tests whether a file output is produced from calling the scan method.
#It needs the download zip and extract zip methods to be working.
class scanTestCase(unittest.TestCase):
	directory = 'test2/'
	spdx_file_name = ''
	def setUp(self):
		#Set output file name to the directory name .SPDX
		self.spdx_file_name = self.directory[:-1] + '.SPDX'

		#scan the extracted directory and put results in a named file
		download_repo_run_scan.scan(self.directory, self.spdx_file_name, 'scancode', 'tag-value')
	def tearDown(self):
		#Remove the scan results file
		remove(self.spdx_file_name)

	def testScan(self):
		assert path.isfile(self.spdx_file_name)
{'fraction_non_alphanumeric': 0.08376264071742034, 'fraction_numerical': 0.0005724098454493417, 'mean_word_length': 5.3232810615199035, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 31, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3268070', 'n_tokens_mistral': 1742, 'n_tokens_neox': 1666, 'n_words': 481}