How to use create_topic method in localstack

Best Python code snippet using localstack_python

message_queue_test.py

Source:message_queue_test.py Github

copy

Full Screen

...8def node_with_test_topic():9 node = Swarm(PROGRAM_FILE_PATH, 1)[0]10 node.start(ELECTION_TIMEOUT)11 node.wait_for_flask_startup()12 assert (node.create_topic(TEST_TOPIC).json() == {"success": True})13 yield node14 node.clean()15@pytest.fixture16def node():17 node = Swarm(PROGRAM_FILE_PATH, 1)[0]18 node.start(ELECTION_TIMEOUT)19 node.wait_for_flask_startup()20 yield node21 node.clean()22# TOPIC TESTS23def test_get_topic_empty(node):24 assert (node.get_topics().json() == {"success": True, "topics": []})25def test_create_topic(node):26 assert (node.create_topic(TEST_TOPIC).json() == {"success": True})27def test_create_different_topics(node):28 assert (node.create_topic(TEST_TOPIC).json() == {"success": True})29 assert (node.create_topic("test_topic_different").json()30 == {"success": True})31def test_create_same_topic(node):32 assert (node.create_topic(TEST_TOPIC).json() == {"success": True})33 assert (node.create_topic(TEST_TOPIC).json() == {"success": False})34def test_get_topic(node):35 assert (node.create_topic(TEST_TOPIC).json() == {"success": True})36 assert (node.get_topics().json() == {37 "success": True, "topics": [TEST_TOPIC]38 })39def test_get_same_topic(node):40 assert (node.create_topic(TEST_TOPIC).json() == {"success": True})41 assert (node.create_topic(TEST_TOPIC).json() == {"success": False})42 assert (node.get_topics().json() == {43 "success": True, "topics": [TEST_TOPIC]44 })45def test_get_multiple_topics(node):46 topics = []47 for i in range(5):48 topic = TEST_TOPIC + str(i)49 assert (node.create_topic(topic).json() == {"success": True})50 topics.append(topic)51 assert (node.get_topics().json() == {52 "success": True, "topics": topics53 })54def test_get_multiple_topics_with_duplicates(node):55 topics = []56 for i in range(5):57 topic = TEST_TOPIC + str(i)58 assert (node.create_topic(topic).json() == {"success": True})59 assert (node.create_topic(topic).json() == {"success": False})60 topics.append(topic)61 assert (node.get_topics().json() == {62 "success": True, "topics": topics63 })64# MESSAGE TEST65def test_get_message_from_inexistent_topic(node_with_test_topic):66 assert (node_with_test_topic.get_message(67 TEST_TOPIC).json() == {"success": False})68def test_get_message(node_with_test_topic):69 assert (node_with_test_topic.get_message(70 TEST_TOPIC).json() == {"success": False})71def test_put_message(node_with_test_topic):72 assert (node_with_test_topic.put_message(73 TEST_TOPIC, TEST_MESSAGE).json() == {"success": True})...

Full Screen

Full Screen

init_db.py

Source:init_db.py Github

copy

Full Screen

...3conn, cur = db.get_db_connection()4with open('schema.sql') as f:5 cur.execute(f.read())6db.close_db_connection(conn)7db.create_topic('Advanced Gas Turbine Engine',8 ['10.1038/nmat4687',9 '10.1016/j.paerosci.2017.08.001',10 '10.1016/j.apenergy.2017.04.048',11 '10.2514/1.J055361',12 '10.1016/j.ijhydene.2019.12.143'], [])13 14db.create_topic('Advanced Manufacturing',15 ['10.1016/j.pmatsci.2017.10.001',16 '10.1016/j.compositesb.2018.02.012',17 '10.1016/j.compositesb.2016.11.034',18 '10.1016/J.ENG.2017.05.015',19 '10.1126/science.aai7899'], [])20 21db.create_topic('Financial Technologies',22 ['10.1109/MC.2017.3571064',23 '10.1016/j.elerap.2019.100833',24 '10.1108/IMDS-08-2018-0368',25 '10.1016/j.jsis.2018.10.002',26 '10.1109/BigDataCongress.2017.85'], [])27 28db.create_topic('Advanced Nuclear Energy Technologies',29 ['10.1016/j.pmatsci.2019.01.005',30 '10.1039/C8TA09486A',31 '10.1016/j.jclepro.2018.05.271',32 '10.1016/j.jclepro.2018.01.262',33 '10.1016/j.apenergy.2018.03.002'], [])34 35db.create_topic('Microelectronics',36 ['10.1038/s41586-018-0028-z',37 '10.1038/s41586-018-0028-z',38 '10.1038/nphoton.2017.75',39 '10.1038/s41551-018-0335-6',40 '10.1038/s41928-020-0461-5'], [])41 42db.create_topic('Renewable Energy Generation and Storage',43 ['10.4324/9780203790434',44 '10.1021/acsami.5b09515',45 '10.1038/nmat4766',46 '10.1186/s12934-018-0879-x',47 '10.1021/jacs.8b04546'], [])48 49db.create_topic('Trusted AI and Autonomy',50 ['10.1038/nature14539',51 '10.1038/nature24270',52 '10.1109/TNNLS.2016.2582924',53 '10.1109/JPROC.2017.2761740',54 '10.1145/3298981'], [])55 56db.create_topic('Space Technology',57 ['10.1093/mnras/stx721',58 '10.1051/0004-6361/201832727',59 '10.1103/PhysRevLett.121.111302',60 '10.1093/MNRAS/STX2183',61 '10.1093/mnras/stw2805'], [])62 63db.create_topic('Human-Machine Interfaces',64 ['10.1002/adfm.201504755',65 '10.1038/nature25494',66 '10.1038/s41467-017-02685-9',67 '10.1126/sciadv.1700694',68 '10.1021/acsnano.8b02477'], [])69 70db.create_topic('Advanced Computing and Software',71 ['10.1038/s41592-019-0686-2',72 '10.1137/141000671',73 '10.1016/j.future.2019.02.028',74 '10.1016/j.agsy.2017.01.023',75 '10.1080/23746149.2016.1259585'], [])76 77db.create_topic('Integrated Network Systems-of-Systems',78 ['10.1109/JSAC.2019.2906789',79 '10.1109/MIE.2017.2649104',80 '10.1109/COMST.2017.2705720',81 '10.1109/MCOM.2017.1600863',82 '10.1007/978-981-10-5861-5_5'], [])83 84db.create_topic('Future Generation Wireless Technology',85 ['10.1109/JIOT.2018.2887086',86 '10.1007/s11432-020-2955-6',87 '10.1109/MCOM.2017.1500657CM',88 '10.1109/TWC.2019.2936025',89 '10.1109/MNET.001.1900287'], [])90 91db.create_topic('Biotechnology',92 ['10.1039/c8cs00457a',93 '10.1039/c7cs00240h',94 '10.1016/j.arabjc.2015.11.015',95 '10.1038/s41467-018-04252-2',96 '10.1126/science.aaq0180'], [])97 98db.create_topic('Quantum Science',99 ['10.1103/RevModPhys.89.035002',100 '10.1038/s41586-019-1666-5',101 '10.1126/science.abe8770',102 '10.1103/RevModPhys.90.015002',103 '10.1126/sciadv.abn5130'], [])104 105db.create_topic('Advanced Materials',106 ['10.1021/ja201269b',107 '10.1002/adma.201802981',108 '10.1002/adma.201703779',109 '10.1016/j.apenergy.2018.12.018',110 '10.1016/j.est.2019.100852'], [])111 112db.create_topic('Hypersonics',113 ['10.1146/annurev-fluid-122316-045217',114 '10.1016/j.jmst.2016.08.004',115 '10.1109/TIE.2019.2892696',116 '10.1109/TIE.2017.2701776',117 '10.1016/j.ijheatmasstransfer.2018.05.013'], [])118 119db.create_topic('Directed Energy',120 ['10.1016/B978-0-08-100433-3.00013-0',121 '10.3847/2041-8213/aa8f41',122 '10.1021/acs.chemrev.6b00468',123 '10.1080/24725854.2017.1417656',124 '10.1016/j.jmatprotec.2018.08.041'], [])125 126db.create_topic('Integrated Sensing and Cyber',127 ['10.1038/s41928-020-00501-9',128 '10.1007/s10163-018-0720-y',129 '10.1007/978-981-10-7901-6_89',130 '10.1109/JSEN.2020.2998168',...

Full Screen

Full Screen

CreateDataset.py

Source:CreateDataset.py Github

copy

Full Screen

2import os3import sys4import pandas as pd5import numpy as np6def create_topic(csv_file_name, dir_name,file_no):7 8 data_dir = "/Users/surabhiravishankar/Spring/EECS499_Larry/original_csv/"9 os.chdir(data_dir)10 corpus_path = csv_file_name11 corpus_var = pd.read_csv(corpus_path)12 print "Length of Corpus = ",len(corpus_var)13 field_names = [] 14 for row in corpus_var: 15 field_names.append(row)16 # Make a data frame 17 csv_df = pd.DataFrame(corpus_var,columns=field_names)18 abstract_df = csv_df['Abstract']19 path = "/Users/surabhiravishankar/Spring/EECS499_Larry/data/"+dir_name20 21 if not os.path.exists(path):22 os.mkdir(path,0755)23 os.chdir(path)24 else: 25 print "Path already exists!!"26 exit(0)27 # writing into the files 28 for index, row in csv_df.iterrows(): 29 print "writing file ... ", index30 filename = str(file_no)+str(index)31 file1 = open(filename, "wb")32 file1.write(row['Abstract'])33 34def main(): 35 create_topic("AddAdhd.csv","AddAdhd",10)36 create_topic("Alzheimers.csv","Alzheimers",30)37 create_topic("Autism.csv","Autism",50)38 create_topic("BirthControl.csv","BirthControl",70)39 create_topic("Cancer.csv","Cancer",90)40 create_topic("HivAids.csv","HivAids",10)41 create_topic("Depression.csv","Depression",110)42 create_topic("Diabetes.csv","Diabetes",130)43 create_topic("HeartDiseases.csv","HeartDiseases",150)44 create_topic("Psychology.csv","Psychology",170)45 create_topic("Schizophrenia.csv","Schizophrenia",190)46 create_topic("StemCells.csv","StemCells",210)47 create_topic("Zoology.csv","Zoology",230)48 create_topic("Genetics.csv","Genetics",250)49 create_topic("Extinction.csv","Extinction",270)50 create_topic("Biotechnology.csv","Biotechnology",290)51 create_topic("VideoGames.csv","VideoGames",310)52 create_topic("ArtificialIntelligence.csv","ArtificialIntelligence",330)53 create_topic("Robotics.csv","Robotics",350)54 create_topic("VirtualReality.csv","VirtualReality",370)55 create_topic("ComputerSecurity.csv","ComputerSecurity",390)56 create_topic("Hurricanes.csv","Hurricanes",410)57 create_topic("Geology.csv","Geology",430)58 create_topic("Water.csv","Water",450)59 create_topic("Pollution.csv","Pollution",470)60 create_topic("GlobalWarming.csv","GlobalWarming",490)61 create_topic("EarthQuakes.csv","EarthQuakes",510)62 create_topic("Climate.csv","Climate",530)63 create_topic("Astrophysics.csv","Astrophysics",550)64 create_topic("DarkMatter.csv","DarkMatter",570)65 create_topic("Blackholes.csv","Blackholes",590)66 create_topic("Dinosaurs.csv","Dinosaurs",610)67 create_topic("Moon.csv","Moon",630)68 create_topic("Mars.csv","Mars",650)69 create_topic("SolarCells.csv","SolarCells",670)70 create_topic("WindEnergy.csv","WindEnergy",690)71 create_topic("SolarEnergy.csv","SolarEnergy",710)72 create_topic("NanoTechnology.csv","NanoTechnology",730)73 create_topic("FossilFuels.csv","FossilFuels",750)74if __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 localstack 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