Пример #1
0
 def test_no_process_is_running(self):
     d = mkdtemp()
     f = _get_pid_filename(d)
     try:
         with open(f, 'w') as pid_file:
             pid_file.write('99999999999 1.1')
         self.assertFalse(_is_running(d))
     finally:
         rmtree(d)
Пример #2
0
 def test_valid_is_running(self):
     p = Process()
     d = mkdtemp()
     f = _get_pid_filename(d)
     try:
         with open(f, 'w') as pid_file:
             pid_file.write('{0} {1:6f}'.format(p.pid, p.create_time()))
         self.assertTrue(_is_running(d))
     finally:
         rmtree(d)
Пример #3
0
 def test_cleanup_invalid_pid_file(self):
     d = mkdtemp()
     f = _get_pid_filename(d)
     try:
         with open(f, 'w') as pid_file:
             pid_file.write("#@$!")
         self.assertFalse(_is_running(d))
         self.assertFalse(isfile(f))
         self.assertTrue(isdir(d))
     finally:
         rmtree(d)
Пример #4
0
 def test_create_time_mismatch_is_running(self):
     p = Process()
     d = mkdtemp()
     f = _get_pid_filename(d)
     try:
         with open(f, 'w') as pid_file:
             pid_file.write('{0} 1.1'.format(p.pid))
         self.assertFalse(_is_running(d))
         self.assertFalse(isfile(f))
         self.assertTrue(isdir(d))
     finally:
         if isdir(d):
             rmtree(d)
Пример #5
0
 def test_get_pid_filename(self):
     self.assertEquals('/test/INFO', _get_pid_filename('/test'))