Пример #1
0
 def test_add_root(self):
     chassis = obj_utils.get_test_chassis(self.context)
     response = self.patch_json('/chassis/%s' % chassis.uuid,
                                [{'path': '/description', 'value': 'test',
                                  'op': 'add'}])
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(200, response.status_int)
Пример #2
0
 def test_remove_uuid(self):
     chassis = obj_utils.get_test_chassis(self.context)
     response = self.patch_json('/chassis/%s' % chassis.uuid,
                                [{'path': '/uuid', 'op': 'remove'}],
                                expect_errors=True)
     self.assertEqual(400, response.status_int)
     self.assertEqual('application/json', response.content_type)
     self.assertTrue(response.json['error_message'])
Пример #3
0
 def test_remove_non_existent_property_fail(self):
     chassis = obj_utils.get_test_chassis(self.context)
     response = self.patch_json('/chassis/%s' % chassis.uuid,
                          [{'path': '/extra/non-existent', 'op': 'remove'}],
                          expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_code)
     self.assertTrue(response.json['error_message'])
Пример #4
0
 def test_add_root_non_existent(self):
     chassis = obj_utils.get_test_chassis(self.context)
     response = self.patch_json('/chassis/%s' % chassis.uuid,
                                [{'path': '/foo', 'value': 'bar',
                                  'op': 'add'}],
                                expect_errors=True)
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(400, response.status_int)
     self.assertTrue(response.json['error_message'])
Пример #5
0
 def test_add_multi(self):
     chassis = obj_utils.get_test_chassis(self.context)
     response = self.patch_json('/chassis/%s' % chassis.uuid,
                                [{'path': '/extra/foo1', 'value': 'bar1',
                                  'op': 'add'},
                                 {'path': '/extra/foo2', 'value': 'bar2',
                                  'op': 'add'}])
     self.assertEqual('application/json', response.content_type)
     self.assertEqual(200, response.status_code)
     result = self.get_json('/chassis/%s' % chassis.uuid)
     expected = {"foo1": "bar1", "foo2": "bar2"}
     self.assertEqual(expected, result['extra'])
Пример #6
0
    def test_replace_singular(self, mock_utcnow):
        chassis = obj_utils.get_test_chassis(self.context)
        description = 'chassis-new-description'
        test_time = datetime.datetime(2000, 1, 1, 0, 0)

        mock_utcnow.return_value = test_time
        response = self.patch_json('/chassis/%s' % chassis.uuid,
                                   [{'path': '/description',
                                     'value': description, 'op': 'replace'}])
        self.assertEqual('application/json', response.content_type)
        self.assertEqual(200, response.status_code)
        result = self.get_json('/chassis/%s' % chassis.uuid)
        self.assertEqual(description, result['description'])
        return_updated_at = timeutils.parse_isotime(
                            result['updated_at']).replace(tzinfo=None)
        self.assertEqual(test_time, return_updated_at)
Пример #7
0
 def test_patch_nodes_subresource(self):
     chassis = obj_utils.get_test_chassis(self.context)
     response = self.patch_json('/chassis/%s/nodes' % chassis.uuid,
                                [{'path': '/extra/foo', 'value': 'bar',
                                  'op': 'add'}], expect_errors=True)
     self.assertEqual(403, response.status_int)
Пример #8
0
 def test_patch_nodes_subresource(self):
     chassis = obj_utils.get_test_chassis(self.context)
     response = self.patch_json('/chassis/%s/nodes' % chassis.uuid,
                                [{'path': '/extra/foo', 'value': 'bar',
                                  'op': 'add'}], expect_errors=True)
     self.assertEqual(403, response.status_int)