Skip to content

Commit

Permalink
Add TestMoveDirectoryWithFileInIt, cleanup imports.
Browse files Browse the repository at this point in the history
Signed-off-by: David <toonarmycaptain@hotmail.com>
  • Loading branch information
toonarmycaptain committed Dec 21, 2018
1 parent c7a93e9 commit 6f61509
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions test_suite/test_file_functions.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os, shutil
import os
import shutil

from unittest import TestCase

Expand Down Expand Up @@ -60,4 +61,40 @@ def test_move_file(self):
def tearDown(self):
shutil.rmtree(self.new_folder_name)

# TODO: test moving a directory with files in it.

class TestMoveDirectoryWithFileInIt(TestCase):
def setUp(self):
# Origin file, folder.
self.original_filename = 'just_a_naughty_boy.png'
self.original_folder_name = 'not_the_messiah'

self.original_file_path = os.path.join(self.original_folder_name, self.original_filename)

# Destination folder, filepath.
self.destination_folder_name = 'a_boy_named_brian'
self.destination_path = os.path.join(self.destination_folder_name, self.original_file_path)

# Make origin folder, file, destination folder.
os.mkdir(self.original_folder_name)
with open(self.original_file_path, 'w+') as test_file:
pass
os.mkdir(self.destination_folder_name)

# test setUp
# confirm original files and folders exist
assert os.path.exists(self.original_folder_name)
assert os.path.exists(self.original_file_path)
assert os.path.exists(self.destination_folder_name)

# Confirm target not in destination folder:
# Folder in new location.
assert not os.path.exists(os.path.join(self.destination_folder_name, self.original_folder_name))
assert not os.path.exists(self.destination_path) # File in destination_folder/original_folder/file.

def test_move_file(self):
move_file(self.original_folder_name, self.destination_folder_name)
assert os.path.exists(self.destination_path)
assert not os.path.exists(self.original_file_path)

def tearDown(self):
shutil.rmtree(self.destination_folder_name)

1 comment on commit 6f61509

@toonarmycaptain
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#88

Please sign in to comment.