2
2
3
3
import os
4
4
5
+ import pytest
6
+
5
7
from encryptdef .utils import get_new_file_path
6
8
7
9
8
10
def test_get_new_file_path_positive ():
9
11
"""Test function get_new_file_path"""
12
+ current_dir = os .getcwd ()
10
13
file = "file_test.txt"
11
14
new_file = "encrypt_file_test.txt"
12
- current_dir = os .getcwd ()
15
+ expected_path = os .path .join (current_dir , new_file )
16
+
13
17
file_path = get_new_file_path (file , new_file , current_dir )
18
+ assert file_path == expected_path
19
+
20
+
21
+ def test_get_new_file_path_is_directory_error ():
22
+ """Test function get_new_file_path"""
23
+ current_dir = os .getcwd ()
24
+ directoty = "new_directory"
25
+ directoty_path = os .path .join (current_dir , directoty )
26
+ os .mkdir (directoty_path )
27
+
28
+ with pytest .raises (IsADirectoryError ):
29
+ get_new_file_path (directoty_path , "new_test.txt" , current_dir )
14
30
15
- assert file_path == os .path .join (os .getcwd (), new_file )
31
+ with pytest .raises (IsADirectoryError ):
32
+ get_new_file_path ("test.txt" , directoty_path , current_dir )
16
33
17
34
18
35
def test_get_new_file_path_positive_exact_file_path ():
@@ -22,6 +39,6 @@ def test_get_new_file_path_positive_exact_file_path():
22
39
23
40
current_dir = os .getcwd ()
24
41
new_file_path = os .path .join (current_dir , new_file )
25
- file_path_get = get_new_file_path (file , new_file_path , current_dir )
26
42
27
- assert file_path_get == new_file_path
43
+ new_file_path_get = get_new_file_path (file , new_file_path , current_dir )
44
+ assert new_file_path_get == new_file_path
0 commit comments