def test_set(self): data = {'s': 'value', 'b': True, 'i': 42} self.node_info.set_option('name', data) self.assertEqual(data, self.node_info.options['name']) new = node_cache.NodeInfo(uuid=self.uuid, started_at=3.14) self.assertEqual(data, new.options['name'])
def test_get_introspection_in_progress(self, get_mock): get_mock.return_value = node_cache.NodeInfo(uuid='uuid', started_at=42.0) res = self.app.get('/v1/introspection/uuid') self.assertEqual(200, res.status_code) self.assertEqual({'finished': False, 'error': None}, json.loads(res.data.decode('utf-8')))
def setUp(self): super(TestNodeInfoOptions, self).setUp() node_cache.add_node(self.uuid, bmc_address='1.2.3.4', mac=self.macs) self.node_info = node_cache.NodeInfo(uuid=self.uuid, started_at=3.14) with self.db: self.db.execute( 'insert into options(uuid, name, value) ' 'values(?, ?, ?)', (self.uuid, 'foo', '"bar"'))
def test_get_introspection_finished(self, get_mock): get_mock.return_value = node_cache.NodeInfo(uuid='uuid', started_at=42.0, finished_at=100.1, error='boom') res = self.app.get('/v1/introspection/uuid') self.assertEqual(200, res.status_code) self.assertEqual({'finished': True, 'error': 'boom'}, json.loads(res.data.decode('utf-8')))