Conventions

parent 53d51edc
...@@ -22,7 +22,7 @@ class BasicMixin: ...@@ -22,7 +22,7 @@ class BasicMixin:
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
self.setSlapgrid() self.setSlapgrid()
def setSlapgrid(self,develop=False): def setSlapgrid(self, develop=False):
self.software_root = os.path.join(self._tempdir, 'software') self.software_root = os.path.join(self._tempdir, 'software')
self.instance_root = os.path.join(self._tempdir, 'instance') self.instance_root = os.path.join(self._tempdir, 'instance')
if getattr(self, 'master_url', None) is None: if getattr(self, 'master_url', None) is None:
...@@ -36,7 +36,7 @@ class BasicMixin: ...@@ -36,7 +36,7 @@ class BasicMixin:
self.grid = slapgrid.Slapgrid(self.software_root, self.instance_root, self.grid = slapgrid.Slapgrid(self.software_root, self.instance_root,
self.master_url, self.computer_id, self.supervisord_socket, self.master_url, self.computer_id, self.supervisord_socket,
self.supervisord_configuration_path, self.usage_report_periodicity, self.supervisord_configuration_path, self.usage_report_periodicity,
self.buildout,develop=develop) self.buildout, develop=develop)
def tearDown(self): def tearDown(self):
...@@ -132,7 +132,7 @@ touch worked""") ...@@ -132,7 +132,7 @@ touch worked""")
BasicMixin.tearDown(self) BasicMixin.tearDown(self)
def _server_response (self_test,_requested_state,timestamp=None): def _server_response (self_test, _requested_state, timestamp=None):
def server_response(self_httplib, path, method, body, header): def server_response(self_httplib, path, method, body, header):
parsed_url = urlparse.urlparse(path.lstrip('/')) parsed_url = urlparse.urlparse(path.lstrip('/'))
self_test.sequence.append(parsed_url.path) self_test.sequence.append(parsed_url.path)
...@@ -427,8 +427,8 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase): ...@@ -427,8 +427,8 @@ class TestSlapgridCPPartitionProcessing (MasterMixin, unittest.TestCase):
self.sequence = [] self.sequence = []
self.timestamp = str(int(time.time())) self.timestamp = str(int(time.time()))
self.started = False self.started = False
httplib.HTTPConnection._callback = _server_response(self,'stopped', httplib.HTTPConnection._callback = _server_response(
self.timestamp) self, 'stopped', self.timestamp)
os.mkdir(self.software_root) os.mkdir(self.software_root)
os.mkdir(self.instance_root) os.mkdir(self.instance_root)
...@@ -448,18 +448,20 @@ touch worked""") ...@@ -448,18 +448,20 @@ touch worked""")
self.assertSortedListEqual(os.listdir(self.instance_root), ['0', 'etc', self.assertSortedListEqual(os.listdir(self.instance_root), ['0', 'etc',
'var']) 'var'])
partition = os.path.join(self.instance_root, '0') partition = os.path.join(self.instance_root, '0')
self.assertSortedListEqual(os.listdir(partition), ['.timestamp','worked', self.assertSortedListEqual(
'buildout.cfg']) os.listdir(partition), ['.timestamp', 'worked', 'buildout.cfg'])
self.assertSortedListEqual(os.listdir(self.software_root), self.assertSortedListEqual(
[software_hash]) os.listdir(self.software_root), [software_hash])
timestamp_path = os.path.join(partition_path, '.timestamp') timestamp_path = os.path.join(partition_path, '.timestamp')
self.setSlapgrid() self.setSlapgrid()
self.assertTrue(self.grid.processComputerPartitionList()) self.assertTrue(self.grid.processComputerPartitionList())
self.assertTrue(self.timestamp in open(timestamp_path,'r').read()) self.assertTrue(self.timestamp in open(timestamp_path,'r').read())
self.assertEqual(self.sequence, self.assertEqual(self.sequence,
['getFullComputerInformation', 'availableComputerPartition', ['getFullComputerInformation',
'stoppedComputerPartition', 'getFullComputerInformation']) 'availableComputerPartition',
'stoppedComputerPartition',
'getFullComputerInformation'])
def test_partition_timestamp_develop(self): def test_partition_timestamp_develop(self):
...@@ -467,8 +469,8 @@ touch worked""") ...@@ -467,8 +469,8 @@ touch worked""")
self.sequence = [] self.sequence = []
self.timestamp = str(int(time.time())) self.timestamp = str(int(time.time()))
self.started = False self.started = False
httplib.HTTPConnection._callback = _server_response(self,'stopped', httplib.HTTPConnection._callback = _server_response(
self.timestamp) self, 'stopped', self.timestamp)
os.mkdir(self.software_root) os.mkdir(self.software_root)
os.mkdir(self.instance_root) os.mkdir(self.instance_root)
partition_path = os.path.join(self.instance_root, '0') partition_path = os.path.join(self.instance_root, '0')
...@@ -487,10 +489,10 @@ touch worked""") ...@@ -487,10 +489,10 @@ touch worked""")
self.assertSortedListEqual(os.listdir(self.instance_root), ['0', 'etc', self.assertSortedListEqual(os.listdir(self.instance_root), ['0', 'etc',
'var']) 'var'])
partition = os.path.join(self.instance_root, '0') partition = os.path.join(self.instance_root, '0')
self.assertSortedListEqual(os.listdir(partition), ['.timestamp','worked', self.assertSortedListEqual(
'buildout.cfg']) os.listdir(partition), ['.timestamp','worked', 'buildout.cfg'])
self.assertSortedListEqual(os.listdir(self.software_root), self.assertSortedListEqual(
[software_hash]) os.listdir(self.software_root), [software_hash])
self.setSlapgrid(develop=True) self.setSlapgrid(develop=True)
self.assertTrue(self.grid.processComputerPartitionList()) self.assertTrue(self.grid.processComputerPartitionList())
...@@ -509,8 +511,8 @@ touch worked""") ...@@ -509,8 +511,8 @@ touch worked""")
self.sequence = [] self.sequence = []
self.timestamp = str(int(time.time())) self.timestamp = str(int(time.time()))
self.started = False self.started = False
httplib.HTTPConnection._callback = _server_response(self,'stopped', httplib.HTTPConnection._callback = _server_response(
self.timestamp) self,'stopped', self.timestamp)
os.mkdir(self.software_root) os.mkdir(self.software_root)
os.mkdir(self.instance_root) os.mkdir(self.instance_root)
...@@ -530,15 +532,14 @@ touch worked""") ...@@ -530,15 +532,14 @@ touch worked""")
self.assertSortedListEqual(os.listdir(self.instance_root), ['0', 'etc', self.assertSortedListEqual(os.listdir(self.instance_root), ['0', 'etc',
'var']) 'var'])
partition = os.path.join(self.instance_root, '0') partition = os.path.join(self.instance_root, '0')
self.assertSortedListEqual(os.listdir(partition), ['.timestamp','worked', self.assertSortedListEqual(os.listdir(partition),
'buildout.cfg']) ['.timestamp','worked', 'buildout.cfg'])
self.assertSortedListEqual(os.listdir(self.software_root), self.assertSortedListEqual(os.listdir(self.software_root),
[software_hash]) [software_hash])
self.setSlapgrid() self.setSlapgrid()
httplib.HTTPConnection._callback = _server_response(self, httplib.HTTPConnection._callback = _server_response(
'stopped', self, 'stopped', str(int(self.timestamp)-1))
str(int(self.timestamp)-1))
self.assertTrue(self.grid.processComputerPartitionList()) self.assertTrue(self.grid.processComputerPartitionList())
self.assertEqual(self.sequence, self.assertEqual(self.sequence,
['getFullComputerInformation', 'availableComputerPartition', ['getFullComputerInformation', 'availableComputerPartition',
...@@ -572,8 +573,8 @@ touch worked""") ...@@ -572,8 +573,8 @@ touch worked""")
self.assertSortedListEqual(os.listdir(self.instance_root), ['0', 'etc', self.assertSortedListEqual(os.listdir(self.instance_root), ['0', 'etc',
'var']) 'var'])
partition = os.path.join(self.instance_root, '0') partition = os.path.join(self.instance_root, '0')
self.assertSortedListEqual(os.listdir(partition), ['.timestamp','worked', self.assertSortedListEqual(os.listdir(partition),
'buildout.cfg']) ['.timestamp','worked', 'buildout.cfg'])
self.assertSortedListEqual(os.listdir(self.software_root), self.assertSortedListEqual(os.listdir(self.software_root),
[software_hash]) [software_hash])
httplib.HTTPConnection._callback = _server_response(self, httplib.HTTPConnection._callback = _server_response(self,
...@@ -615,8 +616,8 @@ touch worked""") ...@@ -615,8 +616,8 @@ touch worked""")
self.assertSortedListEqual(os.listdir(self.instance_root), ['0', 'etc', self.assertSortedListEqual(os.listdir(self.instance_root), ['0', 'etc',
'var']) 'var'])
partition = os.path.join(self.instance_root, '0') partition = os.path.join(self.instance_root, '0')
self.assertSortedListEqual(os.listdir(partition), ['.timestamp','worked', self.assertSortedListEqual(os.listdir(partition),
'buildout.cfg']) ['.timestamp','worked', 'buildout.cfg'])
self.assertSortedListEqual(os.listdir(self.software_root), self.assertSortedListEqual(os.listdir(self.software_root),
[software_hash]) [software_hash])
httplib.HTTPConnection._callback = _server_response(self, httplib.HTTPConnection._callback = _server_response(self,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment