Skip to content

Commit

Permalink
changed 'tmp' dir to '__tmp__'
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdallah-Ragab committed Sep 17, 2023
1 parent 914d0fc commit a732ad2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ __pycache__/
*$py.class

# Temp files
tmp/
__tmp__/
*.csv
tmp/*.bin
__tmp__/*.bin
# C extensions
*.so

Expand Down
2 changes: 1 addition & 1 deletion ip2location_toolkit/downloader/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_tmp_dir():
:return: The path to the temporary directory.
:rtype: str
"""
full_path = os.path.join(os.getcwd(), 'tmp')
full_path = os.path.join(os.getcwd(), '__tmp__')
return get_dir_or_create(full_path)

def get_downloaded_zip_path(db_code):
Expand Down
14 changes: 7 additions & 7 deletions tests/test_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
class TestGetDownloadedZipPath(SilentTestCase):
def test_get_downloaded_zip_path(self):
result = get_downloaded_zip_path('DB1LITEBIN')
self.assertEqual(result, os.path.join(get_tmp_dir(), 'DB1LITEBIN.zip'), msg="The function should return the path to the tmp directory + the file code + .zip.")
self.assertEqual(result, os.path.join(get_tmp_dir(), 'DB1LITEBIN.zip'), msg="The function should return the path to the __tmp__ directory + the file code + .zip.")

class TestGetDirOrCreate(SilentTestCase):
def test_existing_dir(self):
Expand All @@ -45,8 +45,8 @@ def test_new_dir(self):
class TestGetTMPDir(SilentTestCase):
def test_tmp_dir(self):
result = get_tmp_dir()
self.assertTrue(os.path.exists(result), msg="The tmp directory should exist.")
self.assertEqual(result, os.path.join(os.getcwd(), 'tmp'), msg="The function should return the path to the tmp directory. The path should be the same as the current working directory + tmp.")
self.assertTrue(os.path.exists(result), msg="The __tmp__ directory should exist.")
self.assertEqual(result, os.path.join(os.getcwd(), '__tmp__'), msg="The function should return the path to the __tmp__ directory. The path should be the same as the current working directory + __tmp__.")

class TestDownloadFile(SilentTestCase):
@patch('ip2location_toolkit.downloader.download.requests.get', return_value=mocked_404_response)
Expand Down Expand Up @@ -156,21 +156,21 @@ def test_failed_download_database(self, download_database_mock):

class TestRenameFile(TestCase):
def setUp(self) -> None:
Path('/tmp').mkdir(exist_ok=True)
Path('/__tmp__').mkdir(exist_ok=True)
return super().setUp()

def tearDown(self):
recursive_remove_dir('/tmp')
recursive_remove_dir('/__tmp__')
return super().tearDown()

def test_same_filename(self):
filepath = '/tmp/test_file.xyz'
filepath = '/__tmp__/test_file.xyz'
new_filename = 'test_file.xyz'
result = rename_file(filepath, new_filename)
self.assertEqual(result, Path(filepath), msg="The rename_file should return the same path to the file when the new filename is the same as the old one.")

def test_file_not_exist(self):
filepath = '/tmp/test_file_unique_4312349545.xyz'
filepath = '/__tmp__/test_file_unique_4312349545.xyz'
new_filename = 'new_test_file.xyz'
with self.assertRaises(ValueError, msg="Expected ValueError Exception to be raised when file does not exist"):
rename_file(filepath, new_filename)
Expand Down

0 comments on commit a732ad2

Please sign in to comment.