forked from nficano/python-lambda
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_readHelper.py
More file actions
36 lines (25 loc) · 1.07 KB
/
test_readHelper.py
File metadata and controls
36 lines (25 loc) · 1.07 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
import os
import unittest
import yaml
from aws_lambda.helpers import read
class TestReadHelper(unittest.TestCase):
TEST_FILE = "readTmp.txt"
def setUp(self):
with open(TestReadHelper.TEST_FILE, "w") as tmp_file:
tmp_file.write("testYaml: testing")
def tearDown(self):
os.remove(TestReadHelper.TEST_FILE)
def test_read_no_loader_non_binary(self):
fileContents = read(TestReadHelper.TEST_FILE)
self.assertEqual(fileContents, "testYaml: testing")
def test_read_yaml_loader_non_binary(self):
testYaml = read(TestReadHelper.TEST_FILE, loader=yaml.full_load)
self.assertEqual(testYaml["testYaml"], "testing")
def test_read_no_loader_binary_mode(self):
fileContents = read(TestReadHelper.TEST_FILE, binary_file=True)
self.assertEqual(fileContents, b"testYaml: testing")
def test_read_yaml_loader_binary_mode(self):
testYaml = read(
TestReadHelper.TEST_FILE, loader=yaml.full_load, binary_file=True
)
self.assertEqual(testYaml["testYaml"], "testing")