Example #1
0
 def test_get_machine_count(self):
     user = factory.make_User()
     handler = ResourcePoolHandler(user, {}, None)
     pool = factory.make_ResourcePool()
     factory.make_Machine(pool=pool)
     result = handler.get({"id": pool.id})
     self.assertEqual(1, result['machine_total_count'])
Example #2
0
 def test_get_machine_ready_count(self):
     user = factory.make_User()
     handler = ResourcePoolHandler(user, {}, None)
     pool = factory.make_ResourcePool()
     factory.make_Machine(pool=pool, status=NODE_STATUS.NEW)
     factory.make_Machine(pool=pool, status=NODE_STATUS.READY)
     result = handler.get({"id": pool.id})
     self.assertEqual(2, result['machine_total_count'])
     self.assertEqual(1, result['machine_ready_count'])
Example #3
0
 def test_get(self):
     user = factory.make_User()
     handler = ResourcePoolHandler(user, {}, None)
     pool = factory.make_ResourcePool()
     result = handler.get({"id": pool.id})
     self.assertEqual(
         {'id': pool.id,
          'name': pool.name,
          'description': pool.description,
          'is_default': False,
          'created': dehydrate_datetime(pool.created),
          'updated': dehydrate_datetime(pool.updated),
          'machine_total_count': 0,
          'machine_ready_count': 0,
          'permissions': []},
         result)
Example #4
0
 def test_get(self):
     user = factory.make_User()
     handler = ResourcePoolHandler(user, {}, None)
     pool = factory.make_ResourcePool()
     result = handler.get({"id": pool.id})
     self.assertEqual(
         {
             "id": pool.id,
             "name": pool.name,
             "description": pool.description,
             "is_default": False,
             "created": dehydrate_datetime(pool.created),
             "updated": dehydrate_datetime(pool.updated),
             "machine_total_count": 0,
             "machine_ready_count": 0,
             "permissions": [],
         },
         result,
     )
Example #5
0
 def test_get_is_default(self):
     pool = ResourcePool.objects.get_default_resource_pool()
     handler = ResourcePoolHandler(factory.make_User(), {}, None)
     result = handler.get({"id": pool.id})
     self.assertTrue(result['is_default'])