-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_git.py
More file actions
43 lines (31 loc) · 1.36 KB
/
test_git.py
File metadata and controls
43 lines (31 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import unittest
import os
from git import do_command
def test_do_command_commit_invalid_file_path():
filePaths = ["invalid_path1.txt", "invalid_path2.txt"]
message = "test commit message"
try:
do_command("commit", [], filePaths, [], [], message)
except ValueError as e:
assert str(e) == f"{filePaths[0]} is not a valid file path"
assert os.path.exists(filePaths[0]) == False
assert os.path.exists(filePaths[1]) == False
def test_do_command_commit_no_message():
filePaths = ["test-files/test_file1.txt", "test-files/test_file2.txt"]
message = ""
result = do_command("commit", [], filePaths, [], [], message)
assert result == "Please enter a commit message"
def test_do_command_diff_invalid_file_path():
versions = ["invalid_path1.txt", "invalid_path2.txt"]
result = do_command("diff", [], [], [], versions, "")
assert result == "file is not a valid file path"
def test_do_command_diff_files_identical():
versions = ["test_file1.txt", "test_file1_copy.txt"]
result = do_command("diff", [], [], [], versions, "")
assert result == "Files are identical"
def test_do_command_diff_files_different():
versions = ["test_file1.txt", "test_file2.txt"]
result = do_command("diff", [], [], [], versions, "")
assert result == "Files are different"
if __name__ == "__main__":
unittest.main()