This repository has been archived by the owner on Oct 27, 2021. It is now read-only.
/
test_cluster.py
69 lines (56 loc) · 1.82 KB
/
test_cluster.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
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
67
68
69
##
# vcluster unit tests
# @author David Awad
#
import unittest2 as unittest
import virtual_machine
import vcluster
import yaml
import json
import sys
import os
class vclusterTests(unittest.TestCase):
def setUp(self):
self.config = vcluster.open_config('settings.yaml')
def test_yaml_config(self):
config = vcluster.open_config('settings.yaml')
self.assertEquals(config['command'], 'python unittest.py')
self.assertTrue(config['command'])
def test_json_config(self):
# FIXME JSON support is actually totally untested.
config = vcluster.open_config('sample.json')
# self.assertEquals(config['command'], 'python unittest.py')
# self.assertTrue(config['command'])
def test_config_ftype(self):
with open('settings.csv', 'w') as f:
f.write("hello there, I'm not a config file")
config = vcluster.open_config('settings.csv')
os.remove('settings.csv')
self.assertFalse(config)
def test_check_vagrantfiles(self):
"""
make a temp_cluster folder, scrape it for clarity
"""
vm_list = vcluster.generate_machines(self.config)
for item in vm_list:
self.assertIsInstance(item, virtual_machine.vm)
def test_render_clusters(self):
"""
create vagrant files for a vcluster,
make sure templates render correctly
"""
return # TODO double check this!
def test_clear_vm(self):
"""
make a temp_cluster folder, remove it
"""
vm_list = vcluster.generate_machines(self.config)
self.assertTrue(vcluster.clear_vms())
def tearDown(self):
vcluster.clear_vms()
try:
os.remove('settings.csv')
except OSError:
pass
if __name__ == '__main__':
unittest.main()