-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting_document.py
More file actions
46 lines (38 loc) · 1.65 KB
/
Copy pathtesting_document.py
File metadata and controls
46 lines (38 loc) · 1.65 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
44
45
46
import unittest
from class_document import Document
class TestDocument(unittest.TestCase):
def test_document_initialization(self):
doc = Document("PDF", "Sample data")
self.assertEqual(doc.type, "PDF")
self.assertEqual(doc.data, "Sample data")
self.assertTrue(isinstance(doc.date, str))
def test_edit_document(self):
doc = Document("Word", "Initial content")
old_date = doc.date
doc.edit("Updated content")
self.assertEqual(doc.data, "Updated content")
self.assertNotEqual(doc.date, old_date)
def test_create_document_valid(self):
doc = Document.create_document("Text", "New document")
self.assertEqual(doc.type, "Text")
self.assertEqual(doc.data, "New document")
def test_create_document_invalid_type_empty(self):
with self.assertRaises(ValueError):
Document.create_document("", "Content")
def test_create_document_invalid_type_nonstring(self):
with self.assertRaises(ValueError):
Document.create_document(123, "Content")
def test_send_document_valid(self):
doc = Document("PDF", "Sendable doc")
try:
doc.send_document("Recipient Name")
except Exception as e:
self.fail(f"send_document raised an exception unexpectedly: {e}")
def test_send_document_invalid_empty(self):
doc = Document("PDF", "Sendable doc")
with self.assertRaises(ValueError):
doc.send_document("")
def test_send_document_invalid_type(self):
doc = Document("PDF", "Sendable doc")
with self.assertRaises(ValueError):
doc.send_document(123)