
import uuid

from openstack.object_store.v1 import container
from openstack.tests.functional import base


class TestContainer(base.BaseFunctionalTest):

    NAME = uuid.uuid4().hex

    @classmethod
    def setUpClass(cls):
        super(TestContainer, cls).setUpClass()
        tainer = cls.conn.object_store.create_container(name=cls.NAME)
        assert isinstance(tainer, container.Container)
        cls.assertIs(cls.NAME, tainer.name)

    @classmethod
    def tearDownClass(cls):
        pass
        # TODO(thowe): uncomment this when bug/1451211 fixed
        # tainer = cls.conn.object_store.delete_container(cls.NAME,
        #                                                 ignore_missing=False)
        # cls.assertIs(None, tainer)

    def test_list(self):
        names = [o.name for o in self.conn.object_store.containers()]
        self.assertIn(self.NAME, names)


import uuid

from openstack.object_store.v1 import container
from openstack.tests.functional import base


class TestContainer(base.BaseFunctionalTest):

    NAME = uuid.uuid4().hex

    @classmethod
    def setUpClass(cls):
        super(TestContainer, cls).setUpClass()
        tainer = cls.conn.object_store.create_container(name=cls.NAME)
        assert isinstance(tainer, container.Container)
        cls.assertIs(cls.NAME, tainer.name)

    @classmethod
    def tearDownClass(cls):
        result = cls.conn.object_store.delete_container(cls.NAME,
                                                        ignore_missing=False)
        cls.assertIs(None, result)

    def test_list(self):
        names = [o.name for o in self.conn.object_store.containers()]
        self.assertIn(self.NAME, names)

    def test_get_metadata(self):
        tainer = self.conn.object_store.get_container_metadata(self.NAME)
        self.assertEqual(0, tainer.object_count)
        self.assertEqual(0, tainer.bytes_used)
        self.assertEqual(self.NAME, tainer.name)

Add functional tests for container metadata and delete
Add functional tests for container metadata and delete

Change-Id: Id13073b37d19482ca6ff6e53e315aaa424c3f1b9

  
  import uuid
  
  from openstack.object_store.v1 import container
  from openstack.tests.functional import base
  
  
  class TestContainer(base.BaseFunctionalTest):
  
      NAME = uuid.uuid4().hex
  
      @classmethod
      def setUpClass(cls):
          super(TestContainer, cls).setUpClass()
          tainer = cls.conn.object_store.create_container(name=cls.NAME)
          assert isinstance(tainer, container.Container)
          cls.assertIs(cls.NAME, tainer.name)
  
      @classmethod
      def tearDownClass(cls):
-         pass
-         # TODO(thowe): uncomment this when bug/1451211 fixed
-         # tainer = cls.conn.object_store.delete_container(cls.NAME,
+         result = cls.conn.object_store.delete_container(cls.NAME,
-         #                                                 ignore_missing=False)
+                                                         ignore_missing=False)
-         # cls.assertIs(None, tainer)
+         cls.assertIs(None, result)
  
      def test_list(self):
          names = [o.name for o in self.conn.object_store.containers()]
          self.assertIn(self.NAME, names)
  
+     def test_get_metadata(self):
+         tainer = self.conn.object_store.get_container_metadata(self.NAME)
+         self.assertEqual(0, tainer.object_count)
+         self.assertEqual(0, tainer.bytes_used)
+         self.assertEqual(self.NAME, tainer.name)
+ 
Add functional tests for container metadata and delete
## Code Before:

import uuid

from openstack.object_store.v1 import container
from openstack.tests.functional import base


class TestContainer(base.BaseFunctionalTest):

    NAME = uuid.uuid4().hex

    @classmethod
    def setUpClass(cls):
        super(TestContainer, cls).setUpClass()
        tainer = cls.conn.object_store.create_container(name=cls.NAME)
        assert isinstance(tainer, container.Container)
        cls.assertIs(cls.NAME, tainer.name)

    @classmethod
    def tearDownClass(cls):
        pass
        # TODO(thowe): uncomment this when bug/1451211 fixed
        # tainer = cls.conn.object_store.delete_container(cls.NAME,
        #                                                 ignore_missing=False)
        # cls.assertIs(None, tainer)

    def test_list(self):
        names = [o.name for o in self.conn.object_store.containers()]
        self.assertIn(self.NAME, names)

## Instruction:
Add functional tests for container metadata and delete
## Code After:

import uuid

from openstack.object_store.v1 import container
from openstack.tests.functional import base


class TestContainer(base.BaseFunctionalTest):

    NAME = uuid.uuid4().hex

    @classmethod
    def setUpClass(cls):
        super(TestContainer, cls).setUpClass()
        tainer = cls.conn.object_store.create_container(name=cls.NAME)
        assert isinstance(tainer, container.Container)
        cls.assertIs(cls.NAME, tainer.name)

    @classmethod
    def tearDownClass(cls):
        result = cls.conn.object_store.delete_container(cls.NAME,
                                                        ignore_missing=False)
        cls.assertIs(None, result)

    def test_list(self):
        names = [o.name for o in self.conn.object_store.containers()]
        self.assertIn(self.NAME, names)

    def test_get_metadata(self):
        tainer = self.conn.object_store.get_container_metadata(self.NAME)
        self.assertEqual(0, tainer.object_count)
        self.assertEqual(0, tainer.bytes_used)
        self.assertEqual(self.NAME, tainer.name)
