Example #1
0
    def setUp(self):
        # Basic setup and mock/fake structures for testing only
        super(TestDatastoreBase, self).setUp()
        util.init_db()
        self.rand_id = str(uuid.uuid4())
        self.ds_name = "my-test-datastore" + self.rand_id
        self.ds_version = "my-test-version" + self.rand_id
        self.capability_name = "root_on_create" + self.rand_id
        self.capability_desc = "Enables root on create"
        self.capability_enabled = True

        datastore_models.update_datastore(self.ds_name, False)
        self.datastore = Datastore.load(self.ds_name)

        datastore_models.update_datastore_version(
            self.ds_name, self.ds_version, "mysql", "", "", True)

        self.datastore_version = DatastoreVersion.load(self.datastore,
                                                       self.ds_version)
        self.test_id = self.datastore_version.id

        self.cap1 = Capability.create(self.capability_name,
                                      self.capability_desc, True)
        self.cap2 = Capability.create("require_volume" + self.rand_id,
                                      "Require external volume", True)
        self.cap3 = Capability.create("test_capability" + self.rand_id,
                                      "Test capability", False)
Example #2
0
    def setUp(self):
        # Basic setup and mock/fake structures for testing only
        super(TestDatastoreBase, self).setUp()
        util.init_db()
        self.rand_id = str(uuid.uuid4())
        self.ds_name = "my-test-datastore" + self.rand_id
        self.ds_version = "my-test-version" + self.rand_id
        self.capability_name = "root_on_create" + self.rand_id
        self.capability_desc = "Enables root on create"
        self.capability_enabled = True
        self.datastore_version_id = str(uuid.uuid4())
        self.flavor_id = 1

        datastore_models.update_datastore(self.ds_name, False)
        self.datastore = Datastore.load(self.ds_name)

        datastore_models.update_datastore_version(self.ds_name, self.ds_version, "mysql", "", "", True)
        DatastoreVersionMetadata.add_datastore_version_flavor_association(
            self.ds_name, self.ds_version, [self.flavor_id]
        )

        self.datastore_version = DatastoreVersion.load(self.datastore, self.ds_version)
        self.test_id = self.datastore_version.id

        self.cap1 = Capability.create(self.capability_name, self.capability_desc, True)
        self.cap2 = Capability.create("require_volume" + self.rand_id, "Require external volume", True)
        self.cap3 = Capability.create("test_capability" + self.rand_id, "Test capability", False)
Example #3
0
    def setUpClass(cls):
        util.init_db()

        cls.ds_name = cls.random_name(name='test-datastore')
        cls.ds_version_name = cls.random_name(name='test-version')
        cls.capability_name = cls.random_name(name='root_on_create',
                                              prefix='TestDatastoreBase')
        cls.capability_desc = "Enables root on create"
        cls.capability_enabled = True
        cls.flavor_id = 1
        cls.volume_type = 'some-valid-volume-type'

        datastore_models.update_datastore(cls.ds_name, False)
        cls.datastore = Datastore.load(cls.ds_name)

        datastore_models.update_datastore_version(cls.ds_name,
                                                  cls.ds_version_name, "mysql",
                                                  "", "", "", True)
        cls.datastore_version = DatastoreVersion.load(cls.datastore,
                                                      cls.ds_version_name)
        cls.test_id = cls.datastore_version.id

        DatastoreVersionMetadata.add_datastore_version_flavor_association(
            cls.datastore_version.id, [cls.flavor_id])
        DatastoreVersionMetadata.add_datastore_version_volume_type_association(
            cls.datastore_version.id, [cls.volume_type])

        cls.cap1 = Capability.create(cls.capability_name, cls.capability_desc,
                                     True)
        cls.cap2 = Capability.create(
            cls.random_name(name='require_volume', prefix='TestDatastoreBase'),
            "Require external volume", True)
        cls.cap3 = Capability.create(
            cls.random_name(name='test_capability',
                            prefix='TestDatastoreBase'), "Test capability",
            False)

        super(TestDatastoreBase, cls).setUpClass()
Example #4
0
    def test_capability_disabled(self):
        capability = Capability.load(self.capability_name)
        capability.disable()
        self.assertFalse(capability.enabled)

        self.assertFalse(Capability.load(self.capability_name).enabled)
Example #5
0
 def test_capability_enabled(self):
     self.assertTrue(Capability.load(self.capability_name).enabled)
Example #6
0
 def test_capability(self):
     cap = Capability.load(self.capability_name)
     self.assertEqual(self.capability_name, cap.name)
     self.assertEqual(self.capability_desc, cap.description)
     self.assertEqual(self.capability_enabled, cap.enabled)
Example #7
0
    def test_capability_disabled(self):
        capability = Capability.load(self.capability_name)
        capability.disable()
        self.assertFalse(capability.enabled)

        self.assertFalse(Capability.load(self.capability_name).enabled)
Example #8
0
 def test_capability_enabled(self):
     self.assertTrue(Capability.load(self.capability_name).enabled)
Example #9
0
 def test_capability(self):
     cap = Capability.load(self.capability_name)
     self.assertEqual(cap.name, self.capability_name)
     self.assertEqual(cap.description, self.capability_desc)
     self.assertEqual(cap.enabled, self.capability_enabled)