public inbox for [email protected]
help / color / mirror / Atom feedFrom: Priyanka Shendge <[email protected]>
To: Dave Page <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Cc: Kanchan Mohitey <[email protected]>
Subject: Re: pgAdmin IV API test cases patch
Date: Tue, 5 Jul 2016 13:30:17 +0530
Message-ID: <CAKmZXFRfZ6Y0eJK8k1FdvWX_V6A8bCdxJzBuWaJ0-nRWDsaOQA@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CAKmZXFQ2Hj1-OZpSGFEBB-vOypQ_=1b4Yr_VytZ-E1=CBw9Yhw@mail.gmail.com>
<CA+OCxow8Q83e7Tm+BC2bxq=oqwd-m4JS3y2KpzgFemc=wX=f=A@mail.gmail.com>
<CAKmZXFTX9D_qOXGrvPa9sfFjc1A6VPebcpBn7vyzPEOH4pWfEg@mail.gmail.com>
<CAKmZXFRj8yY91TTxwQQ01eOQE8Rc7FPWuxGcjxaVY+QcWpgWDg@mail.gmail.com>
<CA+OCxoyqfK8pUGGmeO=5pyC=MOizNMOnfshAfgQ5NjMRnkjgmA@mail.gmail.com>
<CAKmZXFSgdtd9NDE=TysR68_tcwqFB2Sv-h+qK4K4i1HjxOd5ng@mail.gmail.com>
<CAKmZXFRWXd7ZrUhpJt-rD_YOE1xcK5haE1CwAj8DMVyS9Fs6yA@mail.gmail.com>
<CA+OCxoyiNMAem5bYAZ1XM16vK4wJETCCPncRgKYbVdmH2m4Ocg@mail.gmail.com>
<CAKmZXFRvn8JDL52ooxZYtrf0Aw+bMz6=spXmyP9Q7fq8kWjuDA@mail.gmail.com>
<CA+OCxowzMWyATh1_eEQ7hnrseaxuq8T3_+FDsCETLm=WaoRNEw@mail.gmail.com>
<CAKmZXFT34JxCPw=UbZ27jU8uL0KzFa3Lfpmge2V14F7GynGLWw@mail.gmail.com>
<CAKmZXFRfX+Us9Bg2ACFGvGLTjjW02XETLEj3h5cHnZZBAbZwEQ@mail.gmail.com>
<CA+OCxow+V_RU2y1q07R07UzZOmxLh+3WouSpwMXkYiz4v_V=qw@mail.gmail.com>
<CAKmZXFTSYiZxVNe6FYkL-eDYk=yzpnLxdotGcek6zmp9f5S41g@mail.gmail.com>
<[email protected]>
List-Unsubscribe: <mailto:[email protected]?body=unsub%20pgadmin-hackers>
Hi Dave,
I tried running the testsuite against PG9.4 and unable to reproduce the
failures.
I have added debug statements to previous patch. Patch attached.
Could you please re-run the same and send me the logs and output?
Thank you.
On 4 July 2016 at 17:30, Dave Page <[email protected]> wrote:
> Hi
>
> The test data was the default, and I ran against PG 9.4. All other logs
> were attached to my previous email.
>
> --
> Dave Page
> Blog: http://pgsnake.blogspot.com
> Twitter: @pgsnake
>
> EnterpriseDB UK:http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
> On 4 Jul 2016, at 12:16, Priyanka Shendge <
> [email protected]> wrote:
>
> Hi Dave,
>
> I am unable to reproduce issue on my side; tried on Python 2.7 and Python
> 3.4.
> Could you please provide me DEBUG logs and test data using for database
> node?
>
> Thank you.
>
> On 30 June 2016 at 00:51, Dave Page <[email protected]> wrote:
>
>> Hi,
>>
>> That's better. I tweaked a few things and fixed a bug related to
>> recent changes to the schema version config. Patch attached.
>>
>> However, there are still issues:
>>
>> 1) The testsuite doesn't run to completion. See the attached
>> stdout.txt and logger.txt files.
>> 2) stdout should only display the test summary - what tests are
>> currently running (and pass/fail), and a summary at the end - even if
>> there's a crash like I saw.
>> 3) The output log file should contain the full output, including
>> what's sent to stdout.
>> 4) The output advises the user to check ".../pgadmin4/web/regression".
>> This should be in the summary at the end, and should be corrected to
>> show the correct (full) path.
>>
>> Thanks.
>>
>>
>> On Wed, Jun 29, 2016 at 2:52 PM, Priyanka Shendge
>> <[email protected]> wrote:
>> > Hi Dave,
>> >
>> > As per discussion over mail i have created separate config files for
>> > credentials and test data.
>> >
>> > PFA patch for same. Kindly, review and let me know for modifications.
>> >
>> > On 27 June 2016 at 15:10, Priyanka Shendge
>> > <[email protected]> wrote:
>> >>
>> >>
>> >>
>> >> On 27 June 2016 at 13:24, Dave Page <[email protected]> wrote:
>> >>>
>> >>> On Sun, Jun 26, 2016 at 12:05 PM, Priyanka Shendge
>> >>> <[email protected]> wrote:
>> >>> >
>> >>> >
>> >>> > On 24 June 2016 at 16:17, Dave Page <[email protected]> wrote:
>> >>> >>
>> >>> >> Hi
>> >>> >>
>> >>> >> On Thu, Jun 23, 2016 at 2:41 PM, Priyanka Shendge
>> >>> >> <[email protected]> wrote:
>> >>> >> >
>> >>> >> >
>> >>> >> > On 15 June 2016 at 15:05, Priyanka Shendge
>> >>> >> > <[email protected]> wrote:
>> >>> >> >>
>> >>> >> >> Thanks a lot Dave.
>> >>> >> >>
>> >>> >> >> On 15 June 2016 at 14:09, Dave Page <[email protected]> wrote:
>> >>> >> >>>
>> >>> >> >>> Hi
>> >>> >> >>>
>> >>> >> >>> On Thu, Jun 9, 2016 at 1:37 PM, Priyanka Shendge
>> >>> >> >>> <[email protected]> wrote:
>> >>> >> >>> > Hi Dave,
>> >>> >> >>> >
>> >>> >> >>> > PFA updated patch. I have made changes suggested by you.
>> >>> >> >>> >
>> >>> >> >>> > Kindly, review and let me know for more changes.
>> >>> >> >>>
>> >>> >> >>> OK, I got a bit further this time, but not there yet.
>> >>> >> >>>
>> >>> >> >>> 1) The patch overwrote my test_config.json file. That should
>> never
>> >>> >> >>> happen (that file shouldn't be in the source tree).
>> >>> >> >>> test_config.json.in should be the file that's included in the
>> >>> >> >>> patch.
>> >>> >> >>
>> >>> >> >>
>> >>> >> >> OK.
>> >>> >> >>>
>> >>> >> >>>
>> >>> >> >>> 2) The updated test_config.json file is huge.
>> >>> >> >
>> >>> >> >
>> >>> >> > Current configuration file web/regression/test_config.json
>> contains
>> >>> >> > test
>> >>> >> > data(credentials) for each tree node;
>> >>> >> > which is used while adding and updating the respective node.
>> >>> >>
>> >>> >> Why would we need that?
>> >>> >
>> >>> >
>> >>> > Each node file (e.g. test_db_add.py and test_db_put.py) uses
>> respective
>> >>> > credentials test data from
>> >>> > test_config.json while execution.
>> >>>
>> >>> That doesn't answer my question - why do we need separate credentials
>> >>> for each node?
>> >>
>> >>
>> >> Sorry for typo, its test data not credentials.
>> >>
>> >>>
>> >>>
>> >>> >> We should have just one set of credentials for
>> >>> >> everything.
>> >>> >
>> >>> >
>> >>> > Let me know if my understanding is clear:
>> >>> >
>> >>> > Should i keep basic credentials of each node (database, schema) into
>> >>> > test_config.json
>> >>> > instead taking care of each field?
>> >>>
>> >>> You should have one set of credentials that's used for the entire test
>> >>> run.
>> >>
>> >>
>> >> Sure. I'll separate the credentials and test data into 2 different
>> files.
>> >> So, a normal user can run the tests into one go after some minor
>> >> credentials changes.
>> >> And an advanced user can have an option to change the test data if he
>> >> wants.
>> >>>
>> >>>
>> >>> >> >>> I should only need to
>> >>> >> >>> define one or more connections, then be able to run the tests.
>> If
>> >>> >> >>> you
>> >>> >> >>> need to keep configuration info for "advanced users", let's
>> put it
>> >>> >> >>> in
>> >>> >> >>> a different file to avoid confusing/scaring everyone else.
>> Maybe
>> >>> >> >>> split
>> >>> >> >>> it into config.json for the stuff the user needs to edit
>> >>> >> >>> (config.json.in would go in git), and test_config.json for the
>> >>> >> >>> test
>> >>> >> >>> configuration.
>> >>> >> >
>> >>> >> >
>> >>> >> > Should i keep login and server credentials into
>> >>> >> > web/regression/test_config.json file and
>> >>> >> > put respective node details into config.json file of respective
>> >>> >> > node's
>> >>> >> > tests
>> >>> >> > directory?
>> >>> >>
>> >>> >> Not if you expect users to need to edit them - and if not, why are
>> the
>> >>> >> values not just hard-coded?
>> >>> >>
>> >>> >> > e.g. for database node:
>> >>> >> > I'll create config.json file into .../databases/tests/ directory
>> >>> >> > put database add and update credentials into config.json
>> >>> >>
>> >>> >> The key here is to make it simple for users.
>> >>> >>
>> >>> >> - To run the default tests, they should be able to copy/edit a
>> simple
>> >>> >> file, and just add database server details for the server to run
>> >>> >> against.
>> >>> >>
>> >>> >> - If we have configurable tests (because making them configurable
>> adds
>> >>> >> genuine value), then we can use an "advanced" config file to allow
>> the
>> >>> >> user to adjust settings as they want.
>> >>> >>
>> >>> >> In the simple case, the user should be able to run the tests
>> >>> >> successfully within a minute or two from starting.
>> >>> >>
>> >>> >> In designing the layout for files etc, remember the following:
>> >>> >>
>> >>> >> - Users should never edit a file that is in our source control.
>> That's
>> >>> >> why we have .in files that we expect them to copy.
>> >>> >>
>> >>> >> - Unless they're an advanced user, they shouldn't need to copy the
>> >>> >> config file for advanced options. That means that the tests should
>> >>> >> have defaults that match what is in the template advanced config
>> file
>> >>> >> (or, the tests could read advanced.json.in if advanced.json
>> doesn't
>> >>> >> exist, though that does seem a little icky). Of course, those are
>> >>> >> example filenames, not necessarily what you may choose.
>> >>> >>
>> >>> >> --
>> >>> >> Dave Page
>> >>> >> Blog: http://pgsnake.blogspot.com
>> >>> >> Twitter: @pgsnake
>> >>> >>
>> >>> >> EnterpriseDB UK: http://www.enterprisedb.com
>> >>> >> The Enterprise PostgreSQL Company
>> >>> >
>> >>> >
>> >>> >
>> >>> >
>> >>> > --
>> >>> > Best,
>> >>> > Priyanka
>> >>> >
>> >>> > EnterpriseDB Corporation
>> >>> > The Enterprise PostgreSQL Company
>> >>>
>> >>>
>> >>>
>> >>> --
>> >>> Dave Page
>> >>> Blog: http://pgsnake.blogspot.com
>> >>> Twitter: @pgsnake
>> >>>
>> >>> EnterpriseDB UK: http://www.enterprisedb.com
>> >>> The Enterprise PostgreSQL Company
>> >>>
>> >>>
>> >>> --
>> >>> Sent via pgadmin-hackers mailing list ([email protected]
>> )
>> >>> To make changes to your subscription:
>> >>> http://www.postgresql.org/mailpref/pgadmin-hackers
>> >>
>> >>
>> >>
>> >>
>> >> --
>> >> Best,
>> >> Priyanka
>> >>
>> >> EnterpriseDB Corporation
>> >> The Enterprise PostgreSQL Company
>> >
>> >
>> >
>> >
>> > --
>> > Best,
>> > Priyanka
>> >
>> > EnterpriseDB Corporation
>> > The Enterprise PostgreSQL Company
>>
>>
>>
>> --
>> Dave Page
>> Blog: http://pgsnake.blogspot.com
>> Twitter: @pgsnake
>>
>> EnterpriseDB UK: http://www.enterprisedb.com
>> The Enterprise PostgreSQL Company
>>
>
>
>
> --
> Best,
> Priyanka
>
> EnterpriseDB Corporation
> The Enterprise PostgreSQL Company
>
>
--
Best,
Priyanka
EnterpriseDB Corporation
The Enterprise PostgreSQL Company
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers
Attachments:
[application/octet-stream] pgadmin_api_debug.patch (35.8K, 3-pgadmin_api_debug.patch)
download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/tests/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/tests/__init__.py
new file mode 100644
index 0000000..60ed4c7
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/tests/__init__.py
@@ -0,0 +1,16 @@
+# ##########################################################################
+#
+# #pgAdmin 4 - PostgreSQL Tools
+#
+# #Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# #This software is released under the PostgreSQL Licence
+#
+# ##########################################################################
+
+from pgadmin.utils.route import BaseTestGenerator
+
+
+class DatabaseGenerateTestCase(BaseTestGenerator):
+
+ def runTest(self):
+ return
diff --git a/web/pgadmin/browser/server_groups/servers/databases/tests/test_db_add.py b/web/pgadmin/browser/server_groups/servers/databases/tests/test_db_add.py
new file mode 100644
index 0000000..8bbe9b2
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/tests/test_db_add.py
@@ -0,0 +1,102 @@
+# #################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+# ##################################################################
+
+from regression.config import config_data, advance_config_data, pickle_path
+from pgadmin.browser.tests.test_login import LoginTestCase
+import json
+import pickle
+import uuid
+import os
+from regression.test_utils import get_ids
+
+
+class DatabaseAddTestCase(LoginTestCase):
+ """
+ This class will check server group node present on the object browser's
+ tree node by response code.
+ """
+ priority = 7
+
+ scenarios = [
+ # Fetching default URL for database node.
+ ('Check Databases Node URL', dict(url='/browser/database/obj/'))
+ ]
+
+ def runTest(self):
+ """ This function will add database under 1st server of tree node. """
+
+ srv_id = get_ids()
+
+ server_id = srv_id["sid"][0]
+ srv_grp = config_data['test_server_group']
+
+ response = self.tester.post('browser/server/connect/' + str(srv_grp) +
+ '/' + server_id,
+ data=dict(
+ password=config_data
+ ['test_server_credentials'][0]
+ ['test_db_password']),
+ follow_redirects=True)
+
+ self.assertEquals(response.status_code, 200)
+
+ srv_connect = json.loads(response.data.decode())
+
+ if srv_connect['data']['connected']:
+
+ data = {
+ "datacl": advance_config_data['test_add_database_data']
+ ['test_privileges_acl'],
+ "datconnlimit": advance_config_data
+ ['test_add_database_data']['test_conn_limit'],
+ "datowner": advance_config_data
+ ['test_add_database_data']['test_owner'],
+ "deffuncacl": advance_config_data
+ ['test_add_database_data']['test_fun_acl'],
+ "defseqacl": advance_config_data
+ ['test_add_database_data']['test_seq_acl'],
+ "deftblacl": advance_config_data
+ ['test_add_database_data']['test_tbl_acl'],
+ "deftypeacl": advance_config_data
+ ['test_add_database_data']['test_type_acl'],
+ "encoding": advance_config_data
+ ['test_add_database_data']['test_encoding'],
+ "name": str(uuid.uuid4())[1:8],
+ "privileges": advance_config_data
+ ['test_add_database_data']['test_privileges'],
+ "securities": advance_config_data
+ ['test_add_database_data']['test_securities'],
+ "variables": advance_config_data
+ ['test_add_database_data']['test_variables']
+ }
+
+ db_response = self.tester.post(self.url + str(srv_grp) + "/" +
+ server_id + "/",
+ data=json.dumps(data),
+ content_type='html/json')
+
+ self.assertTrue(db_response.status_code, 200)
+
+ respdata = json.loads(db_response.data.decode())
+
+ db_id = respdata['node']['_id']
+
+ if os.path.isfile(pickle_path):
+
+ exst_server_id = open(pickle_path, 'rb')
+
+ tol_server_id = pickle.load(exst_server_id)
+ pickle_id_dict = tol_server_id
+
+ pickle_id_dict["did"].append(db_id)
+ print("\ndb id in db add", pickle_id_dict["did"][0])
+
+ db_output = open(pickle_path, 'wb')
+ pickle.dump(pickle_id_dict, db_output)
+ db_output.close()
diff --git a/web/pgadmin/browser/server_groups/servers/databases/tests/test_db_delete.py b/web/pgadmin/browser/server_groups/servers/databases/tests/test_db_delete.py
new file mode 100644
index 0000000..d0fc93d
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/tests/test_db_delete.py
@@ -0,0 +1,48 @@
+# #################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+# ##################################################################
+
+from regression.config import config_data
+from pgadmin.browser.tests.test_login import LoginTestCase
+import json
+from regression.test_nodes import test_getnodes
+from regression.test_utils import get_ids
+
+
+class DatabaseDeleteTestCase(LoginTestCase):
+ """ This class will delete the database under last added server. """
+
+ priority = 98
+
+ scenarios = [
+ # Fetching default URL for database node.
+ ('Check Databases Node URL', dict(url='/browser/database/obj/'))
+ ]
+
+ def runTest(self):
+ """ This function will delete the added database."""
+
+ all_id = get_ids()
+ server_id = all_id["sid"][0]
+ db_id = all_id["did"][0]
+ print("\ndb id in delete database:", db_id)
+
+ srv_grp = config_data['test_server_group']
+
+ db_con = test_getnodes(node=self)
+
+ if len(db_con) == 0:
+ raise Exception("No database(s) to delete.")
+
+ response = self.tester.delete(self.url + str(srv_grp) + '/' +
+ str(server_id) + '/' + str(db_id),
+ follow_redirects=True)
+
+ respdata = json.loads(response.data.decode())
+ print("database delete response", respdata)
+ self.assertTrue(respdata['success'], 1)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/tests/test_db_get.py b/web/pgadmin/browser/server_groups/servers/databases/tests/test_db_get.py
new file mode 100644
index 0000000..984a99e
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/tests/test_db_get.py
@@ -0,0 +1,46 @@
+# #################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+# ##################################################################
+
+from regression.config import config_data
+from pgadmin.browser.tests.test_login import LoginTestCase
+from regression.test_nodes import test_getnodes
+from regression.test_utils import get_ids
+
+
+class DatabasesGetTestCase(LoginTestCase):
+ """
+ This class will fetch added database under server node.
+ """
+ priority = 8
+
+ scenarios = [
+ # Fetching default URL for database node.
+ ('Check Databases Node URL', dict(url='/browser/database/obj/'))
+ ]
+
+ def runTest(self):
+ """ This function will fetch added database. """
+
+ all_id = get_ids()
+ server_id = all_id["sid"][0]
+ db_id = all_id["did"][0]
+ print("\ndb id in get database:", db_id)
+
+ srv_grp = config_data['test_server_group']
+
+ db_con = test_getnodes(node=self)
+
+ if db_con['data']["connected"]:
+
+ response = self.tester.get(self.url + str(srv_grp) + '/' +
+ str(server_id) + '/' + str(db_id),
+ follow_redirects=True)
+ print("database get response", response.data.decode())
+
+ self.assertEquals(response.status_code, 200)
diff --git a/web/pgadmin/browser/server_groups/servers/databases/tests/test_db_put.py b/web/pgadmin/browser/server_groups/servers/databases/tests/test_db_put.py
new file mode 100644
index 0000000..3d9f867
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/servers/databases/tests/test_db_put.py
@@ -0,0 +1,55 @@
+# #################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+# ##################################################################
+
+from regression.config import config_data, advance_config_data
+from pgadmin.browser.tests.test_login import LoginTestCase
+import json
+from regression.test_utils import get_ids
+from regression.test_nodes import test_getnodes
+
+
+class DatabasesUpdateTestCase(LoginTestCase):
+ """
+ This class will update the database under last added server.
+ """
+ priority = 9
+
+ scenarios = [
+ # Fetching default URL for database node.
+ ('Check Databases Node', dict(url='/browser/database/obj/'))
+ ]
+
+ def runTest(self):
+ """ This function will update the comments field of database."""
+
+ all_id = get_ids()
+ server_id = all_id["sid"][0]
+ db_id = all_id["did"][0]
+ print("\ndb id in update database:", db_id)
+
+ srv_grp = config_data['test_server_group']
+
+ db_con = test_getnodes(node=self)
+
+ if db_con['data']["connected"]:
+
+ data = {
+ "comments": advance_config_data["test_db_update_data"]
+ ["test_comment"],
+ "id": db_id
+ }
+
+ put_response = self.tester.put(self.url + str(srv_grp) + '/' +
+ str(server_id) + '/' + str(db_id),
+ data=json.dumps(data),
+ follow_redirects=True)
+ print("database put response", put_response.data.decode())
+
+
+ self.assertEquals(put_response.status_code, 200)
diff --git a/web/pgadmin/browser/server_groups/servers/tests/__init__.py b/web/pgadmin/browser/server_groups/servers/tests/__init__.py
index 28cdb94..4fd2066 100644
--- a/web/pgadmin/browser/server_groups/servers/tests/__init__.py
+++ b/web/pgadmin/browser/server_groups/servers/tests/__init__.py
@@ -12,4 +12,4 @@ from pgadmin.utils.route import BaseTestGenerator
class ServerGenerateTestCase(BaseTestGenerator):
def runTest(self):
- print ("In ServerGenerateTestCase...")
+ return
diff --git a/web/pgadmin/browser/server_groups/servers/tests/test_server_add.py b/web/pgadmin/browser/server_groups/servers/tests/test_server_add.py
index 0af13d3..499c0a0 100644
--- a/web/pgadmin/browser/server_groups/servers/tests/test_server_add.py
+++ b/web/pgadmin/browser/server_groups/servers/tests/test_server_add.py
@@ -8,16 +8,14 @@
# ##########################################################################
import json
-
+import pickle
+import os
from pgadmin.browser.tests.test_login import LoginTestCase
-from regression.config import config_data
+from regression.config import config_data, pickle_path
class ServersAddTestCase(LoginTestCase):
- """
- This class will add the servers under default server group and verify with
- server's name.
- """
+ """ This class will add the servers under default server group. """
priority = 4
@@ -27,14 +25,19 @@ class ServersAddTestCase(LoginTestCase):
]
def runTest(self):
- """
- This function will add the server under default server group.
- Verify the added server with response code as well as server name.
- """
+ """ This function will add the server under default server group."""
+
+ # Storing parent id's into pickle dict
+ pickle_id_dict = \
+ {
+ "sid": [], # server
+ "did": [] # database
+ }
srv_grp = config_data['test_server_group']
for srv in config_data['test_server_credentials']:
+
data = {"name": srv['test_name'],
"comment": "",
"host": srv['test_host'],
@@ -44,10 +47,22 @@ class ServersAddTestCase(LoginTestCase):
"role": "",
"sslmode": srv['test_sslmode']}
- url = self.url + str(srv_grp) + "/"
-
- response = self.tester.post(url, data=json.dumps(data),
+ response = self.tester.post(self.url + str(srv_grp) + "/",
+ data=json.dumps(data),
content_type='html/json')
+
self.assertTrue(response.status_code, 200)
- respdata = json.loads(response.data)
- self.assertTrue(respdata['node']['label'], srv['test_name'])
+ respdata = json.loads(response.data.decode())
+
+ server_id = respdata['node']['_id']
+
+ if os.path.isfile(pickle_path):
+ exst_server_id = open(pickle_path, 'rb')
+ pickle_id_dict = pickle.load(exst_server_id)
+
+ pickle_id_dict["sid"].append(server_id)
+ print("\nServer id in server add", pickle_id_dict["sid"][0])
+
+ output = open(pickle_path, 'wb')
+ pickle.dump(pickle_id_dict, output)
+ output.close()
diff --git a/web/pgadmin/browser/server_groups/servers/tests/test_server_delete.py b/web/pgadmin/browser/server_groups/servers/tests/test_server_delete.py
index 329d74f..997308e 100644
--- a/web/pgadmin/browser/server_groups/servers/tests/test_server_delete.py
+++ b/web/pgadmin/browser/server_groups/servers/tests/test_server_delete.py
@@ -8,17 +8,14 @@
# ##################################################################
import json
-
from pgadmin.browser.tests.test_login import LoginTestCase
from regression.config import config_data
-class ServersDeleteTestCase(LoginTestCase):
- """
- This class will check server node present on the object browser's tree node
- by response code.
- """
- priority = 7
+class ServerDeleteTestCase(LoginTestCase):
+ """ This class will delete the last server present under tree node."""
+
+ priority = 99
scenarios = [
# Fetching the default url for server node
@@ -26,32 +23,22 @@ class ServersDeleteTestCase(LoginTestCase):
]
def runTest(self):
- """
- This function will get all available servers under object browser
- and delete the servers using server id.
- """
+ """ This function will get all available servers under object browser
+ and delete the last server using server id."""
srv_grp = config_data['test_server_group']
- for srv in config_data['test_server_credentials']:
-
- data = {"name": srv['test_name'],
- "host": srv['test_host'],
- "port": srv['test_db_port'],
- "db": srv['test_maintenance_db'],
- "username": srv['test_db_username'],
- "role": "",
- "sslmode": srv['test_sslmode']}
+ url = self.url + str(srv_grp) + "/"
- url = self.url + str(srv_grp) + "/"
+ response = self.tester.get(url)
+ respdata = json.loads(response.data.decode())
- response = self.tester.get(url, data=json.dumps(data),
- content_type='html/json')
- self.assertTrue(response.status_code, 200)
- respdata = json.loads(response.data)
+ if len(respdata) == 0:
+ raise Exception("No server(s) to delete.")
- for server in respdata:
- response = self.tester.delete(url + json.dumps(server['id']))
- self.assertTrue(response.status_code, 200)
- respdata = json.loads(response.data)
- self.assertTrue(respdata['success'], 1)
+ # delete last server
+ server = respdata[-1]
+ response = self.tester.delete(url + str(server['id']))
+ self.assertTrue(response.status_code, 200)
+ respdata = json.loads(response.data.decode())
+ self.assertTrue(respdata['success'], 1)
diff --git a/web/pgadmin/browser/server_groups/servers/tests/test_server_get.py b/web/pgadmin/browser/server_groups/servers/tests/test_server_get.py
index 050843e..163fef3 100644
--- a/web/pgadmin/browser/server_groups/servers/tests/test_server_get.py
+++ b/web/pgadmin/browser/server_groups/servers/tests/test_server_get.py
@@ -7,15 +7,14 @@
#
# ##########################################################################
-import json
-
from pgadmin.browser.tests.test_login import LoginTestCase
from regression.config import config_data
+from regression.test_utils import get_ids
class ServersGetTestCase(LoginTestCase):
"""
- This class will check server node present on the object browser's tree node
+ This class will fetch added servers under default server group
by response code.
"""
@@ -27,23 +26,16 @@ class ServersGetTestCase(LoginTestCase):
]
def runTest(self):
- """
- This function will get all available servers present under
- object browser.
- """
+ """ This function will fetch the added servers to object browser. """
+ all_id = get_ids()
+ server_id = all_id["sid"]
srv_grp = config_data['test_server_group']
- for srv in config_data['test_server_credentials']:
- data = {"name": srv['test_name'],
- "host": srv['test_host'],
- "port": srv['test_db_port'],
- "db": srv['test_maintenance_db'],
- "username": srv['test_db_username'],
- "role": "",
- "sslmode": srv['test_sslmode']}
-
- url = self.url + str(srv_grp) + "/"
- response = self.tester.get(url, data=json.dumps(data),
+ for srv in server_id:
+
+ response = self.tester.get(self.url + str(srv_grp) + '/' +
+ str(srv),
content_type='html/json')
- self.assertTrue(response.status_code, 200)
+
+ self.assertEquals(response.status_code, 200)
diff --git a/web/pgadmin/browser/server_groups/servers/tests/test_server_put.py b/web/pgadmin/browser/server_groups/servers/tests/test_server_put.py
index 306bb03..35d7c03 100644
--- a/web/pgadmin/browser/server_groups/servers/tests/test_server_put.py
+++ b/web/pgadmin/browser/server_groups/servers/tests/test_server_put.py
@@ -8,16 +8,13 @@
# ##########################################################################
import json
-
from pgadmin.browser.tests.test_login import LoginTestCase
from regression.config import config_data
+from regression.test_utils import get_ids
-class ServersUpdateTestCase(LoginTestCase):
- """
- This class will check server node present on the object browser's tree node
- by response code.
- """
+class ServerUpdateTestCase(LoginTestCase):
+ """ This class will update server's comment field. """
priority = 6
@@ -27,39 +24,41 @@ class ServersUpdateTestCase(LoginTestCase):
]
def runTest(self):
- """
- This function will edit and update the server's comment field
- by the server id.
- """
+ """ This function will update the server's comment field. """
+ all_id = get_ids()
+ server_id = all_id["sid"][0]
srv_grp = config_data['test_server_group']
- for srv in config_data['test_server_credentials']:
+ response = self.tester.get(self.url + str(srv_grp) + '/' +
+ str(server_id),
+ follow_redirects=True)
- data = {"name": srv['test_name'],
- "host": srv['test_host'],
- "port": srv['test_db_port'],
- "db": srv['test_maintenance_db'],
- "username": srv['test_db_username'],
- "role": "",
- "sslmode": srv['test_sslmode']}
+ con_response = self.tester.post('browser/server/connect/{0}/{1}'.format
+ (srv_grp, server_id),
+ data=dict(password=
+ config_data
+ ['test_server_credentials'][0]
+ ['test_db_password']),
+ follow_redirects=True)
- url = self.url + str(srv_grp) + "/"
+ srv_con = json.loads(con_response.data.decode())
- response = self.tester.get(url, data=json.dumps(data),
- content_type='html/json')
+ if len(srv_con) == 0:
+ raise Exception("No Server(s) connected to update.")
- self.assertTrue(response.status_code, 200)
- respdata = json.loads(response.data)
+ data = \
+ {
+ "comment": config_data
+ ['test_server_update_data'][0]['test_comment'],
+ "id": server_id
+ }
- for server in respdata:
+ put_response = self.tester.put(self.url + str(srv_grp) + '/' +
+ str(server_id), data=json.dumps(data),
+ content_type='html/json')
- url = self.url + str(srv_grp) + "/" + json.dumps(server['id'])
+ self.assertEquals(put_response.status_code, 200)
- for server in config_data['test_server_update_data']:
- data = {"comment": server['test_comment']}
- response = self.tester.put(url, data=json.dumps(data),
- content_type='html/json')
- self.assertTrue(response.status_code, 200)
- respdata = json.loads(response.data)
- self.assertTrue(respdata['success'], 1)
+ respdata = json.loads(put_response.data.decode())
+ self.assertTrue(respdata['success'], 1)
diff --git a/web/pgadmin/browser/server_groups/tests/test_sg_get.py b/web/pgadmin/browser/server_groups/tests/test_sg_get.py
new file mode 100644
index 0000000..c552d8e
--- /dev/null
+++ b/web/pgadmin/browser/server_groups/tests/test_sg_get.py
@@ -0,0 +1,36 @@
+###########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+###########################################################################
+
+import json
+from pgadmin.browser.tests.test_login import LoginTestCase
+from regression.config import config_data
+
+
+class SgGetTestCase(LoginTestCase):
+ """
+ This class will check available server groups in pgAdmin.
+ """
+
+ priority = 3
+
+ scenarios = [
+ # Fetching the default url for server group node
+ ('Check Server Group Node', dict(url='/browser/server-group/obj/'))
+ ]
+
+ def runTest(self):
+ """This function will check available server groups."""
+
+ srv_grp = config_data['test_server_group']
+
+ response = self.tester.get(self.url + str(srv_grp),
+ content_type='html/json')
+ self.assertEquals(response.status_code, 200)
+ respdata = json.loads(response.data.decode())
+ self.assertTrue(respdata['id'], srv_grp)
diff --git a/web/pgadmin/browser/tests/__init__.py b/web/pgadmin/browser/tests/__init__.py
index 2381efd..4470711 100644
--- a/web/pgadmin/browser/tests/__init__.py
+++ b/web/pgadmin/browser/tests/__init__.py
@@ -11,5 +11,6 @@ from pgadmin.utils.route import BaseTestGenerator
class BrowserGenerateTestCase(BaseTestGenerator):
+
def runTest(self):
- print ("In BrowserGenerateTestCase...")
+ return
diff --git a/web/pgadmin/browser/tests/test_change_password.py b/web/pgadmin/browser/tests/test_change_password.py
index dedb7d9..5c4930d 100644
--- a/web/pgadmin/browser/tests/test_change_password.py
+++ b/web/pgadmin/browser/tests/test_change_password.py
@@ -85,10 +85,10 @@ class ChangePasswordTestCase(LoginTestCase):
"""This function will check change password functionality."""
response = self.tester.get('/change', follow_redirects=True)
- self.assertIn('pgAdmin 4 Password Change', response.data)
+ self.assertIn('pgAdmin 4 Password Change', response.data.decode('utf8'))
response = self.tester.post('/change', data=dict(
password=self.password,
new_password=self.new_password,
new_password_confirm=self.new_password_confirm),
follow_redirects=True)
- self.assertIn(self.respdata, response.data)
+ self.assertIn(self.respdata, response.data.decode('utf8'))
diff --git a/web/pgadmin/browser/tests/test_login.py b/web/pgadmin/browser/tests/test_login.py
index 7c2b796..d272a63 100644
--- a/web/pgadmin/browser/tests/test_login.py
+++ b/web/pgadmin/browser/tests/test_login.py
@@ -8,7 +8,6 @@
##########################################################################
import uuid
-
from pgadmin.utils.route import BaseTestGenerator
from regression.config import config_data
@@ -67,7 +66,9 @@ class LoginTestCase(BaseTestGenerator):
['test_login_username']),
password=(config_data['pgAdmin4_login_credentials']
['test_login_password']),
- respdata='You are currently running version'))
+ respdata='Gravatar image for %s' %
+ config_data['pgAdmin4_login_credentials']
+ ['test_login_username']))
]
def runTest(self):
@@ -76,4 +77,4 @@ class LoginTestCase(BaseTestGenerator):
response = self.tester.post('/login', data=dict(
email=self.email, password=self.password),
follow_redirects=True)
- self.assertIn(self.respdata, response.data)
+ self.assertIn(self.respdata, response.data.decode('utf8'))
diff --git a/web/pgadmin/browser/tests/test_logout.py b/web/pgadmin/browser/tests/test_logout.py
index 8971e72..d9611ae 100644
--- a/web/pgadmin/browser/tests/test_logout.py
+++ b/web/pgadmin/browser/tests/test_logout.py
@@ -14,14 +14,13 @@ from regression.config import config_data
class LogoutTest(LoginTestCase):
"""
This class verifies the logout functionality; provided the user is already
- logged-in. Dictionary parameters define the scenario appended by test
- name.
+ logged-in.
"""
- priority = 3
+ priority = 100
scenarios = [
- # This test case validate the logout page
+ # This test case validate the logout page.
('Logging Out', dict(respdata='Redirecting...'))
]
@@ -29,7 +28,7 @@ class LogoutTest(LoginTestCase):
"""This function checks the logout functionality."""
response = self.tester.get('/logout')
- self.assertIn(self.respdata, response.data)
+ self.assertIn(self.respdata, response.data.decode('utf8'))
def tearDown(self):
"""
diff --git a/web/pgadmin/browser/tests/test_reset_password.py b/web/pgadmin/browser/tests/test_reset_password.py
index 030b182..31a3992 100644
--- a/web/pgadmin/browser/tests/test_reset_password.py
+++ b/web/pgadmin/browser/tests/test_reset_password.py
@@ -41,8 +41,9 @@ class ResetPasswordTestCase(BaseTestGenerator):
"""This function checks reset password functionality."""
response = self.tester.get('/reset')
- self.assertIn('Recover pgAdmin 4 Password', response.data)
+ self.assertIn('Recover pgAdmin 4 Password',
+ response.data.decode('utf8'))
response = self.tester.post(
'/reset', data=dict(email=self.email),
follow_redirects=True)
- self.assertIn(self.respdata, response.data)
+ self.assertIn(self.respdata, response.data.decode('utf8'))
diff --git a/web/pgadmin/utils/route.py b/web/pgadmin/utils/route.py
index fb9de69..e439965 100644
--- a/web/pgadmin/utils/route.py
+++ b/web/pgadmin/utils/route.py
@@ -52,7 +52,10 @@ class TestsGeneratorRegistry(ABCMeta):
from werkzeug.utils import find_modules
for module_name in find_modules(pkg, False, True):
- module = import_module(module_name)
+ try:
+ module = import_module(module_name)
+ except ImportError:
+ pass
import six
diff --git a/web/regression/config.py b/web/regression/config.py
index bef65fb..f48eade 100644
--- a/web/regression/config.py
+++ b/web/regression/config.py
@@ -14,3 +14,8 @@ root = os.path.dirname(os.path.realpath(__file__))
with open(root + '/test_config.json') as data_file:
config_data = json.load(data_file)
+
+with open(root + '/test_advance_config.json') as data_file:
+ advance_config_data = json.load(data_file)
+
+pickle_path = os.path.join(root, 'parent_id.pkl')
diff --git a/web/regression/test_advance_config.json.in b/web/regression/test_advance_config.json.in
new file mode 100644
index 0000000..e415876
--- /dev/null
+++ b/web/regression/test_advance_config.json.in
@@ -0,0 +1,103 @@
+{
+ "test_add_database_data":
+ {
+ "test_privileges_acl": [
+ {
+ "grantee": "postgres",
+ "grantor": "postgres",
+ "privileges": [
+ {
+ "privilege_type": "C",
+ "privilege": true,
+ "with_grant": true
+ },
+ {
+ "privilege_type": "T",
+ "privilege": true,
+ "with_grant": false
+ }
+ ]
+ }
+ ],
+ "test_conn_limit": -1,
+ "test_owner": "postgres",
+ "test_fun_acl": [
+ {
+ "grantee": "postgres",
+ "grantor": "postgres",
+ "privileges": [
+ {
+ "privilege_type": "X",
+ "privilege": true,
+ "with_grant": false
+ }
+ ]
+ }
+ ],
+ "test_seq_acl": [
+ {
+ "grantee": "postgres",
+ "grantor": "postgres",
+ "privileges": [
+ {
+ "privilege_type": "r",
+ "privilege": true,
+ "with_grant": false
+ },
+ {
+ "privilege_type": "w",
+ "privilege": true,
+ "with_grant": false
+ },
+ {
+ "privilege_type": "U",
+ "privilege": true,
+ "with_grant": false
+ }
+ ]
+ }
+ ],
+ "test_tbl_acl": [
+ {
+ "grantee": "postgres",
+ "grantor": "postgres",
+ "privileges": [
+ {
+ "privilege_type": "a",
+ "privilege": true,
+ "with_grant": true
+ },
+ {
+ "privilege_type": "r",
+ "privilege": true,
+ "with_grant": false
+ }
+ ]
+ }
+ ],
+ "test_type_acl": [
+ {
+ "grantee": "postgres",
+ "grantor": "postgres",
+ "privileges": [
+ {
+ "privilege_type": "U",
+ "privilege": true,
+ "with_grant": false
+ }
+ ]
+ }
+ ],
+ "test_encoding": "UTF8",
+ "test_name": "test_db_automation",
+ "test_privileges": [],
+ "test_securities": [],
+ "test_variables": []
+ },
+
+ "test_db_update_data":
+ {
+ "test_comment": "This is db update comment"
+ }
+
+}
diff --git a/web/regression/test_nodes.py b/web/regression/test_nodes.py
new file mode 100644
index 0000000..8919595
--- /dev/null
+++ b/web/regression/test_nodes.py
@@ -0,0 +1,46 @@
+# #################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+# ##################################################################
+
+from regression.config import config_data
+import json
+from regression.test_utils import get_ids
+
+
+def test_getnodes(node=None):
+ # Connect to server and database.
+
+ if not node:
+ return None
+
+ all_id = get_ids()
+
+ server_id = all_id["sid"][0]
+ db_id = all_id["did"][0]
+ print("db id in test nodes:", db_id)
+
+ srv_grp = config_data['test_server_group']
+
+ # Connect to server
+ response = node.tester.post('browser/server/connect/{0}/{1}'.format
+ (srv_grp, server_id),
+ data=dict(password=config_data
+ ['test_server_credentials'][0]
+ ['test_db_password']), follow_redirects=True)
+
+ # Connect to database
+ con_response = node.tester.post('browser/database/connect/'
+ '{0}/{1}/{2}'.format
+ (srv_grp, server_id, db_id),
+ follow_redirects=True)
+ print("connect db response in test nodes", con_response)
+
+ db_con = json.loads(con_response.data.decode())
+ print("db connection response in test nodes", db_con)
+
+ return db_con
diff --git a/web/regression/test_utils.py b/web/regression/test_utils.py
new file mode 100644
index 0000000..c68744f
--- /dev/null
+++ b/web/regression/test_utils.py
@@ -0,0 +1,20 @@
+# #################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2016, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+# ##################################################################
+
+import pickle
+from regression.config import pickle_path
+
+
+def get_ids(url=pickle_path):
+ # This function will read parent nodes id's from pickle and return it.
+
+ output = open(url, 'rb')
+ ids = pickle.load(output)
+ output.close()
+ return ids
diff --git a/web/regression/testsuite.py b/web/regression/testsuite.py
index 75d437b..3d8d2c4 100644
--- a/web/regression/testsuite.py
+++ b/web/regression/testsuite.py
@@ -13,7 +13,8 @@ them to TestSuite. """
import os
import sys
import unittest
-
+import operator
+import logging
from testscenarios.scenarios import generate_scenarios
# We need to include the root directory in sys.path to ensure that we can
@@ -65,6 +66,8 @@ def suite():
modules.insert(gen.priority, gen)
+ modules.sort(key=operator.attrgetter('priority'))
+
for m in modules:
obj = m()
obj.setTestClient(test_client)
@@ -75,5 +78,20 @@ def suite():
if __name__ == '__main__':
+
+ logging.basicConfig(level=logging.DEBUG,
+ format='%(asctime)s:%(levelname)s:%(name)s:%(message)s',
+ filename="logger.log",
+ filemode='w')
+
suite = suite()
- tests = unittest.TextTestRunner(descriptions=True, verbosity=2).run(suite)
+ tests = unittest.TextTestRunner(descriptions=True, verbosity=2,
+ stream=sys.stdout).run(suite)
+
+ print("Please check output in file: logger.log placed at", current_path)
+
+ try:
+ os.remove("parent_id.pkl")
+
+ except FileNotFoundError:
+ pass
view thread (27+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: pgAdmin IV API test cases patch
In-Reply-To: <CAKmZXFRfZ6Y0eJK8k1FdvWX_V6A8bCdxJzBuWaJ0-nRWDsaOQA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox