Example #1
0
 def test_create(self):
     try:
         self.spam = self.api.spam.create()
         assert_is_none(self.create)
     except SpamHttpException as she:
         self.spam = self.admin_api.spam.create()
         assert_equal(she.status_code, self.create)
Example #2
0
    def assert_users_list(self, instance_id, expected_user_defs, expected_http_code, limit=2):
        full_list = self.rd_client.users.list(instance_id)
        self.assert_client_code(expected_http_code)
        listed_users = {user.name: user for user in full_list}
        asserts.assert_is_none(full_list.next, "Unexpected pagination in the list.")

        for user_def in expected_user_defs:
            user_name = user_def["name"]
            asserts.assert_true(
                user_name in listed_users, "User not included in the 'user-list' output: %s" % user_name
            )
            self._assert_user_matches(listed_users[user_name], user_def)

        # Check that the system (ignored) users are not included in the output.
        system_users = self.get_system_users()
        asserts.assert_false(
            any(name in listed_users for name in system_users),
            "System users should not be included in the 'user-list' output.",
        )

        # Test list pagination.
        list_page = self.rd_client.users.list(instance_id, limit=limit)
        self.assert_client_code(expected_http_code)

        asserts.assert_true(len(list_page) <= limit)
        asserts.assert_is_not_none(list_page.next, "List page is missing.")
        marker = list_page.next

        self.assert_pagination_match(list_page, full_list, 0, limit)
        self.assert_pagination_match(list_page[-1:], full_list, limit - 1, limit)

        list_page = self.rd_client.users.list(instance_id, marker=marker)
        self.assert_client_code(expected_http_code)
        self.assert_pagination_match(list_page, full_list, limit, len(full_list))
Example #3
0
 def test_read(self):
     try:
         spam = self.api.spam.get(self.spam.id)
         assert_is_none(self.read)
         assert_equal(spam, self.spam)
     except SpamHttpException as she:
         assert_equal(she.status_code, self.read)
 def test_read(self):
     try:
         spam = self.api.spam.get(self.spam.id)
         assert_is_none(self.read)
         assert_equal(spam, self.spam)
     except SpamHttpException as she:
         assert_equal(she.status_code, self.read)
 def test_create(self):
     try:
         self.spam = self.api.spam.create()
         assert_is_none(self.create)
     except SpamHttpException as she:
         self.spam = self.admin_api.spam.create()
         assert_equal(she.status_code, self.create)
Example #6
0
 def test_module_remove(self):
     with patch.object(
             module_manager.ModuleManager, 'remove_module',
             return_value=[self.expected_module_details]) as mock_rm:
         module_details = self.manager.module_remove(
             self.context,
             {'module': self.expected_module_details})
         assert_is_none(module_details)
         assert_equal(1, mock_rm.call_count)
Example #7
0
 def test_module_remove(self):
     with patch.object(
             module_manager.ModuleManager, 'remove_module',
             return_value=[self.expected_module_details]) as mock_rm:
         module_details = self.manager.module_remove(
             self.context,
             {'module': self.expected_module_details})
         assert_is_none(module_details)
         assert_equal(1, mock_rm.call_count)
    def test_pagination(self, requested_limit, requested_marker,
                        expected_length, expected_marker, expected_last_item):
        instances = self.dbaas.instances.list(limit=requested_limit,
                                              marker=requested_marker)
        marker = instances.next

        self.print_list(instances)

        # Better get as many as we asked for.
        assert_equal(len(instances), expected_length)
        # The last one should be roughly this one in the list.
        assert_equal(instances[-1].id, expected_last_item)
        # Because limit < count, the marker must be something.
        if expected_marker:
            assert_is_not(marker, None)
            assert_equal(marker, expected_marker)
        else:
            assert_is_none(marker)
        self.assert_instances_sorted_by_ids(instances)
    def test_pagination(self, requested_limit, requested_marker,
                        expected_length, expected_marker, expected_last_item):
        instances = self.dbaas.instances.list(limit=requested_limit,
                                              marker=requested_marker)
        marker = instances.next

        self.print_list(instances)

        # Better get as many as we asked for.
        assert_equal(len(instances), expected_length)
        # The last one should be roughly this one in the list.
        assert_equal(instances[-1].id, expected_last_item)
        # Because limit < count, the marker must be something.
        if expected_marker:
            assert_is_not(marker, None)
            assert_equal(marker, expected_marker)
        else:
            assert_is_none(marker)
        self.assert_instances_sorted_by_ids(instances)
Example #10
0
    def assert_databases_list(self,
                              instance_id,
                              expected_database_defs,
                              expected_http_code,
                              limit=2):
        full_list = self.rd_client.databases.list(instance_id)
        self.assert_client_code(expected_http_code)
        listed_databases = {database.name: database for database in full_list}
        asserts.assert_is_none(full_list.next,
                               "Unexpected pagination in the list.")

        for database_def in expected_database_defs:
            database_name = database_def['name']
            asserts.assert_true(
                database_name in listed_databases,
                "Database not included in the 'database-list' output: %s" %
                database_name)

        # Check that the system (ignored) databases are not included in the
        # output.
        system_databases = self.get_system_databases()
        asserts.assert_false(
            any(name in listed_databases for name in system_databases),
            "System databases should not be included in the 'database-list' "
            "output.")

        # Test list pagination.
        list_page = self.rd_client.databases.list(instance_id, limit=limit)
        self.assert_client_code(expected_http_code)

        asserts.assert_true(len(list_page) <= limit)
        asserts.assert_is_not_none(list_page.next, "List page is missing.")
        marker = list_page.next

        self.assert_pagination_match(list_page, full_list, 0, limit)
        self.assert_pagination_match(list_page[-1:], full_list, limit - 1,
                                     limit)

        list_page = self.rd_client.databases.list(instance_id, marker=marker)
        self.assert_client_code(expected_http_code)
        self.assert_pagination_match(list_page, full_list, limit,
                                     len(full_list))
Example #11
0
    def assert_users_list(self,
                          instance_id,
                          expected_user_defs,
                          expected_http_code,
                          limit=2):
        full_list = self.rd_client.users.list(instance_id)
        self.assert_client_code(expected_http_code)
        listed_users = {user.name: user for user in full_list}
        asserts.assert_is_none(full_list.next,
                               "Unexpected pagination in the list.")

        for user_def in expected_user_defs:
            user_name = user_def['name']
            asserts.assert_true(
                user_name in listed_users,
                "User not included in the 'user-list' output: %s" % user_name)
            self._assert_user_matches(listed_users[user_name], user_def)

        # Check that the system (ignored) users are not included in the output.
        system_users = self.get_system_users()
        asserts.assert_false(
            any(name in listed_users for name in system_users),
            "System users should not be included in the 'user-list' output.")

        # Test list pagination.
        list_page = self.rd_client.users.list(instance_id, limit=limit)
        self.assert_client_code(expected_http_code)

        asserts.assert_true(len(list_page) <= limit)
        asserts.assert_is_not_none(list_page.next, "List page is missing.")
        marker = list_page.next

        self.assert_pagination_match(list_page, full_list, 0, limit)
        self.assert_pagination_match(list_page[-1:], full_list, limit - 1,
                                     limit)

        list_page = self.rd_client.users.list(instance_id, marker=marker)
        self.assert_client_code(expected_http_code)
        self.assert_pagination_match(list_page, full_list, limit,
                                     len(full_list))
Example #12
0
    def assert_databases_list(self, instance_id, expected_database_defs,
                              expected_http_code, limit=2):
        full_list = self.rd_client.databases.list(instance_id)
        self.assert_client_code(expected_http_code)
        listed_databases = {database.name: database for database in full_list}
        asserts.assert_is_none(full_list.next,
                               "Unexpected pagination in the list.")

        for database_def in expected_database_defs:
            database_name = database_def['name']
            asserts.assert_true(
                database_name in listed_databases,
                "Database not included in the 'database-list' output: %s" %
                database_name)

        # Check that the system (ignored) databases are not included in the
        # output.
        system_databases = self.get_system_databases()
        asserts.assert_false(
            any(name in listed_databases for name in system_databases),
            "System databases should not be included in the 'database-list' "
            "output.")

        # Test list pagination.
        list_page = self.rd_client.databases.list(instance_id, limit=limit)
        self.assert_client_code(expected_http_code)

        asserts.assert_true(len(list_page) <= limit)
        asserts.assert_is_not_none(list_page.next, "List page is missing.")
        marker = list_page.next

        self.assert_pagination_match(list_page, full_list, 0, limit)
        self.assert_pagination_match(
            list_page[-1:], full_list, limit - 1, limit)

        list_page = self.rd_client.databases.list(instance_id, marker=marker)
        self.assert_client_code(expected_http_code)
        self.assert_pagination_match(
            list_page, full_list, limit, len(full_list))
Example #13
0
 def assert_is_none(cls, value, message=None):
     asserts.assert_is_none(value, message=message)
Example #14
0
 def test_delete(self):
     try:
         self.api.spam.delete(self.spam.id)
         assert_is_none(self.delete)
     except SpamHttpException as she:
         assert_equal(she.status_code, self.delete)
 def test_delete(self):
     try:
         self.api.spam.delete(self.spam.id)
         assert_is_none(self.delete)
     except SpamHttpException as she:
         assert_equal(she.status_code, self.delete)
 def test_is_not_none3(self):
     assert_is_none(None, "Blah!")
 def queue_is_deleted(self):
     """Makes sure the queue is cleaned up."""
     rabbit = rpc.Rabbit()
     queue_name = "guestagent.%s" % instance_info.id
     count = rabbit.get_queue_items(queue_name)
     assert_is_none(count)
 def test_is_none1(self):
     assert_is_none(None)
Example #19
0
 def queue_is_deleted(self):
     """Makes sure the queue is cleaned up."""
     rabbit = rpc.Rabbit()
     queue_name = "guestagent.%s" % instance_info.id
     count = rabbit.get_queue_items(queue_name)
     assert_is_none(count)
 def test_is_not_none3(self):
     assert_is_none(None, "Blah!")
 def test_is_none1(self):
     assert_is_none(None)