from domin8.tools.request_change import classify_action_from_diff
def test_classify_create():
diff = """
diff --git a/newfile b/newfile
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/newfile
@@ -0,0 +1 @@
+hello
"""
assert classify_action_from_diff(diff, 'newfile') == 'create'
def test_classify_delete():
diff = """
diff --git a/oldfile b/oldfile
deleted file mode 100644
index e69de29..0000000
--- a/oldfile
+++ /dev/null
@@ -1 +0,0 @@
-gone
"""
assert classify_action_from_diff(diff, 'oldfile') == 'delete'
def test_classify_rename_explicit():
diff = """
diff --git a/foo.txt b/bar.txt
similarity index 100%
rename from foo.txt
rename to bar.txt
"""
assert classify_action_from_diff(diff, 'bar.txt') == 'rename'
def test_classify_rename_via_headers():
diff = """
--- a/old/path.txt
+++ b/new/path.txt
@@ -1 +1 @@
-old
+new
"""
assert classify_action_from_diff(diff, 'new/path.txt') == 'rename'