## Lines beginning with '##' are for explaining the contents of this
## file, and should be removed if you copy the file to create a new
## (set of) tests.  Also note that the file must be named to match the
## scheme "test_[...].py", i.e., "test_tokens.py".
##
## I don't think I need to explain the copyright notice :)
##
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright (c) 2011 OpenStack, LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.


## This test suite uses the DTest framework, which can be found on
## PyPi ("pip install dtest").  DTest uses threading to perform tests
## in parallel; the threading can be limited by using dependencies,
## but the purpose of dependencies is really to say that some test
## must pass before other actions can be performed.  Within dtest, the
## util module contains a number of useful "assert_*()" functions, but
## if you want, you can just use the "assert" statement.
##
## Also note that names are important.  Modules should be named
## "test_[...].py", as mentioned above.  Classes must extend
## base.KeystoneTest (a subclass of dtest.DTestCase), and test methods
## should have names like "test_[...]" (or be decorated with the
## @dtest.istest decorator).  Adhere to these rules, and DTest can
## discover and run the tests without you having to do anything other
## than create them.
import dtest
from dtest import util

## The "base" module contains KeystoneTest, which ensures that there's
## a Keystone authentication token in self.token and an API accessor
## in self.ks.  See ksapi.py for a list of what methods are available
## on self.ks.
import base


## Tests should be gathered together in classes, not too dissimilar
## from how unittest works.  Extend base.KeystoneTest, so you get
## self.token and self.ks.  If you override setUp(), make sure you
## call the superclass's setUp() method (it's responsible for setting
## self.ks).  Try to avoid overriding setUpClass() or tearDownClass()
## if you can help it (they're responsible for setting up and
## destroying self.token).
class SampleTest(base.KeystoneTest):
    def test_sample(self):
        """Test that we can do sample."""
        ## You don't *have* to declare a doc string, but it's good
        ## practice.

        ## Here we're making a "sample_call()", passing self.token as
        ## the authentication token.  For available calls and the
        ## order of arguments, check out ksapi.py.  The return value
        ## will be an httplib.HTTPResponse object with additional
        ## 'body' (str) and 'obj' (dict) attributes.  If a status code
        ## greater than or equal to 400 is returned from the other
        ## end, an exception will be raised; the response will be
        ## attached to the 'response' attribute of the exception, and
        ## the status will be on the 'status' attribute of the
        ## exception.  Note that redirects are followed.
        resp = self.ks.sample_call(self.token, 'argument 1', 'argument 2')

        # Verify that resp is correct
        util.assert_equal(resp.status, 200)
        util.assert_in('sample', resp.obj)
        ## Place your various assertions about the response here.

        ## Rinse, lather, repeat.  You should perform only a single
        ## test per test method, but if you're doing creation tests,
        ## it makes sense to include the deletion test in the same
        ## test method.  Remember, the only control you have over test
        ## ordering is by setting up dependencies (@dtest.depends()).
        ## No return value is necessary.

@@ -2001,19 +2001,16 @@
 ken and 
-an 
 API acce
@@ -2017,22 +2017,35 @@
 ssor
-%0A## in
+s in%0A## self.ks and
  self.ks
 .  S
@@ -2040,16 +2040,22 @@
  self.ks
+_admin
 .  See k
@@ -2088,16 +2088,19 @@
  methods
+%0A##
  are ava
@@ -2105,19 +2105,16 @@
 vailable
-%0A##
  on self
@@ -2116,16 +2116,30 @@
  self.ks
+/self.ks_admin
 .%0Aimport
@@ -2284,29 +2284,58 @@
 get%0A## self.
-token
+user_tok, self.ks, self.admin_tok,
  and self.ks
@@ -2334,16 +2334,22 @@
  self.ks
+_admin
 .  If yo
@@ -2349,16 +2349,19 @@
   If you
+%0A##
  overrid
@@ -2384,19 +2384,16 @@
 sure you
-%0A##
  call th
@@ -2414,16 +2414,19 @@
  setUp()
+%0A##
  method 
@@ -2458,22 +2458,39 @@
 ting
-%0A## self.ks). 
+ self.ks and self.ks_admin).%0A##
  Try
@@ -2541,19 +2541,16 @@
 nClass()
-%0A##
  if you 
@@ -2552,16 +2552,19 @@
  you can
+%0A##
  help it
@@ -2603,19 +2603,16 @@
 g up and
-%0A##
  destroy
@@ -2614,27 +2614,52 @@
 stroying
+%0A##
  self.
+admin_tok and self.user_
 tok
-en
 ).%0Aclass
@@ -3553,21 +3553,24 @@
 ll(self.
+user_
 tok
-en
 , 'argum

Update the sample to reflect some minor enhancements to the base framework.