示例#1
0
 def test_create_partition_invalid_additional_attributes(self):
     # Test creation of partition with an invalid attribute called 'foo'
     ndict = dbutils.post_get_test_partition(forihostid=self.ihost.id,
                                             idisk_id=self.disk.id,
                                             foo='some value')
     self.assertRaises(webtest.app.AppError,
                       self.post_json,
                       self.API_PREFIX,
                       ndict,
                       headers=self.API_HEADERS)
示例#2
0
 def test_create_partition_invalid_disk(self):
     # Test creation of partition with an invalid disk
     ndict = dbutils.post_get_test_partition(forihostid=self.ihost.id,
                                             idisk_id=1234567,
                                             size_mib=128)
     self.assertRaises(webtest.app.AppError,
                       self.post_json,
                       self.API_PREFIX,
                       ndict,
                       headers=self.API_HEADERS)
示例#3
0
    def test_create_partition_invalid_size(self):
        # Test creation of partition with an invalid disk

        # Available size is 256. Therefore a 256 partition is considered invalid.
        invalid_sizes = [None, 0, -100, 256, 257, 'xyz']
        for bad_size in invalid_sizes:
            ndict = dbutils.post_get_test_partition(forihostid=self.ihost.id,
                                                    idisk_id=self.disk.id,
                                                    size_mib=bad_size)
            self.assertRaises(webtest.app.AppError,
                              self.post_json,
                              self.API_PREFIX,
                              ndict,
                              headers=self.API_HEADERS)
示例#4
0
    def test_create_partition(self):
        # Test creation of partition
        ndict = dbutils.post_get_test_partition(forihostid=self.ihost.id,
                                                idisk_id=self.disk.id,
                                                idisk_uuid=self.disk.uuid,
                                                size_mib=128)
        response = self.post_json(self.API_PREFIX,
                                  ndict,
                                  headers=self.API_HEADERS)

        # Verify that no filesystems were created
        self.fake_conductor_api.create_controller_filesystems.\
            assert_not_called()

        self.assertEqual('application/json', response.content_type)
        self.assertEqual(response.status_code, http_client.OK)
        self.assertEqual(response.json['size_mib'], ndict['size_mib'])

        uuid = response.json['uuid']
        # Verify that the partition was created and some basic attributes match
        response = self.get_json(self.get_single_url(uuid))
        self.assertEqual(response['size_mib'], ndict['size_mib'])