From 8331efae8dc7f432267c7f7b96062af8a4cd5a59 Mon Sep 17 00:00:00 2001 From: Rich Ellis Date: Wed, 19 Feb 2020 15:21:05 +0000 Subject: [PATCH] Fixed invalid DB name test The HEAD on an invalid DB name that doesn't exist returns a 400 in 1.7.2 but a 404 in 1.7.1 and 2.x --- tests/unit/client_tests.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/unit/client_tests.py b/tests/unit/client_tests.py index f3ac4e76..2726de33 100644 --- a/tests/unit/client_tests.py +++ b/tests/unit/client_tests.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright (C) 2015, 2019 IBM Corp. All rights reserved. +# Copyright (C) 2015, 2020 IBM Corp. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -405,9 +405,10 @@ def test_create_invalid_database_name(self): """ dbname = 'invalidDbName_' self.client.connect() - with self.assertRaises(CloudantDatabaseException) as cm: + with self.assertRaises((CloudantDatabaseException, HTTPError)) as cm: self.client.create_database(dbname) - self.assertEqual(cm.exception.status_code, 400) + code = cm.exception.status_code if hasattr(cm.exception, 'status_code') else cm.exception.response.status_code + self.assertEqual(code, 400) self.client.disconnect() @skip_if_not_cookie_auth