예제 #1
0
    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')
예제 #2
0
    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')
예제 #3
0
    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)
예제 #4
0
    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)
예제 #5
0
    def test_check_activity_no_container(self):
        result = check_container_activity('bad_container_id')

        self.assertIsNone(result)