forked from InstaPy/InstaPy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_file_handling.py
25 lines (18 loc) · 1004 Bytes
/
test_file_handling.py
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
import unittest
from instapy import util
class TestFileHandling(unittest.TestCase):
"""Unit tests for file_handling function"""
# list of expected entries
expected_entries = ["This is a comment...", "photography", "portrait"]
def test_valid_entries(self):
"""Check file_handling with valid entries"""
actual_entries = util.file_handling("tests/resources/valid_target_list.txt")
self.assertListEqual(actual_entries, TestFileHandling.expected_entries)
def test_invalid_entries(self):
"""Check file_handling with invalid entries"""
actual_entries = util.file_handling("tests/resources/invalid_target_list.txt")
self.assertListEqual(actual_entries, TestFileHandling.expected_entries)
def test_invalid_filepath(self):
"""Check whether it raises an exception when the filepath is invalid"""
actual_entries = util.file_handling("invalid_filepath")
self.assertListEqual(actual_entries, ["FileNotFoundError"])