class searchTest(unittest.TestCase):

    def setUp(self):
        print ""
        print "*********************************************************************"
        print "*********************************************************************"
        print "*********************************************************************"
        self.config = ConfigParser.ConfigParser()
        self.config.read('strata.cfg')

        self.user = self.config.get('strata', 'external_username')
        if (self.user.startswith('$')):
            self.user = os.environ.get(self.user[1:])
            print "Username: "******"Username: %s" % self.user)

        self.passwd = self.config.get('strata', 'external_password')
        if (self.passwd.startswith('$')):
            self.passwd = os.environ.get(self.passwd[1:])
            logging.log(5, "password: %s" % self.passwd)

        self.url = self.config.get('strata', 'url')
        if (self.url.startswith('$')):
            self.url = os.environ.get(self.url[1:])
            print "url: ", self.url

        self.api = API(username=self.user,
                       password=self.passwd,
                       url=self.url,
                       no_verify_ssl=True)


    def tearDown(self):
        self.api.disconnect();


    def testSearch(self):
        print "---testSearch---"
        try:
            solAry = self.api.search.search(self.config.get('testFilterSolutions', 'keyword'))
            assert solAry is not None
            for sol in solAry:
                print "Found the following solution:"
                print sol.toXml()
        except RequestError, re:
            self.fail("Unable to connect to support services API.  Reason:  %s %s" % (re.status, re.reason))
        except ConnectionError:
            self.fail("Problem connecting to the support services API.  Is the service accessible from this host?")
    def setUp(self):
        print ""
        print "*********************************************************************"
        print "*********************************************************************"
        print "*********************************************************************"
        self.config = ConfigParser.ConfigParser()
        self.config.read('strata.cfg')

        self.user = self.config.get('strata', 'internal_username')
        if (self.user.startswith('$')):
            self.user = os.environ.get(self.user[1:])
            print "Username: "******"Username: %s" % self.user)

        self.passwd = self.config.get('strata', 'internal_password')
        if (self.passwd.startswith('$')):
            self.passwd = os.environ.get(self.passwd[1:])
            logging.log(5, "password: %s" % self.passwd)

        self.url = self.config.get('strata', 'url')
        if (self.url.startswith('$')):
            self.url = os.environ.get(self.url[1:])
            print "url: ", self.url

        self.api = API(username=self.user,
                       password=self.passwd,
                       url=self.url,
                       no_verify_ssl=True)
class solutionTest(unittest.TestCase):

    def setUp(self):
        self.config = ConfigParser.ConfigParser()
        self.config.read('strata.cfg')
        self.user = self.config.get('strata', 'internal_username')
        if (self.user.startswith('$')):
            self.user = os.environ.get(self.user[1:])
            print "Username: "******"Username: %s" % self.user)

        self.passwd = self.config.get('strata', 'internal_password')
        if (self.passwd.startswith('$')):
            self.passwd = os.environ.get(self.passwd[1:])
            logging.log(5, "password: %s" % self.passwd)

        self.url = self.config.get('strata', 'url')
        if (self.url.startswith('$')):
            self.url = os.environ.get(self.url[1:])
            print "url: ", self.url

        self.api = API(username=self.user,
                       password=self.passwd,
                       url=self.url,
                       no_verify_ssl=True)


    def tearDown(self):
        self.api.disconnect();


    def testGetSolution(self):
        print "---testGetSolution---"
        sid = self.config.get('testGetSolution', 'solutionID')
        print "Getting solution %s" % sid
        try:
            sol = self.api.solutions.get(sid)
            print sol
            assert sol is not None
            print "Solution title(%s)" % sol.get_title()
            assert sol.get_title() == self.config.get('testGetSolution', 'title')
            print "Solution authorSSOName(%s)" % sol.get_authorSSOName()
            assert sol.get_authorSSOName() == self.config.get('testGetSolution', 'authorSSOName')
        except RequestError, re:
            self.fail("Unable to connect to support services API.  Reason:  %s %s" % (re.status, re.reason))
        except ConnectionError:
            self.fail("Problem connecting to the support services API.  Is the service accessible from this host?")
class diagnoseTest(unittest.TestCase):

    def setUp(self):
        self.config = ConfigParser.ConfigParser()
        self.config.read('strata.cfg')
        self.user = self.config.get('strata', 'external_username')
        if (self.user.startswith('$')):
            self.user = os.environ.get(self.user[1:])
            print "Username: "******"Username: %s" % self.user)

        self.passwd = self.config.get('strata', 'external_password')
        if (self.passwd.startswith('$')):
            self.passwd = os.environ.get(self.passwd[1:])
            logging.log(5, "password: %s" % self.passwd)

        self.url = self.config.get('strata', 'url')
        if (self.url.startswith('$')):
            self.url = os.environ.get(self.url[1:])
            print "url: ", self.url

        self.api = API(username=self.user,
                       password=self.passwd,
                       url=self.url,
                       no_verify_ssl=True)


    def tearDown(self):
        self.api.disconnect();


    def testStringDiagnose(self):
        print "---testStringDiagnose---"
        # FIXME make me do something useful.
        # check that HTTP upload is escaped by broker.
        try:
            pary = self.api.problems.diagnoseStr('Exception: This failure intentionally triggered < > ')
            for p in pary:
                lary = p.get_link()
                for l in lary:
                    print l.get_uri()
                    print l.get_value()
        except RequestError, re:
            self.fail("Unable to connect to support services API.  Reason:  %s %s" % (re.status, re.reason))
        except ConnectionError:
            self.fail("Problem connecting to the support services API.  Is the service accessible from this host?")
class entitlementTest(unittest.TestCase):

    def setUp(self):
        self.config = ConfigParser.ConfigParser()
        self.config.read('strata.cfg')
        self.user = self.config.get('strata', 'external_username')
        if (self.user.startswith('$')):
            self.user = os.environ.get(self.user[1:])
            print "Username: "******"Username: %s" % self.user)

        self.passwd = self.config.get('strata', 'external_password')
        if (self.passwd.startswith('$')):
            self.passwd = os.environ.get(self.passwd[1:])
            logging.log(5, "password: %s" % self.passwd)

        self.url = self.config.get('strata', 'url')
        if (self.url.startswith('$')):
            self.url = os.environ.get(self.url[1:])
            print "url: ", self.url

        self.api = API(username=self.user,
                       password=self.passwd,
                       url=self.url,
                       no_verify_ssl=True)


    def tearDown(self):
        self.api.disconnect();


    # This is just a place-holder and needs to be replaced with a more meaningful test, just as soon as
    # someone can explain entitlements to me in sufficient detail
    def testGetEntitlements(self):
        print "---testGetEntitlements---"
        entAry = self.api.entitlements.list(activeOnly=True, product="JBoss Communications Platform")

        self.assertNotEqual(entAry, None)

        print "entitlements:"
        print "found", len(entAry), "entitlements."
class productTest(unittest.TestCase):
    def setUp(self):
        self.config = ConfigParser.ConfigParser()
        self.config.read("strata.cfg")
        self.user = self.config.get("strata", "external_username")
        if self.user.startswith("$"):
            self.user = os.environ.get(self.user[1:])
            logging.log(logging.DEBUG, "Username: %s" % self.user)

        self.passwd = self.config.get("strata", "external_password")
        if self.passwd.startswith("$"):
            self.passwd = os.environ.get(self.passwd[1:])
            logging.log(5, "password: %s" % self.passwd)

        self.url = self.config.get("strata", "url")
        if self.url.startswith("$"):
            self.url = os.environ.get(self.url[1:])
            print "url: ", self.url

        self.api = API(username=self.user, password=self.passwd, url=self.url, no_verify_ssl=True)

    def tearDown(self):
        self.api.disconnect()

    # This is just a place-holder and needs to be replaced with a more meaningful test.
    def testGetproducts(self):
        print "---testGetproducts---"
        prodAry = self.api.products.list()
        print "products:"
        for prod in prodAry:
            print "\n  %s:" % prod.get_name()
            verAry = prod.get_versions()
            for ver in verAry:
                print "    %s" % ver

        pass
    def setUp(self):
        self.config = ConfigParser.ConfigParser()
        self.config.read("strata.cfg")
        self.user = self.config.get("strata", "external_username")
        if self.user.startswith("$"):
            self.user = os.environ.get(self.user[1:])
            logging.log(logging.DEBUG, "Username: %s" % self.user)

        self.passwd = self.config.get("strata", "external_password")
        if self.passwd.startswith("$"):
            self.passwd = os.environ.get(self.passwd[1:])
            logging.log(5, "password: %s" % self.passwd)

        self.url = self.config.get("strata", "url")
        if self.url.startswith("$"):
            self.url = os.environ.get(self.url[1:])
            print "url: ", self.url

        self.api = API(username=self.user, password=self.passwd, url=self.url, no_verify_ssl=True)
class symptomTest(unittest.TestCase):


    def setUp(self):
        print ""
        print "*********************************************************************"
        print "*********************************************************************"
        print "*********************************************************************"
        self.config = ConfigParser.ConfigParser()
        self.config.read('strata.cfg')

        self.user = self.config.get('strata', 'internal_username')
        if (self.user.startswith('$')):
            self.user = os.environ.get(self.user[1:])
            print "Username: "******"Username: %s" % self.user)

        self.passwd = self.config.get('strata', 'internal_password')
        if (self.passwd.startswith('$')):
            self.passwd = os.environ.get(self.passwd[1:])
            logging.log(5, "password: %s" % self.passwd)

        self.url = self.config.get('strata', 'url')
        if (self.url.startswith('$')):
            self.url = os.environ.get(self.url[1:])
            print "url: ", self.url

        self.api = API(username=self.user,
                       password=self.passwd,
                       url=self.url,
                       no_verify_ssl=True)


    def tearDown(self):
        self.api.disconnect();


    def testAddSymptom(self):
        print "---testAddSymptom---"
        try:
            print "make a case so we can add a symptom to it..."

            # get product list for this user
            print "===================================================="
            print "Getting list of products for this user:"******"===================================================="
            print "Getting versions for one of the products:"
            versionAry = product.get_versions()
            self.assertNotEqual(versionAry, None)
            version = versionAry[0]

            # create new case object
            case = self.api.im.makeCase()

            # set required initial fields
            case.product = product.name
            case.version = version
            case.summary = 'This is only a test.'
            case.description = 'This is an automatically generated test case.  Feel free to delete it.'
            case.severity = '3 (Normal)'

            # support level and case group are a little hard to set directly, so skip them

            print "===================================================="
            print "Creating a case that looks like this:"
            print case.toXml()
            print "----------------------------------------------------"
            doc = self.api.cases.add(case)

            print "===================================================="
            print "Getting our newly created case:"
            newdoc = self.api.cases.get(doc.caseNumber)
            print "----------------------------------------------------"
            print "Which looks like this:"
            print newdoc.toXml()

            print "===================================================="
            print "Adding a symptom to our newly created case:"
            # create new symptom object
            sym = self.api.im.makeSymptom(caseNumber=doc.caseNumber,
                                          summary='SUMMARY', category='CPP',
                                          uri='URI', description='DES',
                                          data='TRACE', location='LOC')

            print sym.toXml()

            print "----------------------------------------------------------------------"
            sym = self.api.symptoms.add(sym)
            print sym.location
            self.assertNotEqual(sym.location, None,)

        except RequestError, re:
            self.fail("Unable to connect to support services API.  Reason:  %s %s" % (re.status, re.reason))
        except ConnectionError:
            self.fail("Problem connecting to the support services API.  Is the service accessible from this host?")
def _make_api():
    cfg = confighelper.get_config_helper()

    logger.log(logging.DEBUG, 'user(%s)' % cfg.get(option='user'))
    logger.log(logging.DEBUG, 'proxy_url(%s)' % cfg.get(option='proxy_url'))
    logger.log(logging.DEBUG, 'proxy_user(%s)' % cfg.get(option='proxy_user'))
    '''
    logger.log(logging.DEBUG, 'password(%s)' % cfg.pw_decode(cfg.get(option='password'),
                                                             cfg.get(option='user')))
    logger.log(logging.DEBUG, 'proxy_password(%s)' % cfg.pw_decode(
                                                     cfg.get(option='proxy_password'),
                                                     cfg.get(option='proxy_user')))
    '''
    global _api
    if not _api:
        try:
            url = cfg.get(option='url')
            user = cfg.get(option='user')
            passwd = cfg.pw_decode(cfg.get(option='password'),
                                   cfg.get(option='user'))

            # ensure we have a userid
            if user == None or user == '':
                user = cfg.prompt_for_user()

            # ensure we have a password
            if passwd == None or passwd == '':
                passwd = cfg.prompt_for_password()

            if cfg.get(option='no_verify_ssl'):
                no_verify_ssl = True
            else:
                no_verify_ssl = False

            ssl_ca = cfg.get(option='ssl_ca')

            if url:
                _api = API(username=cfg.get(option='user'),
                           password=cfg.pw_decode(cfg.get(option='password'),
                                                  cfg.get(option='user')),
                           url=url,
                           proxy_url=cfg.get(option='proxy_url'),
                           proxy_user=cfg.get(option='proxy_user'),
                           proxy_pass=cfg.pw_decode(
                               cfg.get(option='proxy_password'),
                               cfg.get(option='proxy_user')),
                           userAgent=USER_AGENT,
                           no_verify_ssl=no_verify_ssl,
                           ssl_ca=ssl_ca)
            else:
                _api = API(username=cfg.get(option='user'),
                           password=cfg.pw_decode(cfg.get(option='password'),
                                                  cfg.get(option='user')),
                           proxy_url=cfg.get(option='proxy_url'),
                           proxy_user=cfg.get(option='proxy_user'),
                           proxy_pass=cfg.pw_decode(
                               cfg.get(option='proxy_password'),
                               cfg.get(option='proxy_user')),
                           userAgent=USER_AGENT,
                           no_verify_ssl=no_verify_ssl,
                           ssl_ca=ssl_ca)
        except:
            # Ideally we could just get rid of this try: except: block as it
            # does absolutely nothing!
            raise
    return _api
class attachmentTest(unittest.TestCase):

    def setUp(self):
        print ""
        print "*********************************************************************"
        print "*********************************************************************"
        print "*********************************************************************"

        self.config = ConfigParser.ConfigParser()
        self.config.read('strata.cfg')
        self.user = self.config.get('strata', 'external_username')
        if (self.user.startswith('$')):
            self.user = os.environ.get(self.user[1:])
            print "Username: "******"Username: %s" % self.user)

        self.passwd = self.config.get('strata', 'external_password')
        if (self.passwd.startswith('$')):
            self.passwd = os.environ.get(self.passwd[1:])
            logging.log(5, "password: %s" % self.passwd)

        self.url = self.config.get('strata', 'url')
        if (self.url.startswith('$')):
            self.url = os.environ.get(self.url[1:])
            print "url: ", self.url

        self.api = API(username=self.user,
                       password=self.passwd,
                       url=self.url,
                       no_verify_ssl=True)

    def tearDown(self):
        self.api.disconnect()

    def testFilterAttachments(self):
        print "---testFilterAttachments---"

        try:
            # create a new case and add an attachment upon which to filtereth

            print "make a case so we can add an attachment to it..."

            # get product list for this user
            print "===================================================="
            print "Getting list of products for this user:"******"===================================================="
            print "Getting versions for one of the products:"
            versionAry = product.get_versions()
            self.assertNotEqual(versionAry, None)
            version = versionAry[0]

            # create new case object
            case = self.api.im.makeCase()

            # set required initial fields
            case.product = product.name
            case.version = version
            case.summary = 'This is only a test.'
            case.description = 'This is an automatically generated test case.  Feel free to delete it.'
            case.severity = '3 (Normal)'

            # support level and case group are a little hard to set directly, so skip them

            print "===================================================="
            print "Creating a case that looks like this:"
            print case.toXml()
            print "----------------------------------------------------"
            doc = self.api.cases.add(case)
            caseNumber = doc.caseNumber

            print "===================================================="
            print "Getting our newly created case:"
            newdoc = self.api.cases.get(caseNumber)
            print "----------------------------------------------------"
            print "Which looks like this:"
            print newdoc.toXml()

            print "===================================================="
            print "Attach a file to our pretty new case..."

            aFile = "attachmentTest.py"
            public = True
            description = "A description of the file."

            resp = self.api.attachments.add(caseNumber=caseNumber,
                                            public=public,
                                            fileName=aFile,
                                            description=description)

            uuid = resp.uuid

            print "===================================================="
            print "Search for our attachment..."

            aAry = self.api.attachments.list(caseNumber=doc.caseNumber,
                                             uuid=uuid)
            assert aAry is not None

            print "----------------------------------------------------"
            for a in aAry:
                print "Found the following attachment:"
                print a.toXml()
                self.assertEqual(a.description, description)
                self.assertEqual(a.uuid, uuid)

            # try to clean up after ourselves
            print "===================================================="
            print "Everything looks ok so clean up after ourselves..."
            newdoc.status = 'Closed'
            newdoc.update()

        except RequestError, re:
            self.fail("Unable to connect to support services API.  Reason: %s %s" % (re.status, re.reason))
        except ConnectionError:
            self.fail("Problem connecting to the support services API.  Is the service accessible from this host?")
class caseTest(unittest.TestCase):

    def setUp(self):
        print ""
        print "*********************************************************************"
        print "*********************************************************************"
        print "*********************************************************************"
        self.config = ConfigParser.ConfigParser()
        self.config.read('strata.cfg')

        self.user = self.config.get('strata', 'external_username')
        if (self.user.startswith('$')):
            self.user = os.environ.get(self.user[1:])
            print "Username: "******"Username: %s" % self.user)

        self.passwd = self.config.get('strata', 'external_password')
        if (self.passwd.startswith('$')):
            self.passwd = os.environ.get(self.passwd[1:])
            logging.log(5, "password: %s" % self.passwd)

        self.url = self.config.get('strata', 'url')
        if (self.url.startswith('$')):
            self.url = os.environ.get(self.url[1:])
            print "url: ", self.url

        self.api = API(username=self.user,
                       password=self.passwd,
                       url=self.url,
                       no_verify_ssl=True)


    def tearDown(self):
        self.api.disconnect();


    def testAddGetCase(self):
        print "---testAddGetCase---"

        try:
            # get product list for this user
            print "===================================================="
            print "Getting list of products for this user:"******"===================================================="
            print "Getting versions for one of the products:"
            versionAry = product.get_versions()
            self.assertNotEqual(versionAry, None)
            version = versionAry[0]

            # create new case object
            case = self.api.im.makeCase()

            # set required initial fields
            case.product = product.name
            case.version = version
            case.summary = 'This is only a test.'
            case.description = 'This is an automatically generated test case.  Feel free to delete it.'
            case.severity = '3 (Normal)'

            # support level and case group are a little hard to set directly, so skip them

            print "===================================================="
            print "Creating a case that looks like this:"
            print case.toXml()
            print "----------------------------------------------------"
            doc = self.api.cases.add(case)

            print "===================================================="
            print "Getting our newly created case:"
            newdoc = self.api.cases.get(doc.caseNumber)
            print "----------------------------------------------------"
            print "Which looks like this:"
            print newdoc.toXml()

            # Verify fields in new case are sane
            print "===================================================="
            print "Verifying a bunch of stuff..."
            self.assertEqual(newdoc.caseNumber, doc.caseNumber)
            self.assertEqual(newdoc.product, product.name)
            self.assertEqual(newdoc.version, version)
            self.assertEqual(newdoc.summary, 'This is only a test.')
            self.assertEqual(newdoc.description, 'This is an automatically generated test case.  Feel free to delete it.')
            self.assertEqual(newdoc.severity, '3 (Normal)')

            self.assertEqual(newdoc.closed, False)
            self.assertEqual(newdoc.escalated, False)
            self.assertEqual(newdoc.uri, self.url + '/rs/cases/' + doc.caseNumber)
            self.assertEqual(newdoc.status, 'Waiting on Red Hat')

            # try to clean up after ourselves
            print "Everything looks fine, so close the case we created:"
            newdoc.status = 'Closed'
            newdoc.update();

        except RequestError, re:
            self.fail("Unable to connect to support services API.  Reason:  %s %s" % (re.status, re.reason))
        except ConnectionError:
            self.fail("Problem connecting to the support services API.  Is the service accessible from this host?")
class commentTest(unittest.TestCase):

    def setUp(self):
        print ""
        print "*********************************************************************"
        print "*********************************************************************"
        print "*********************************************************************"

        self.config = ConfigParser.ConfigParser()
        self.config.read('strata.cfg')
        self.user = self.config.get('strata', 'external_username')
        if (self.user.startswith('$')):
            self.user = os.environ.get(self.user[1:])
            print "Username: "******"Username: %s" % self.user)

        self.passwd = self.config.get('strata', 'external_password')
        if (self.passwd.startswith('$')):
            self.passwd = os.environ.get(self.passwd[1:])
            logging.log(5, "password: %s" % self.passwd)

        self.url = self.config.get('strata', 'url')
        if (self.url.startswith('$')):
            self.url = os.environ.get(self.url[1:])
            print "url: ", self.url

        self.api = API(username=self.user,
                       password=self.passwd,
                       url=self.url,
                       no_verify_ssl=True)


    def tearDown(self):
        self.api.disconnect();


    def testGetOtherComment(self):
        print "--- testGetOtherComment ---"
        print "Checking to see if we can retrieve comments from cases that are not visible to us..."
        try:
            # create a sparse case so we'll have a case number that is guaranteed to be valid for this user
            print "Creating a sparse case..."
            print "Getting list of products for this user:"******"===================================================="
            print "Getting versions for one of the products:"
            versionAry = product.get_versions()
            self.assertNotEqual(versionAry, None)
            version = versionAry[0]

            # create new case object
            case = self.api.im.makeCase()

            # set required initial fields
            case.product = product.name
            case.version = version
            case.summary = 'This is only a test.'
            case.description = 'This is an automatically generated test case.  Feel free to delete it.'
            case.severity = '3 (Normal)'

            # support level and case group are a little hard to set directly, so skip them

            print "===================================================="
            print "Creating a case that looks like this:"
            print case.toXml()
            print "----------------------------------------------------"
            doc = self.api.cases.add(case)
            caseNumber = doc.caseNumber

            cmnt = self.api.comments.get(caseNumber=caseNumber,
                                         commentID="a0aA0000007vrRfIAI")  # this is a real comment from a live case
            print "Retrieved comment:"
            print cmnt.toXml()

            if cmnt == None or cmnt.id == None:
                success = True
            else:
                success = False

            # try to clean up after ourselves
            print "===================================================="
            print "Clean up after ourselves..."
            doc.status = 'Closed'
            doc.update();

            if success == False:
                self.fail("Should not have been able to retrieve comment!")

        except RequestError, re:
            print "Attempt was not successful (as it should not be.)"
            print "Clean up after ourselves..."
            doc.status = 'Closed'
            doc.update();

        except ConnectionError:
            self.fail("Problem connecting to the support services API.  Is the service accessible from this host?")
class articleTest(unittest.TestCase):

    def setUp(self):
        print ""
        print "*********************************************************************"
        print "*********************************************************************"
        print "*********************************************************************"
        self.config = ConfigParser.ConfigParser()
        self.config.read('strata.cfg')
        self.user = self.config.get('strata', 'internal_username')
        if (self.user.startswith('$')):
            self.user = os.environ.get(self.user[1:])
            print "Username: "******"Username: %s" % self.user)

        self.passwd = self.config.get('strata', 'internal_password')
        if (self.passwd.startswith('$')):
            self.passwd = os.environ.get(self.passwd[1:])
            logging.log(5, "password: %s" % self.passwd)

        self.url = self.config.get('strata', 'url')
        if (self.url.startswith('$')):
            self.url = os.environ.get(self.url[1:])
            print "url: ", self.url

        self.api = API(username=self.user,
                       password=self.passwd,
                       url=self.url,
                       no_verify_ssl=True)


    def tearDown(self):
        self.api.disconnect()


    def testAddGetUpdateArticle(self):
        print " *******  testAddGetUpdateArticle *******"
        try:
            print "Create a new article object..."
            art = self.api.im.makeArticle(createdBy='rhn-support-cbredese',
                                          title='Pyunit REST API TC for Articles',
                                          summary="Summary text here",
                                          kcsState='wip',
                                          body='Body text here')

            self.assertNotEqual(art, None)

            print "which looks like this:"
            print art.toXml()

            print "===================================================="
            print "Add the article via strata..."
            doc = self.api.articles.add(art)

            self.assertNotEqual(doc, None)
            self.assert_(doc.get_id() is not None, doc)

            print "===================================================="
            print "Get the article we just created..."
            art = self.api.articles.get(doc.id)

            self.assertNotEqual(art, None)

            print "----------------------------------------------------"
            print "which looks like this:"
            print art.toXml()

            print "===================================================="
            print "Update the article..."

            new_text = 'Updated resolution text'
            art.set_body(new_text)

            print "WHich now looks like this:"
            print art.toXml()

            self.assertEqual(art.get_body(), new_text)
            art.update()

        except RequestError, re:
            self.fail("Unable to connect to support services API.  Reason:  %s %s" % (re.status, re.reason))
        except ConnectionError:
            self.fail("Problem connecting to the support services API.  Is the service accessible from this host?")