public inbox for [email protected]  
help / color / mirror / Atom feed
From: Navnath Gadakh <[email protected]>
To: pgadmin-hackers <[email protected]>
Cc: Kanchan Mohitey <[email protected]>
Cc: Ikram Khan <[email protected]>
Subject: pgAdmin4: Test-suite OS compatability issue
Date: Fri, 28 Apr 2017 19:21:32 +0530
Message-ID: <CAOAJCYrRH_E-=TwsVK7=FsiV86xBgwKOQnVHanOQ9sMeBECe-g@mail.gmail.com> (raw)
List-Unsubscribe:  <mailto:[email protected]?body=unsub%20pgadmin-hackers>

Hi Dave,

         Please find the patch for OS compatability issue of test-suite.

*Code Changes:*

            1. Minor code changes done related to os module in
*pgadmin4/web/regression/feature_utils/app_starter.py*
            2. Code added in
pgadmin4/*web/pgadmin/utils/tests/test_versioned_template_loader.py
*to handle path for SQL file.
            3. Code added to convert unicode to string in some .py files.

*Note:*
             With python2.6.6 test-suite is failed to execute. I have
created the RM 2367 <https://redmine.postgresql.org/issues/2367;

Thank you!



-- 
Regards,
Navnath Gadakh

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] testsuite_os_compatability_issue.patch (5.2K, 3-testsuite_os_compatability_issue.patch)
  download | inline diff:
diff --git a/web/pgadmin/utils/tests/test_versioned_template_loader.py b/web/pgadmin/utils/tests/test_versioned_template_loader.py
index 5374b878..4ba56033 100644
--- a/web/pgadmin/utils/tests/test_versioned_template_loader.py
+++ b/web/pgadmin/utils/tests/test_versioned_template_loader.py
@@ -33,34 +33,37 @@ class TestVersionedTemplateLoader(BaseTestGenerator):
     def test_get_source_returns_a_template(self):
         expected_content = "Some SQL" \
                            "\nsome more stuff on a new line\n"
-
+        # For cross platform we join the SQL path (This solves the slashes issue)
+        sql_path = os.path.join("some_feature", "sql", "9.1_plus", "some_action.sql")
         content, filename, up_to_dateness = self.loader.get_source(None, "some_feature/sql/9.1_plus/some_action.sql")
-
-        self.assertEqual(expected_content, content)
-        self.assertIn("some_feature/sql/9.1_plus/some_action.sql", filename)
+        self.assertEqual(expected_content, str(content).replace("\r",""))
+        self.assertIn(sql_path, filename)
 
     def test_get_source_when_the_version_is_9_1_returns_9_1_template(self):
         expected_content = "Some SQL" \
                            "\nsome more stuff on a new line\n"
-
+        # For cross platform we join the SQL path (This solves the slashes issue)
+        sql_path = os.path.join("some_feature", "sql", "9.1_plus", "some_action.sql")
         content, filename, up_to_dateness = self.loader.get_source(None, "some_feature/sql/#90100#/some_action.sql")
 
-        self.assertEqual(expected_content, content)
-        self.assertIn("some_feature/sql/9.1_plus/some_action.sql", filename)
+        self.assertEqual(expected_content, str(content).replace("\r",""))
+        self.assertIn(sql_path, filename)
 
     def test_get_source_when_the_version_is_9_3_and_there_are_templates_for_9_2_and_9_1_returns_9_2_template(self):
-
+        # For cross platform we join the SQL path (This solves the slashes issue)
+        sql_path = os.path.join("some_feature", "sql", "9.2_plus", "some_action.sql")
         content, filename, up_to_dateness = self.loader.get_source(None, "some_feature/sql/#90300#/some_action.sql")
 
-        self.assertEqual("Some 9.2 SQL", content)
-        self.assertIn("some_feature/sql/9.2_plus/some_action.sql", filename)
+        self.assertEqual("Some 9.2 SQL", str(content).replace("\r",""))
+        self.assertIn(sql_path, filename)
 
     def test_get_source_when_the_version_is_9_0_and_there_are_templates_for_9_1_and_9_2_returns_default_template(self):
-
+        # For cross platform we join the SQL path (This solves the slashes issue)
+        sql_path = os.path.join("some_feature", "sql", "default", "some_action_with_default.sql")
         content, filename, up_to_dateness = self.loader.get_source(None, "some_feature/sql/#90000#/some_action_with_default.sql")
 
-        self.assertEqual("Some default SQL", content)
-        self.assertIn("some_feature/sql/default/some_action_with_default.sql", filename)
+        self.assertEqual("Some default SQL", str(content).replace("\r",""))
+        self.assertIn(sql_path, filename)
 
     def test_raise_not_found_exception_when_postgres_version_less_than_all_available_sql_templates(self):
 
diff --git a/web/regression/feature_utils/app_starter.py b/web/regression/feature_utils/app_starter.py
index b03f2a94..98762ca2 100644
--- a/web/regression/feature_utils/app_starter.py
+++ b/web/regression/feature_utils/app_starter.py
@@ -27,13 +27,11 @@ class AppStarter:
         random_server_port = str(random.randint(10000, 65535))
         env = {
             "PGADMIN_PORT": random_server_port,
-            "SQLITE_PATH": self.app_config.TEST_SQLITE_PATH
+            "SQLITE_PATH": str(self.app_config.TEST_SQLITE_PATH)
                }
         env.update(os.environ)
-
         self.pgadmin_process = subprocess.Popen(["python", "pgAdmin4.py"],
                                                 shell=False,
-                                                preexec_fn=os.setsid,
                                                 stderr=open(os.devnull, 'w'),
                                                 env=env)
 
@@ -43,4 +41,4 @@ class AppStarter:
 
     def stop_app(self):
         self.driver.quit()
-        os.killpg(os.getpgid(self.pgadmin_process.pid), signal.SIGTERM)
+        os.kill(self.pgadmin_process.pid, signal.SIGTERM)
diff --git a/web/regression/runtests.py b/web/regression/runtests.py
index 5f4a3d0c..3ab75128 100644
--- a/web/regression/runtests.py
+++ b/web/regression/runtests.py
@@ -67,10 +67,10 @@ if pgadmin_credentials:
                for item in ['login_username', 'login_password']):
             pgadmin_credentials = pgadmin_credentials[
                 'pgAdmin4_login_credentials']
-            os.environ['PGADMIN_SETUP_EMAIL'] = pgadmin_credentials[
-                'login_username']
-            os.environ['PGADMIN_SETUP_PASSWORD'] = pgadmin_credentials[
-                'login_password']
+            os.environ['PGADMIN_SETUP_EMAIL'] = str(pgadmin_credentials[
+                'login_username'])
+            os.environ['PGADMIN_SETUP_PASSWORD'] = str(pgadmin_credentials[
+                'login_password'])
 
 # Execute the setup file
 exec (open("setup.py").read())


view thread (10+ 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: pgAdmin4: Test-suite OS compatability issue
  In-Reply-To: <CAOAJCYrRH_E-=TwsVK7=FsiV86xBgwKOQnVHanOQ9sMeBECe-g@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