def test_check_activity_no_connections_final(self): container = self._create_container() container_id = container['container_id'] result = check_container_activity(container_id, final=True) self.assertEqual(result, 'stopping container')
def test_check_activity_no_connections(self): container = self._create_container() container_id = container['container_id'] result = check_container_activity(container_id) self.assertEqual(result, 'container inactive')
def test_check_activity_not_running(self): container = self._create_container() container_id = container['container_id'] resp = self.app.patch('/v1/containers/%s' % container_id, headers=self.auth, data=dict(status='stopped')) result = check_container_activity(container_id) self.assertIsNone(result)
def test_check_activity_active_connections(self): container = self._create_container() container_id = container['container_id'] r.hset('containers:%s' % container_id, 'active', '1') # Mock apply_async so we don't get stuck in infinite loop check_container_activity.apply_async = Mock() result = check_container_activity(container_id) self.assertEqual(result, 'container active') self.assertTrue(check_container_activity.apply_async.called)
def test_check_activity_no_container(self): result = check_container_activity('bad_container_id') self.assertIsNone(result)