Ok. I have a class which runs this command:
ffmpeg_command = "ffprobe -v quiet -print_format json -show_format -show_streams %s" % self.absolute_path
Where self.absolute_path is a path to a movie, let's say .mpg file.
The file I am using for testing is 4GB large and I don't want to commit it inside my GIT repo.
So I was thinking of mocking this file and creating a file called:
mock.mpg
Which would return the same string as the actual mpg movie when supplied as input to ffprobe command. Is that possible?
Or what other approach should I choose?
This is my class:
class Movie(object):
absolute_path = None
info = None
def __init__(self, path):
self.absolute_path = "%s/%s" % (os.getcwd(), path)
if(os.path.exists(self.absolute_path) is False):
raise IOError("File does not exist")
self.info = json.loads(self.get_info())
def get_info(self):
ffmpeg_command = "ffprobe -v quiet -print_format json -show_format -show_streams %s" % self.absolute_path
return subprocess.check_output(ffmpeg_command, shell=True)
This is how I will be unit testing it:
class MovieTest(unittest.TestCase):
def test_foo(self):
movie = Movie("tests/test_1.mpg") # this file should be a mock file!!!