예제 #1
0
 def test_netdevice_get_all(self):
     dbapi.netdevices_create(self.context, device1)
     filters = {}
     res = dbapi.netdevices_get_by_region(self.context,
                                          device1['region_id'], filters)
     self.assertEqual(len(res), 1)
     self.assertEqual(res[0]['hostname'], 'switch1')
예제 #2
0
 def test_netdevice_get_all(self):
     dbapi.netdevices_create(self.context, device1)
     filters = {}
     res = dbapi.netdevices_get_by_region(self.context,
                                          device1['region_id'],
                                          filters)
     self.assertEqual(len(res), 1)
     self.assertEqual(res[0]['hostname'], 'switch1')
예제 #3
0
 def test_netdevices_update(self):
     device = dbapi.netdevices_create(self.context, device1)
     res = dbapi.netdevices_get_by_id(self.context, device.id)
     self.assertEqual(res.hostname, 'switch1')
     new_name = 'switch2'
     res = dbapi.netdevices_update(self.context, res.id,
                                   {'name': 'switch2'})
     self.assertEqual(res.name, new_name)
예제 #4
0
 def test_netdevices_delete(self):
     device = dbapi.netdevices_create(self.context, device1)
     # First make sure we have the device
     res = dbapi.netdevices_get_by_id(self.context, device.id)
     self.assertEqual(res.id, device.id)
     # Delete the device
     dbapi.netdevices_delete(self.context, res.id)
     self.assertRaises(exceptions.NotFound, dbapi.netdevices_get_by_id,
                       self.context, res.id)
예제 #5
0
 def test_netdevices_delete(self):
     device = dbapi.netdevices_create(self.context, device1)
     # First make sure we have the device
     res = dbapi.netdevices_get_by_id(self.context, device.id)
     self.assertEqual(res.id, device.id)
     # Delete the device
     dbapi.netdevices_delete(self.context, res.id)
     self.assertRaises(exceptions.NotFound, dbapi.netdevices_get_by_id,
                       self.context, res.id)
예제 #6
0
 def test_netdevice_data_delete(self):
     device = dbapi.netdevices_create(self.context, device1)
     _data = {"hello": "hi", "a": "b"}
     dbapi.netdevices_data_update(self.context, device.id, _data)
     ndevice = dbapi.netdevices_get_by_id(self.context, device.id)
     self.assertEqual(ndevice.variables, _data)
     _del_data = {"key": "a"}
     dbapi.netdevices_data_delete(self.context, device.id, _del_data)
     ndevice = dbapi.netdevices_get_by_id(self.context, device.id)
     self.assertEqual(ndevice.variables, {"hello": "hi"})
예제 #7
0
 def test_netdevice_labels_delete(self):
     device = dbapi.netdevices_create(self.context, device1)
     _labels = {"labels": ["tom", "jerry"]}
     dbapi.netdevices_labels_update(self.context, device.id, _labels)
     ndevice = dbapi.netdevices_get_by_id(self.context, device.id)
     self.assertEqual(sorted(ndevice.labels), sorted(_labels["labels"]))
     _dlabels = {"labels": ["tom"]}
     dbapi.netdevices_labels_delete(self.context, ndevice.id, _dlabels)
     ndevice = dbapi.netdevices_get_by_id(self.context, ndevice.id)
     self.assertEqual(ndevice.labels, {"jerry"})
예제 #8
0
 def test_netdevice_data_delete(self):
     device = dbapi.netdevices_create(self.context, device1)
     _data = {"hello": "hi", "a": "b"}
     dbapi.netdevices_data_update(self.context, device.id, _data)
     ndevice = dbapi.netdevices_get_by_id(self.context, device.id)
     self.assertEqual(ndevice.variables, _data)
     _del_data = {"key": "a"}
     dbapi.netdevices_data_delete(self.context, device.id, _del_data)
     ndevice = dbapi.netdevices_get_by_id(self.context, device.id)
     self.assertEqual(ndevice.variables, {"hello": "hi"})
예제 #9
0
 def test_netdevice_labels_delete(self):
     device = dbapi.netdevices_create(self.context, device1)
     _labels = {"labels": ["tom", "jerry"]}
     dbapi.netdevices_labels_update(self.context, device.id, _labels)
     ndevice = dbapi.netdevices_get_by_id(self.context, device.id)
     self.assertEqual(sorted(ndevice.labels), sorted(_labels["labels"]))
     _dlabels = {"labels": ["tom"]}
     dbapi.netdevices_labels_delete(self.context, ndevice.id, _dlabels)
     ndevice = dbapi.netdevices_get_by_id(self.context, ndevice.id)
     self.assertEqual(ndevice.labels, {"jerry"})
예제 #10
0
 def test_netdevices_create(self):
     try:
         dbapi.netdevices_create(self.context, device1)
     except Exception:
         self.fail("Network device create raised unexpected exception")
예제 #11
0
 def test_netdevice_labels_create(self):
     device = dbapi.netdevices_create(self.context, device1)
     labels = {"labels": ["tom", "jerry"]}
     dbapi.netdevices_labels_update(self.context, device.id, labels)
예제 #12
0
 def test_netdevices_get_by_id(self):
     device = dbapi.netdevices_create(self.context, device1)
     res = dbapi.netdevices_get_by_id(self.context, device.id)
     self.assertEqual(res.hostname, 'switch1')
예제 #13
0
 def test_netdevices_get_by_id(self):
     device = dbapi.netdevices_create(self.context, device1)
     res = dbapi.netdevices_get_by_id(self.context, device.id)
     self.assertEqual(res.hostname, 'switch1')
예제 #14
0
 def test_netdevices_create(self):
     try:
         dbapi.netdevices_create(self.context, device1)
     except Exception:
         self.fail("Network device create raised unexpected exception")
예제 #15
0
 def test_netdevice_labels_create(self):
     device = dbapi.netdevices_create(self.context, device1)
     labels = {"labels": ["tom", "jerry"]}
     dbapi.netdevices_labels_update(self.context, device.id, labels)