Best Python code snippet using lisa_python
youtube.py
Source:youtube.py
...63 'description': '',64 'url': ''65 })66 elif intent_type == 'YesFavoriteVideoIntent':67 self.ContextManager.remove_context("FavoriteVideoContext")68 self.ContextManager.handle_add_context("WatchFavoriteVideoContext")69 if "GenreKeyword" in intent:70 self.favoriteGenre = intent["GenreKeyword"]71 elif "RolePlayKeyword" in intent:72 self.favoriteGenre = intent["RolePlayKeyword"]73 elif "keyword" in self.Context:74 self.favoriteGenre = self.Context['keyword']75 if self.favoriteGenre is not '':76 rep = f"I also love {self.favoriteGenre}. Would you like to watch that?"77 response.append({78 'file': "04",79 'response': rep,80 'title': '',81 'description': '',82 'url': ''83 })84 else: 85 self.favoriteGenre = text86 rep = "I love that too! Would you like to watch one of those?"87 response.append({88 'file': "05",89 'response': rep,90 'title': '',91 'description': '',92 'url': ''93 })94 elif intent_type == 'NoFavoriteVideoIntent':95 self.ContextManager.remove_context("FavoriteVideoContext")96 self.ContextManager.handle_add_context("TriggerSampleContext")97 rep = "No problem. Sometimes it's good to start with a medeley of ASMR triggers. Would you like to watch one of those?"98 response.append({99 'file': "06",100 'response': rep,101 'title': '',102 'description': '',103 'url': ''104 })105 elif intent_type == "WatchFavoriteVideoIntent":106 self.ContextManager.remove_context("WatchFavoriteVideoContext")107 self.ContextManager.clear_context() 108 cherrypy.session["activeSkill"] = ""109 cherrypy.session["LastUtteranceCount"] = 0110 if self.favoriteGenre is not '':111 self.favoriteGenre = self.favoriteGenre + " asmr"112 response = []113 data=search_youtube(self.favoriteGenre)114 items=data['items']115 if len(items) > 0:116 response.append({117 'file': '07',118 'response': f'Here\'s a {self.favoriteGenre} video for you!',119 'title': items[0]["snippet"]["title"],120 'description': items[0]["snippet"]["description"],121 'url': "https://youtube.com/watch?v=" + items[0]["id"]["videoId"]})122 else:123 response.append({124 'file': '0',125 'response': f'Sorry we couldn\'t find {self.favoriteGenre} on Youtube!',126 'title':'',127 'description':'',128 'url':''})129 130 elif intent_type == "NoWatchFavoriteVideoIntent":131 self.ContextManager.remove_context("WatchFavoriteVideoContext")132 self.ContextManager.handle_add_context("RolePlayContext")133 rep = "No problem. I love unintentional ASMR videos. Would you like to watch one of those?"134 response.append({135 'file': "08",136 'response': rep,137 'title': '',138 'description': '',139 'url': ''140 })141 elif intent_type == "YesRolePlayVideoIntent":142 self.ContextManager.remove_context("RolePlayContext")143 self.ContextManager.handle_add_context("RolePlayGenreContext")144 rep = "Do you have a favorite unintentional ASMR scenario?"145 response.append({146 'file': "09",147 'response': rep,148 'title': '',149 'description': '',150 'url': ''151 })152 elif intent_type == "NoRolePlayVideoIntent":153 self.ContextManager.remove_context("RolePlayContext")154 self.ContextManager.handle_add_context("NailTappingVideo")155 rep = "Got it. How an hour of nails tapping?"156 response.append({157 'file': "10",158 'response': rep,159 'title': '',160 'description': '',161 'url': ''162 })163 elif intent_type == "RolePlayGenreIntent":164 self.ContextManager.remove_context("RolePlayGenreContext")165 self.ContextManager.clear_context() 166 cherrypy.session["activeSkill"] = ""167 cherrypy.session["LastUtteranceCount"] = 0168 if "RolePlayKeyword" in intent:169 self.rolePlayGenre = intent["RolePlayKeyword"]170 reply = f"Here's a {self.rolePlayGenre} ASMR video!"171 elif "keyword" in self.Context:172 self.rolePlayGenre = self.Context['keyword']173 reply = f"Here's a {self.rolePlayGenre} ASMR video!"174 else: 175 self.rolePlayGenre = "forest"176 reply = f"I'm sorry I couldn't understand you! Here's an unintentional {self.rolePlayGenre} ASMR video!"177 response = []178 data=search_youtube(self.rolePlayGenre + " asmr")179 items=data['items']180 if len(items) > 0:181 response.append({182 'file': '11',183 'response': reply,184 'title': items[0]["snippet"]["title"],185 'description': items[0]["snippet"]["description"],186 'url': "https://youtube.com/watch?v=" + items[0]["id"]["videoId"]})187 else:188 response.append({189 'file': '0',190 'response': f'Sorry we couldn\'t find {self.rolePlayGenre} on Youtube!',191 'title':'',192 'description':'',193 'url':''})194 195 elif intent_type == "NoRolePlayGenreIntent":196 self.ContextManager.remove_context("RolePlayGenreContext")197 self.ContextManager.clear_context() 198 cherrypy.session["activeSkill"] = ""199 cherrypy.session["LastUtteranceCount"] = 0200 response = []201 data=search_youtube("lost in forest ASMR")202 items=data['items']203 if len(items) > 0:204 response.append({205 'file': '12',206 'response': "I love lost in forest ASMR videos. Here you go!",207 'title': items[0]["snippet"]["title"],208 'description': items[0]["snippet"]["description"],209 'url': "https://youtube.com/watch?v=" + items[0]["id"]["videoId"]})210 else:211 response.append({212 'file': '0',213 'response': f'Sorry I couldn\'t find what I was looking for on Youtube!',214 'title':'',215 'description':'',216 'url':''})217 218 elif intent_type == "YesTriggerVideoIntent":219 self.ContextManager.remove_context("TriggerSampleContext")220 self.ContextManager.clear_context() 221 cherrypy.session["activeSkill"] = ""222 cherrypy.session["LastUtteranceCount"] = 0223 response = []224 data=search_youtube("ASMR triggers")225 items=data['items']226 if len(items) > 0:227 response.append({228 'file': '13',229 'response': "Here's a great ASMR trigger video for you!",230 'title': items[0]["snippet"]["title"],231 'description': items[0]["snippet"]["description"],232 'url': "https://youtube.com/watch?v=" + items[0]["id"]["videoId"]})233 else:234 response.append({235 'file': '0',236 'response': f'Sorry I couldn\'t find what I was looking for on Youtube!',237 'title':'',238 'description':'',239 'url':''})240 elif intent_type == "NoTriggerVideoIntent":241 self.ContextManager.remove_context("TriggerSampleContext")242 self.ContextManager.handle_add_context("NailTappingVideo")243 rep = "How about an hour of nail-tapping?"244 response.append({245 'file': "14",246 'response': rep,247 'title': '',248 'description': '',249 'url': ''250 })251 elif intent_type == "YesNailsVideoIntent":252 self.ContextManager.remove_context("NailTappingVideo")253 self.ContextManager.clear_context() 254 cherrypy.session["activeSkill"] = ""255 cherrypy.session["LastUtteranceCount"] = 0256 response = []257 data=search_youtube("ASMR nails hour")258 items=data['items']259 if len(items) > 0:260 response.append({261 'file': '15',262 'response': "Here's an hour of nail-tapping for you!",263 'title': items[0]["snippet"]["title"],264 'description': items[0]["snippet"]["description"],265 'url': "https://youtube.com/watch?v=" + items[0]["id"]["videoId"]})266 else:267 response.append({268 'file': '0',269 'response': f'Sorry I couldn\'t find what I was looking for on Youtube!',270 'title':'',271 'description':'',272 'url':''})273 elif intent_type == "NoNailsVideoIntent":274 self.ContextManager.remove_context("NailTappingVideo")275 self.ContextManager.clear_context() 276 cherrypy.session["activeSkill"] = ""277 cherrypy.session["LastUtteranceCount"] = 0278 response = []279 data=search_youtube("ASMR ephemeral rift")280 items=data['items']281 if len(items) > 0:282 response.append({283 'file': '16',284 'response': "OK, here's a great ASMRtist instead",285 'title': items[0]["snippet"]["title"],286 'description': items[0]["snippet"]["description"],287 'url': "https://youtube.com/watch?v=" + items[0]["id"]["videoId"]})288 else:...
tea.py
Source:tea.py
...32 'file': "01",33 'response': rep 34 })35 elif intent_type == 'YesHoneyIntent':36 self.ContextManager.remove_context('HoneyContext') 37 self.ContextManager.handle_add_context('EndContext')38 honey = True39 if milk:40 rep = f"Sure, here's some {teaType} tea with milk and honey"41 response.append({42 'file': "02",43 'response': rep 44 })45 else: 46 rep = f"Here's your {teaType} tea with honey but no milk"47 response.append({48 'file': "03",49 'response': rep 50 })51 elif intent_type == 'NoHoneyIntent':52 self.ContextManager.remove_context('HoneyContext')53 self.ContextManager.handle_add_context('EndContext')54 honey = False55 if milk:56 rep = f"Here's your {teaType} tea with milk and no honey."57 response.append({58 'file': "04",59 'response': rep 60 })61 else: 62 rep = f"Here's your {teaType} tea without milk and honey"63 response.append({64 'file': "05",65 'response': rep 66 })67 elif intent_type == 'YesMilkIntent':68 self.ContextManager.remove_context('MilkContext')69 self.ContextManager.handle_add_context('HoneyContext')70 milk = True71 rep = "How about honey?"72 response.append({73 'file': "06",74 'response': rep 75 })76 elif intent_type == 'NoMilkIntent':77 self.ContextManager.remove_context('MilkContext') 78 self.ContextManager.handle_add_context('HoneyContext')79 milk = False80 rep = "No milk, but honey?"81 response.append({82 'file': "07",83 'response': rep 84 })85 elif intent_type == 'TeaTypeIntent':86 self.ContextManager.remove_context('TeaContext')87 self.ContextManager.handle_add_context('MilkContext')88 teaType = intent["TeaTypeKeyword"]89 rep = "Sure, do you want milk?"90 response.append({91 'file': "08",92 'response': rep 93 })94 elif intent_type == 'NoTeaTypeIntent':95 self.ContextManager.remove_context('TeaContext') 96 self.ContextManager.handle_add_context('MilkContext')97 rep = "Sure, green tea it will be. Do you want milk?"98 response.append({99 'file': "09",100 'response': rep 101 })102 elif intent_type == 'WelcomeIntent':103 self.ContextManager.clear_context()104 cherrypy.session["activeSkill"] = ""105 cherrypy.session["LastUtteranceCount"] = 0 106 rep = f"You're welcome!! Enjoy your {teaType} tea"107 response.append({108 'file': "10",109 'response': rep ...
test_utils.py
Source:test_utils.py
1from open_anonymizer.utils import *2def test_remove_context():3 assert "XXX" == remove_context("PERSON_1")4 assert "XXX" == remove_context("LOCATION_12")5 assert "XXX" == remove_context("ORG_3")6 assert "XXX" == remove_context("EMAIL_1")7 assert "XXX" == remove_context("PHONE_2")8 assert "XXX" == remove_context("DATE_5")9 assert "XXX" == remove_context("NUMBER_10")10 assert "XXX" == remove_context("NUMBER_1_12")11 assert "mein Name ist XXX, ich wohne in XXX" == remove_context(12 "mein Name ist PERSON_12, ich wohne in LOCATION_1"...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!