How to use test_dumper method in pyshould

Best Python code snippet using pyshould_python

alldata.py

Source:alldata.py Github

copy

Full Screen

1import sys2sys.path.append("/home/mountainsensing/database-scripts/")3from data_dump import DataDump4from datetime import datetime5LIVE_CONFIG = "/home/pjb/database-scripts/db.ini"6TEST_CONFIG = "/home/pjb/database-scripts/db_test.ini"7def index(req):8 output = """<html><head>9 <title>Feshie Data Overview</title>10 </head>11 <body><h1>Feshie Data Overview</h1>12 <p>As at """13 output += str(datetime.utcnow())14 output += """ UTC</p>15 <div style="width:50%; float:left; background-color:#E78B7E">16 <h2>Test Data</h2>"""17 TEST_DUMPER = DataDump(TEST_CONFIG)18 TEST_LATEST = TEST_DUMPER.get_latest_readings()19 output += """<table><tr><th>Node</th><th>Latest</th></tr>"""20 for node in TEST_LATEST:21 output +="<tr><td>%s</td><td>%s</td></tr>"% (node[0], node[2])22 output +="</table>"23 output += """24 <h3>Combined Graphs</h3>25 <a href="graph.py?test&sensor=temp">Temperature</a><br/>26 <a href="graph.py?test&sensor=batt">Battery</a><br/>27 <a href="graph.py?test&sensor=mppt">Max Power Point Tracking</a><br/>28 <a href="graph.py?test&sensor=soc">State of Charge</a><br/>29 <a href="graph.py?test&sensor=solar">Solar Charge Current</a><br/>30 <a href="graph.py?test&sensor=adc&adc_id=1">ADC 1</a><br/>31 <a href="graph.py?test&sensor=adc&adc_id=2">ADC 2</a><br/>32 <a href="graph.py?test&sensor=moisture">Moisture</a><br/>33 <a href="graph.py?test&sensor=rain">Rainfall</a><br/>34 """35 36 TEST_NODES = TEST_DUMPER.get_nodes()37 output += "<h3>Node specific graphs</h3>"38 output += """<table>"""39 for node in TEST_NODES:40 output += "<tr><td>%s</td>" % node41 output += "<td><a href = \"graph.py?test&sensor=accel&node=%s\">Accelerometer</a></td>" % node42 output += "<td><a href = \"graph.py?test&sensor=ow&node=%s\">Spider</a></td>" % node43 output += "<td><a href = \"graph.py?test&sensor=wp&node=%s\">Water Pressure</a></td>" % node44 output += "<td><a href = \"graph.py?test&sensor=chain&node=%s\">Chain</a></td>" % node45 output +="</tr>"46 output +="</table></div>"47 output += "<div style=\"width:50%; float:right; background-color:#A2E382\"><h2>LIVE Data</h2>"48 LIVE_DUMPER = DataDump(LIVE_CONFIG)49 LIVE_LATEST = LIVE_DUMPER.get_latest_readings()50 output += """<table><tr><th>Node</th><th>Latest</th></tr>"""51 for node in LIVE_LATEST:52 output +="<tr><td>%s</td><td>%s</td></tr>"% (node[0], node[2])53 output +="</table>"54 output += """55 <h3>Combined Graphs</h3>56 <a href="graph.py?sensor=temp">Temperature</a><br/>57 <a href="graph.py?sensor=batt">Battery</a><br/>58 <a href="graph.py?sensor=mppt">Max Power Point Tracking</a><br/>59 <a href="graph.py?sensor=soc">State of Charge</a><br/>60 <a href="graph.py?sensor=solar">Solar Charge Current</a><br/>61 <a href="graph.py?sensor=adc&adc_id=1">ADC 1</a><br/>62 <a href="graph.py?sensor=adc&adc_id=2">ADC 2</a><br/>63 <a href="graph.py?sensor=moisture">Moisture</a><br/>64 <a href="graph.py?sensor=rain">Rainfall</a><br/>65 """66 67 LIVE_NODES = LIVE_DUMPER.get_nodes()68 output += "<h3>Node specific graphs</h3>"69 output += """<table>"""70 for node in LIVE_NODES:71 output += "<tr><td>%s</td>" % node72 output += "<td><a href = \"graph.py?sensor=accel&node=%s\">Accelerometer</a></td>" % node73 output += "<td><a href = \"graph.py?sensor=ow&node=%s\">Spider</a></td>" % node74 output += "<td><a href = \"graph.py?sensor=wp&node=%s\">Water Pressure</a></td>" % node75 output += "<td><a href = \"graph.py?sensor=chain&node=%s\">Chain</a></td>" % node76 output +="</tr>"77 output +="</table></div>"78 output +="</body></html>"...

Full Screen

Full Screen

test_dumper.py

Source:test_dumper.py Github

copy

Full Screen

1import os2import shutil3import unittest4import tempfile5import psycopg26import psycopg2.extras7from pum.core.dumper import Dumper8from pum.core.exceptions import PgRestoreFailed9from pum import __main__ as pum10class TestDumper(unittest.TestCase):11 """Test the class Dumper.12 2 pg_services needed for test related to empty db:13 pum_test_114 pum_test_215 """16 def tearDown(self):17 self.cur1.execute('DROP SCHEMA IF EXISTS test_dumper CASCADE;')18 self.conn1.commit()19 self.conn1.close()20 self.cur2.execute('DROP SCHEMA IF EXISTS test_dumper CASCADE;')21 self.conn2.commit()22 self.conn2.close()23 self.tmpdir.cleanup()24 self.tmp = None25 def setUp(self):26 self.pg_service1 = 'pum_test_1'27 self.pg_service2 = 'pum_test_2'28 self.conn1 = psycopg2.connect("service={0}".format(self.pg_service1))29 self.cur1 = self.conn1.cursor()30 self.conn2 = psycopg2.connect("service={0}".format(self.pg_service2))31 self.cur2 = self.conn2.cursor()32 self.cur1.execute("""33 DROP SCHEMA IF EXISTS test_dumper CASCADE;34 CREATE SCHEMA test_dumper;35 CREATE TABLE test_dumper.dumper_table36 (37 id serial NOT NULL PRIMARY KEY,38 version character varying(50),39 description character varying(200) NOT NULL,40 type integer NOT NULL41 );42 """)43 self.conn1.commit()44 self.cur2.execute("""45 DROP SCHEMA IF EXISTS test_dumper CASCADE;""")46 self.conn2.commit()47 self.tmpdir = tempfile.TemporaryDirectory()48 self.tmp = self.tmpdir.name49 def test_dump_restore(self):50 os.makedirs(self.tmp + '/test_dumper/', exist_ok=True)51 dumper = Dumper(self.pg_service1, self.tmp + '/test_dumper/dump.sql')52 dumper.pg_backup(exclude_schema=['public'])53 dumper = Dumper(self.pg_service2, self.tmp + '/test_dumper/dump.sql')54 dumper.pg_restore()55 # postgres > 9.456 self.cur2.execute("SELECT to_regclass('{}');".format('test_dumper.dumper_table'))57 self.assertIsNotNone(self.cur2.fetchone()[0])58 def test_restore_ignore_errors(self):59 self.cur2.execute("""CREATE SCHEMA test_dumper;""")60 self.conn2.commit()61 os.makedirs(self.tmp + '/test_dumper', exist_ok=True)62 file = self.tmp + '/test_dumper/dump_ie.sql'63 dumper = Dumper(self.pg_service1, file)64 dumper.pg_backup(exclude_schema=['public'])65 dumper = Dumper(self.pg_service2, file)66 try:67 dumper.pg_restore()68 self.assertTrue(False)69 except PgRestoreFailed:70 pass71 self.cur2.execute("""DROP SCHEMA IF EXISTS test_dumper CASCADE;""")72 self.conn2.commit()73 self.cur2.execute("""CREATE SCHEMA test_dumper;""")74 self.conn2.commit()75 pum.Pum().run_restore(self.pg_service2, file, True, ['public'])76 self.cur2.execute("SELECT to_regclass('{}');".format('test_dumper.dumper_table'))77 self.assertIsNotNone(self.cur2.fetchone()[0])78if __name__ == '__main__':...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pyshould automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful