aboutsummaryrefslogtreecommitdiff
path: root/tests/test_assign_variable.py
blob: 8623fe781f36cdeae0ba48a6ab6153681ffd4ed6 (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import unittest
import dialoguer


class TestAssignVariable(unittest.TestCase):

	# @classmethod
	# def setUpClass(cls):
	# 	source_file_path = __file__.replace('.py', '.r')
	# 	cls.src_fil_r = dialoguer.Dialogue(source_file_path)

	# @classmethod
	# def tearDownClass(cls):
	# 	cls.src_fil_r.close()

	def setUp(self):
		source_file_path = __file__.replace('.py', '.r')
		self.src_fil_r = dialoguer.Dialogue(source_file_path)

	def tearDown(self):
		self.src_fil_r.close()

	def test_assign_string(self):
		str_1 = 'Test string 1'
		str_2 = 'Test string 2'
		self.src_fil_r.assign_variable('str_1', str_1)
		self.src_fil_r.assign_variable('str_2', str_2)
		str_ret_1 = self.src_fil_r.import_variable('str_1')
		str_ret_2 = self.src_fil_r.import_variable('str_2')
		self.assertEqual(str_ret_1, str_1)
		self.assertEqual(str_ret_2, str_2)

	def test_assign_integer(self):
		int_1 = 20
		int_2 = 200
		self.src_fil_r.assign_variable('int_1', int_1)
		self.src_fil_r.assign_variable('int_2', int_2)
		int_ret_1 = self.src_fil_r.import_variable('int_1')
		int_ret_2 = self.src_fil_r.import_variable('int_2')
		self.assertEqual(int_ret_1, int_1)
		self.assertEqual(int_ret_2, int_2)

	def test_assign_boolean(self):
		chk_1 = True
		chk_2 = False
		self.src_fil_r.assign_variable('chk_1', chk_1)
		self.src_fil_r.assign_variable('chk_2', chk_2)
		chk_ret_1 = self.src_fil_r.import_variable('chk_1')
		chk_ret_2 = self.src_fil_r.import_variable('chk_2')
		self.assertEqual(chk_ret_1, chk_1)
		self.assertEqual(chk_ret_2, chk_2)

	def test_assign_double(self):
		dbl_1 = 20.5
		dbl_2 = 200.98
		self.src_fil_r.assign_variable('dbl_1', dbl_1)
		self.src_fil_r.assign_variable('dbl_2', dbl_2)
		dbl_ret_1 = self.src_fil_r.import_variable('dbl_1')
		dbl_ret_2 = self.src_fil_r.import_variable('dbl_2')
		self.assertEqual(dbl_ret_1, dbl_1)
		self.assertEqual(dbl_ret_2, dbl_2)



if __name__ == '__main__':
	unittest.main()