Hi Dave,

PFA patch to add test case to cover the scenario against RM#3014


On Wed, Feb 21, 2018 at 11:09 PM, Murtuza Zabuawala <
murtuza.zabuaw...@enterprisedb.com> wrote:

> Hi Joao,
>
> ​Thank you for your time in reviewing the patch.​
>
>
> On Wed, Feb 21, 2018 at 9:24 PM, Joao De Almeida Pereira <
> jdealmeidapere...@pivotal.io> wrote:
>
>> Hi Murtuza,
>> Looks good.
>> Was there any reason for the change in position of the if statements in
>> the sql file. Makes the output more readable?
>>
> ​Yes​
>
>
>> Looks like we need some test to ensure that the Sequence issue does not
>> happen again. Maybe a Unit Test is good enough, to ensure that we are
>> creating a good SQL
>>
> ​I'll add a test case for the same.​
>
>
>>
>> Thanks
>> Joao
>>
>> On Wed, Feb 21, 2018 at 3:13 AM Murtuza Zabuawala <
>> murtuza.zabuaw...@enterprisedb.com> wrote:
>>
>>> Hi,
>>>
>>> PFA patches,
>>> 1) To fix the validation issue while creating new sequence
>>> RM#3014
>>>
>>> 2) Fix PEP-8 issues in sequence module
>>> pycodestyle --config=.pycodestyle ./pgadmin/browser/server_group
>>> s/servers/databases/schemas/sequences/
>>>
>>> 3) To fix the regression test for Tablespace when running with Python3.x
>>> RM#3138
>>>
>>> --
>>> Regards,
>>> Murtuza Zabuawala
>>> EnterpriseDB: http://www.enterprisedb.com
>>> The Enterprise PostgreSQL Company
>>>
>>>
>
diff --git 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/test_sequence_add.py
 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/test_sequence_add.py
index eeb7efd..2c92c5c 100644
--- 
a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/test_sequence_add.py
+++ 
b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/tests/test_sequence_add.py
@@ -23,7 +23,40 @@ class SequenceAddTestCase(BaseTestGenerator):
     """ This class will add new sequence(s) under schema node. """
     scenarios = [
         # Fetching default URL for sequence node.
-        ('Fetch sequence Node URL', dict(url='/browser/sequence/obj/'))
+        (
+            'Fetch sequence Node URL (valid optional data)',
+            dict(
+                url='/browser/sequence/obj/',
+                # Valid optional data
+                data={
+                    "cache": "1",
+                    "cycled": True,
+                    "increment": "1",
+                    "maximum": "100000",
+                    "minimum": "1",
+                    "name": "test_sequence_add_%s" % (str(uuid.uuid4())[1:8]),
+                    "securities": [],
+                    "start": "100"
+                }
+            )
+        ),
+        (
+            'Fetch sequence Node URL (invalid optional data)',
+            dict(
+                url='/browser/sequence/obj/',
+                # Optional fields should be int but we are passing empty str
+                data={
+                    "cache": "",
+                    "cycled": False,
+                    "increment": "",
+                    "maximum": "",
+                    "minimum": "",
+                    "name": "test_sequence_add_%s" % (str(uuid.uuid4())[1:8]),
+                    "securities": [],
+                    "start": ""
+                }
+            )
+        )
     ]
 
     def setUp(self):
@@ -47,13 +80,8 @@ class SequenceAddTestCase(BaseTestGenerator):
         if not schema_response:
             raise Exception("Could not find the schema to add sequence.")
         db_user = self.server["username"]
-        data = {
-            "cache": "1",
-            "cycled": True,
-            "increment": "1",
-            "maximum": "100000",
-            "minimum": "1",
-            "name": "test_sequence_add_%s" % (str(uuid.uuid4())[1:8]),
+
+        common_data = {
             "relacl": [
                 {
                     "grantee": db_user,
@@ -79,15 +107,16 @@ class SequenceAddTestCase(BaseTestGenerator):
                 }
             ],
             "schema": schema_name,
-            "securities": [],
             "seqowner": db_user,
-            "start": "100"
         }
+
+        self.data.update(common_data)
+
         response = self.tester.post(
             self.url + str(utils.SERVER_GROUP) + '/' +
             str(self.server_id) + '/' + str(self.db_id) +
             '/' + str(schema_id) + '/',
-            data=json.dumps(data),
+            data=json.dumps(self.data),
             content_type='html/json')
         self.assertEquals(response.status_code, 200)
 

Reply via email to