예제 #1
0
    def test_reset_database_exists(self):
        dbname = 'testresetdb2'
        PSQL.create_database(dbname)
        time.sleep(4)
        PSQL.run_sql_command(sql_cmd="CREATE TABLE testresettable(i int)",
                             dbname=dbname)
        output = PSQL.run_sql_command(sql_cmd="SELECT * FROM testresettable",
                                      dbname=dbname)
        self.assertIsNotNone(re.search('0 rows', output))

        PSQL.reset_database(dbname)
        out_file = os.path.join(
            os.path.dirname(inspect.getfile(self.__class__)),
            'test_reset_database_exists.out')
        self.assertFalse(os.path.exists(out_file))
        PSQL.run_sql_command(sql_cmd="SELECT * FROM testresettable",
                             dbname=dbname,
                             out_file=out_file)
        self.assertTrue(os.path.exists(out_file))
        # stdout should be none
        with open(out_file, 'r') as f:
            output = f.read()
            self.assertIsNotNone(re.search('relation.*does not exist', output))
        os.remove(out_file)
        self.assertFalse(os.path.exists(out_file))
        PSQL.drop_database(dbname)
        time.sleep(4)
        self.assertFalse(PSQL.database_exists(dbname))
예제 #2
0
 def test_reset_database_not_exists(self):
     dbname = 'testresetdb'
     PSQL.reset_database(dbname)
     time.sleep(4)
     self.assertTrue(PSQL.database_exists(dbname))
     PSQL.drop_database(dbname)
     time.sleep(4)
     self.assertFalse(PSQL.database_exists(dbname))
예제 #3
0
 def test_reset_database_not_exists(self):
     dbname = 'testresetdb'
     PSQL.reset_database(dbname)
     time.sleep(4)
     self.assertTrue(PSQL.database_exists(dbname))
     PSQL.drop_database(dbname)
     time.sleep(4)
     self.assertFalse(PSQL.database_exists(dbname))
예제 #4
0
    def test_reset_database_exists(self):
        dbname = 'testresetdb2'
        PSQL.create_database(dbname)
        time.sleep(4)
        PSQL.run_sql_command(sql_cmd = "CREATE TABLE testresettable(i int)", dbname = dbname)
        output = PSQL.run_sql_command(sql_cmd = "SELECT * FROM testresettable", dbname = dbname)
        self.assertIsNotNone(re.search('0 rows', output))

        PSQL.reset_database(dbname)
        out_file = os.path.join(os.path.dirname(inspect.getfile(self.__class__)),'test_reset_database_exists.out')
        self.assertFalse(os.path.exists(out_file))
        PSQL.run_sql_command(sql_cmd = "SELECT * FROM testresettable", dbname = dbname, out_file = out_file)
        self.assertTrue(os.path.exists(out_file))
        # stdout should be none
        with open(out_file, 'r') as f:
            output = f.read()
            self.assertIsNotNone(re.search('relation.*does not exist', output))
        os.remove(out_file)
        self.assertFalse(os.path.exists(out_file))
        PSQL.drop_database(dbname)
        time.sleep(4)
        self.assertFalse(PSQL.database_exists(dbname))