Best Python code snippet using toolium_python
ddr_models.py
Source:ddr_models.py
...3from sqlalchemy.orm import relationship, backref4from database import Base5from models.location import OSMLocation67def get_attribute(root, key, repeatable = False) :8 if isinstance(key, str) :9 return root.get(key, default=None)10 elif isclass(key) :11 if not repeatable :12 return key(root.find(key.__name__)) if root.find(key.__name__) != None else None13 else :14 return [key(xml_tmp) for xml_tmp in root.findall(key.__name__) if xml_tmp != None]151617"""18Class represents document19get XML in constructor20read attributes from XML or create "subclass" (vnorene objekty)21"""22class DOC(Base) :23 """zapouzdÅuje celý dokument pro výmÄnu informacÃ"""24 __tablename__ = 'DOC'25 obj_id = Column(Integer, primary_key=True)2627 value = Column(Text)2829 file_name = Column(Text)3031 version = Column(Text)32 id = Column(Text)33 country = Column(Text)34 DataSet = Column(Text)3536 INF_id = Column(Integer, ForeignKey('INF.obj_id'))37 INF = relationship("INF", backref=backref('DOC', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)3839 MJD_id = Column(Integer, ForeignKey('MJD.obj_id'))40 MJD = relationship("MJD", backref=backref('DOC', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)4142 def __init__(self, root_xml=None, file_name=None):43 if root_xml == None :44 return4546 self.value = root_xml.text4748 self.file_name = file_name4950 self.version = get_attribute(root_xml, "version")51 self.id = get_attribute(root_xml, "id")52 self.country = get_attribute(root_xml, "country")53 self.DataSet = get_attribute(root_xml, "DataSet")5455 self.INF = get_attribute(root_xml, INF)56 self.MJD = get_attribute(root_xml, MJD)5758 def __repr__(self):59 return '<DOC %r>' % (self.id)6061class INF(Base) :62 """Informace o subjektech, které si vymÄÅujà XML dokument"""63 __tablename__ = 'INF'64 obj_id = Column(Integer, primary_key=True)6566 value = Column(Text)6768 sender = Column(Text)69 receiver = Column(Text)70 transmission = Column(Text)7172 DAT_id = Column(Integer, ForeignKey('DAT.obj_id'))73 DAT = relationship("DAT", backref=backref('INF', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)7475 def __init__(self, root_xml):76 if root_xml == None :77 return7879 self.value = root_xml.text8081 self.sender = get_attribute(root_xml, "sender")82 self.receiver = get_attribute(root_xml, "receiver")83 self.transmission = get_attribute(root_xml, "transmission") 8485 self.DAT = get_attribute(root_xml, DAT)8687class DAT(Base) :88 """TAG zapouzdÅujÃcà informace o verzÃch jednotlivých datových sad"""89 __tablename__ = 'DAT'90 obj_id = Column(Integer, primary_key=True)9192 value = Column(Text)9394 EVTT_id = Column(Integer, ForeignKey('EVTT.obj_id'))95 EVTT = relationship("EVTT", backref=backref('DAT', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)9697 SNET_id = Column(Integer, ForeignKey('SNET.obj_id'))98 SNET = relationship("SNET", backref=backref('DAT', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)99100 UIRADR_id = Column(Integer, ForeignKey('UIRADR.obj_id'))101 UIRADR = relationship("UIRADR", backref=backref('DAT', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)102103 def __init__(self, root_xml):104 if root_xml == None :105 return106107 self.value = root_xml.text108109 self.EVTT = get_attribute(root_xml, EVTT)110 self.SNET = get_attribute(root_xml, SNET)111 self.UIRADR = get_attribute(root_xml, UIRADR)112113class EVTT(Base) :114 """Obsahuje informace o katalogu událostà Alert-C"""115 __tablename__ = 'EVTT'116 obj_id = Column(Integer, primary_key=True)117118 value = Column(Text)119120 version = Column(Text)121 language = Column(Text)122 123 def __init__(self, root_xml):124 if root_xml == None :125 return126127 self.value = root_xml.text128 129 self.version = get_attribute(root_xml, "version")130 self.language = get_attribute(root_xml, "language") 131132class SNET(Base) :133 """Informace o datové sadÄ sÃtÄ komunikacÃ, na kterou jsou lokalizovány dopravnà události"""134 __tablename__ = 'SNET'135 obj_id = Column(Integer, primary_key=True)136137 value = Column(Text)138139 type = Column(Text)140 version = Column(Text)141 country = Column(Text)142143 def __init__(self, root_xml):144 if root_xml == None :145 return146147 self.value = root_xml.text148149 self.type = get_attribute(root_xml, "type")150 self.version = get_attribute(root_xml, "version")151 self.country = get_attribute(root_xml, "country") 152153class UIRADR(Base) :154 """Informace o datové sadÄ UIADR"""155 __tablename__ = 'UIRADR'156 obj_id = Column(Integer, primary_key=True)157158 value = Column(Text)159160 structure = Column(Text)161 version = Column(Text)162 date = Column(Text)163 164 def __init__(self, root_xml):165 if root_xml == None :166 return167168 self.value = root_xml.text169170 self.structure = get_attribute(root_xml, "structure")171 self.version = get_attribute(root_xml, "version")172 self.date = get_attribute(root_xml, "date")173174class MJD(Base) :175 """ZapouzdÅuje veÅ¡keré informace o dopravnÃch informacÃch."""176 __tablename__ = 'MJD'177 obj_id = Column(Integer, primary_key=True)178179 value = Column(Text)180181 count = Column(Text)182183 MSG = relationship("MSG", cascade="all, delete-orphan", single_parent=True)184185 def __init__(self, root_xml):186 if root_xml == None :187 return188189 self.value = root_xml.text190 191 self.count = get_attribute(root_xml, "count")192193 self.MSG = get_attribute(root_xml, MSG, repeatable=True)194195class MSG(Base) :196 """TAG zapouzdÅujÃcà jednu zprávu v dokumentu"""197 __tablename__ = 'MSG'198 obj_id = Column(Integer, primary_key=True)199200 MJD_id = Column(Integer, ForeignKey('MJD.obj_id'))201202 value = Column(Text)203204 id = Column(Text)205 version = Column(Text)206 type = Column(Text)207 planned = Column(Text)208209 MTIME_id = Column(Integer, ForeignKey('MTIME.obj_id'))210 MTIME = relationship("MTIME", backref=backref('MSG', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)211212 MTXT_id = Column(Integer, ForeignKey('MTXT.obj_id'))213 MTXT = relationship("MTXT", backref=backref('MSG', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)214215 MEVT_id = Column(Integer, ForeignKey('MEVT.obj_id'))216 MEVT = relationship("MEVT", backref=backref('MSG', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)217218 WDEST_id = Column(Integer, ForeignKey('WDEST.obj_id'))219 WDEST = relationship("WDEST", backref=backref('MSG', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)220221 MLOC_id = Column(Integer, ForeignKey('MLOC.obj_id'))222 MLOC = relationship("MLOC", backref=backref('MSG', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)223224 MDST_id = Column(Integer, ForeignKey('MDST.obj_id'))225 MDST = relationship("MDST", backref=backref('MSG', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)226227 DIVLOC_id = Column(Integer, ForeignKey('DIVLOC.obj_id'))228 DIVLOC = relationship("DIVLOC", backref=backref('MSG', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)229230 Location_id = Column(Integer, ForeignKey('OSMLocation.obj_id'))231 Location = relationship("OSMLocation", backref=backref('MSG', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)232233 def __init__(self, root_xml):234 if root_xml == None :235 return236237 self.value = root_xml.text238239 self.id = get_attribute(root_xml, "id")240 self.version = get_attribute(root_xml, "version")241 self.type = get_attribute(root_xml, "type")242 self.planned = get_attribute(root_xml, "planned") 243244 self.MTIME = get_attribute(root_xml, MTIME)245 self.MTXT = get_attribute(root_xml, MTXT)246 self.MEVT = get_attribute(root_xml, MEVT)247 self.WDEST = get_attribute(root_xml, WDEST)248 self.MLOC = get_attribute(root_xml, MLOC)249 self.MDST = get_attribute(root_xml, MDST)250 self.DIVLOC = get_attribute(root_xml, DIVLOC)251252 def set_Location(self, Location):253 self.Location = Location254255 def get_coord_object(self):256 if self.MLOC:257 if self.MLOC.SNTL :258 if self.MLOC.SNTL.COORD :259 return self.MLOC.SNTL.COORD260261 if self.WDEST :262 if self.WDEST.COORD :263 return self.WDEST.COORD264265 return None266267 def get_coordinations(self):268 if self.MLOC:269 if self.MLOC.SNTL :270 if self.MLOC.SNTL.COORD :271 return {272 "coordsystem" : self.MLOC.SNTL.coordsystem,273 "x" : self.MLOC.SNTL.COORD.x,274 "y" : self.MLOC.SNTL.COORD.y275 }276277 if self.WDEST :278 if self.WDEST.COORD :279 return {280 "coordsystem" : self.WDEST.coordsystem,281 "x" : self.WDEST.COORD.x,282 "y" : self.WDEST.COORD.y283 }284285 return None286287 def get_towncode(self):288 if self.MDST:289 if self.MDST.DEST:290 codes = [dest.TownCode for dest in self.MDST.DEST]291 return codes292293 return None294295 def get_regioncode(self):296 if self.MDST:297 if self.MDST.DEST:298 codes = [dest.RegionCode for dest in self.MDST.DEST]299 return codes300301 return None302303msg_location_id_index = Index('MSG_location_id_index', MSG.Location_id)304305class MTIME(Base) :306 """Tag zapouzdÅujÃcà Äasové informace o zprávÄ"""307 __tablename__ = 'MTIME'308 obj_id = Column(Integer, primary_key=True)309310 value = Column(Text)311312 format = Column(Text)313314 TGEN_id = Column(Integer, ForeignKey('TGEN.obj_id'))315 TGEN = relationship("TGEN", backref=backref('MTIME', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)316317 TSTA_id = Column(Integer, ForeignKey('TSTA.obj_id'))318 TSTA = relationship("TSTA", backref=backref('MTIME', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)319320 TSTO_id = Column(Integer, ForeignKey('TSTO.obj_id'))321 TSTO = relationship("TSTO", backref=backref('MTIME', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)322323 def __init__(self, root_xml):324 if root_xml == None :325 return326327 self.value = root_xml.text328 329 self.format = get_attribute(root_xml, "format")330 331 self.TGEN = get_attribute(root_xml, TGEN)332 self.TSTA = get_attribute(root_xml, TSTA)333 self.TSTO = get_attribute(root_xml, TSTO)334335class TGEN(Base) :336 """Äas kdy byla zpráva vygenerována"""337 __tablename__ = 'TGEN'338 obj_id = Column(Integer, primary_key=True)339340 value = Column(Text)341 342 def __init__(self, root_xml):343 if root_xml == None :344 return345346 self.value = root_xml.text347348class TSTA(Base) :349 """Äas od kdy zpráva platà nebo bude platná"""350 __tablename__ = 'TSTA'351 obj_id = Column(Integer, primary_key=True)352353 value = Column(Text)354 355 def __init__(self, root_xml):356 if root_xml == None :357 return358359 self.value = root_xml.text360361class TSTO(Base) :362 """Äas do kdy bude zpráva platná"""363 __tablename__ = 'TSTO'364 obj_id = Column(Integer, primary_key=True)365366 value = Column(Text)367 368 def __init__(self, root_xml):369 if root_xml == None :370 return371372 self.value = root_xml.text373374class MTXT(Base) :375 """Kompletnà textový popis události vyjadÅujÃcà KDE, CO, KDY, pÅÃpadnÄ JAK dlouho."""376 __tablename__ = 'MTXT'377 obj_id = Column(Integer, primary_key=True)378379 value = Column(Text)380381 language = Column(Text)382 383 def __init__(self, root_xml):384 if root_xml == None :385 return386387 self.value = root_xml.text388389 self.language = get_attribute(root_xml, "language") 390391class MEVT(Base) :392 """zapouzdÅuje veÅ¡keré informace o události"""393 __tablename__ = 'MEVT'394 obj_id = Column(Integer, primary_key=True)395396 value = Column(Text)397398 TMCE_id = Column(Integer, ForeignKey('TMCE.obj_id'))399 TMCE = relationship("TMCE", backref=backref('MEVT', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)400401 WCOND_id = Column(Integer, ForeignKey('WCOND.obj_id'))402 WCOND = relationship("WCOND", backref=backref('MEVT', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)403404 MTNCOND_id = Column(Integer, ForeignKey('MTNCOND.obj_id'))405 MTNCOND = relationship("MTNCOND", backref=backref('MEVT', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)406407 OTXT_id = Column(Integer, ForeignKey('OTXT.obj_id'))408 OTXT = relationship("OTXT", backref=backref('MEVT', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)409410 def __init__(self, root_xml):411 if root_xml == None :412 return413414 self.value = root_xml.text415416 self.TMCE = get_attribute(root_xml, TMCE)417 self.WCOND = get_attribute(root_xml, WCOND)418 self.MTNCOND = get_attribute(root_xml, MTNCOND)419 self.OTXT = get_attribute(root_xml, OTXT)420421class TMCE(Base) :422 """zapouzdÅuje veÅ¡keré TMC informace o události, atributy jsou vázány na normu 14819-1"""423 __tablename__ = 'TMCE'424 obj_id = Column(Integer, primary_key=True)425426 value = Column(Text)427428 urgencyvalue = Column(Text)429 directionalityvalue = Column(Text)430 timescalevalue = Column(Text)431 durationtext = Column(Text)432 diversion = Column(Text)433434 EVI = relationship("EVI", cascade="all, delete-orphan", single_parent=True)435436 SPI_id = Column(Integer, ForeignKey('SPI.obj_id'))437 SPI = relationship("SPI", backref=backref('TMCE', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)438439 DIV_id = Column(Integer, ForeignKey('DIV.obj_id'))440 DIV = relationship("DIV", backref=backref('TMCE', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)441442 TXTMCE_id = Column(Integer, ForeignKey('TXTMCE.obj_id'))443 TXTMCE = relationship("TXTMCE", backref=backref('TMCE', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)444445 def __init__(self, root_xml):446 if root_xml == None :447 return448449 self.value = root_xml.text450451 self.urgencyvalue = get_attribute(root_xml, "urgencyvalue")452 self.directionalityvalue = get_attribute(root_xml, "directionalityvalue")453 self.timescalevalue = get_attribute(root_xml, "timescalevalue")454 self.durationtext = get_attribute(root_xml, "durationtext")455 self.diversion = get_attribute(root_xml, "diversion") 456457 self.EVI = get_attribute(root_xml, EVI, repeatable=True) 458 self.SPI = get_attribute(root_xml, SPI)459 self.DIV = get_attribute(root_xml, DIV)460 self.TXTMCE = get_attribute(root_xml, TXTMCE)461462class EVI(Base) :463 """Tag zapouzdÅujÃcà informace o ÄÃsle události v katalogu událostà o jeho aktualizaÄnà tÅÃdÄ,464 kvantifikátoru, poÅadà (pokud je zpráv vÃce za sebou) vÄetnÄ textového popisu aktualizaÄnà tÅÃdy a události.465 """466 __tablename__ = 'EVI'467 obj_id = Column(Integer, primary_key=True)468469 TMCE_id = Column(Integer, ForeignKey('TMCE.obj_id'))470471 value = Column(Text)472473 eventcode = Column(Text)474 updateclass = Column(Text)475 quantifier = Column(Text)476 eventorder = Column(Text)477478 TXUCL_id = Column(Integer, ForeignKey('TXUCL.obj_id'))479 TXUCL = relationship("TXUCL", backref=backref('EVI', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)480481 TXEVC_id = Column(Integer, ForeignKey('TXEVC.obj_id'))482 TXEVC = relationship("TXEVC", backref=backref('EVI', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)483484485486 def __init__(self, root_xml):487 if root_xml == None :488 return489490 self.value = root_xml.text491 492 self.eventcode = get_attribute(root_xml, "eventcode")493 self.updateclass = get_attribute(root_xml, "updateclass")494 self.quantifier = get_attribute(root_xml, "quantifier")495 self.eventorder = get_attribute(root_xml, "eventorder")496 497 self.TXUCL = get_attribute(root_xml, TXUCL)498 self.TXEVC = get_attribute(root_xml, TXEVC)499500501tmce_index = Index('TMCE_index', EVI.TMCE_id)502503class TXUCL(Base) :504 """textový popis skupiny události podle ALERT-C"""505 __tablename__ = 'TXUCL'506 obj_id = Column(Integer, primary_key=True)507508 value = Column(Text)509510 language = Column(Text)511 512 def __init__(self, root_xml):513 if root_xml == None :514 return515516 self.value = root_xml.text517518 self.language = get_attribute(root_xml, "language") 519520class TXEVC(Base) :521 """textový popis kódu události podle ALERT-C"""522 __tablename__ = 'TXEVC'523 obj_id = Column(Integer, primary_key=True)524525 value = Column(Text)526527 language = Column(Text)528 529 def __init__(self, root_xml):530 if root_xml == None :531 return532533 self.value = root_xml.text534535 self.language = get_attribute(root_xml, "language") 536537class SPI(Base) :538 """informace o ÄÃsle doplÅkové události, rychlostnÃm limitu a délce ovlivnÄného úseku komunikace"""539 __tablename__ = 'SPI'540 obj_id = Column(Integer, primary_key=True)541542 value = Column(Text)543544 supinfocode = Column(Text)545 supinfotext = Column(Text)546 speedlimit = Column(Text)547 length = Column(Text)548 549 def __init__(self, root_xml):550 if root_xml == None :551 return552553 self.value = root_xml.text554 555 self.supinfocode = get_attribute(root_xml, "supinfocode")556 self.supinfotext = get_attribute(root_xml, "supinfotext")557 self.speedlimit = get_attribute(root_xml, "speedlimit")558 self.length = get_attribute(root_xml, "length") 559560class DIV(Base) :561 """TAG zapouzdÅujÃcà informace o objÞÄce dle ALERT-C"""562 __tablename__ = 'DIV'563 obj_id = Column(Integer, primary_key=True)564565 value = Column(Text)566567 diversioncode = Column(Text)568 diversiontext = Column(Text)569 language = Column(Text)570 571 def __init__(self, root_xml):572 if root_xml == None :573 return574575 self.value = root_xml.text576 577 self.diversioncode = get_attribute(root_xml, "diversioncode")578 self.diversiontext = get_attribute(root_xml, "diversiontext")579 self.language = get_attribute(root_xml, "language") 580581class TXTMCE(Base) :582 """Text zprávy složený z hodnot jednotlivých událostà z ALERT-C katalogu událostÃ"""583 __tablename__ = 'TXTMCE'584 obj_id = Column(Integer, primary_key=True)585586 value = Column(Text)587588 language = Column(Text)589 590 def __init__(self, root_xml):591 if root_xml == None :592 return593594 self.value = root_xml.text595596 self.language = get_attribute(root_xml, "language") 597598class WCOND(Base) :599 """zapouzdÅuje informace o povÄtrnostnÃch podmÃnkách týkajÃcÃch se události typu âzimnà zpravodajstvÃâ"""600 __tablename__ = 'WCOND'601 obj_id = Column(Integer, primary_key=True)602603 value = Column(Text)604605 urgency = Column(Text)606607 TEMP_id = Column(Integer, ForeignKey('TEMP.obj_id'))608 TEMP = relationship("TEMP", backref=backref('WCOND', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)609610 CLD_id = Column(Integer, ForeignKey('CLD.obj_id'))611 CLD = relationship("CLD", backref=backref('WCOND', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)612613 PREC_id = Column(Integer, ForeignKey('PREC.obj_id'))614 PREC = relationship("PREC", backref=backref('WCOND', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)615616 WIND_id = Column(Integer, ForeignKey('WIND.obj_id'))617 WIND = relationship("WIND", backref=backref('WCOND', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)618619 VIS_id = Column(Integer, ForeignKey('VIS.obj_id'))620 VIS = relationship("VIS", backref=backref('WCOND', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)621622 WTXT_id = Column(Integer, ForeignKey('WTXT.obj_id'))623 WTXT = relationship("WTXT", backref=backref('WCOND', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)624625 TTXT_id = Column(Integer, ForeignKey('TTXT.obj_id'))626 TTXT = relationship("TTXT", backref=backref('WCOND', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)627628 def __init__(self, root_xml):629 if root_xml == None :630 return631632 self.value = root_xml.text633 634 self.urgency = get_attribute(root_xml, "urgency")635 636 self.TEMP = get_attribute(root_xml, TEMP)637 self.CLD = get_attribute(root_xml, CLD)638 self.PREC = get_attribute(root_xml, PREC)639 self.WIND = get_attribute(root_xml, WIND)640 self.VIS = get_attribute(root_xml, VIS)641 self.WTXT = get_attribute(root_xml, WTXT)642 self.TTXT = get_attribute(root_xml, TTXT)643644class TEMP(Base) :645 """informace o teplotÄ definovanou rozsahem od-do ve zpravodajské oblasti"""646 __tablename__ = 'TEMP'647 obj_id = Column(Integer, primary_key=True)648649 value = Column(Text)650651 unit = Column(Text)652 from_t = Column(Text)653 to_t = Column(Text)654 655 def __init__(self, root_xml):656 if root_xml == None :657 return658659 self.value = root_xml.text660 661 self.unit = get_attribute(root_xml, "unit")662 self.from_t = get_attribute(root_xml, "from_t")663 self.to_t = get_attribute(root_xml, "to_t") 664665class CLD(Base) :666 """informace o oblaÄnosti ve zpravodajské oblasti"""667 __tablename__ = 'CLD'668 obj_id = Column(Integer, primary_key=True)669670 value = Column(Text)671672 CloudyCode = Column(Text)673 language = Column(Text)674 675 def __init__(self, root_xml):676 if root_xml == None :677 return678679 self.value = root_xml.text680 681 self.CloudyCode = get_attribute(root_xml, "CloudyCode")682 self.language = get_attribute(root_xml, "language") 683684class PREC(Base) :685 """informace o srážkách ve zpravodajské oblasti"""686 __tablename__ = 'PREC'687 obj_id = Column(Integer, primary_key=True)688689 value = Column(Text)690691 PrecipitationCode = Column(Text)692 language = Column(Text)693 694 def __init__(self, root_xml):695 if root_xml == None :696 return697698 self.value = root_xml.text699 700 self.PrecipitationCode = get_attribute(root_xml, "PrecipitationCode")701 self.language = get_attribute(root_xml, "language") 702703class WIND(Base) :704 """informace o sÃle a smÄru vÄtru ve zpravodajské oblasti"""705 __tablename__ = 'WIND'706 obj_id = Column(Integer, primary_key=True)707708 value = Column(Text)709710 WindCode = Column(Text)711 WindDirectionCode = Column(Text)712 language = Column(Text)713 714 def __init__(self, root_xml):715 if root_xml == None :716 return717718 self.value = root_xml.text719 720 self.WindCode = get_attribute(root_xml, "WindCode")721 self.WindDirectionCode = get_attribute(root_xml, "WindDirectionCode")722 self.language = get_attribute(root_xml, "language") 723724class VIS(Base) :725 """informace o viditelnosti ve zpravodajské oblasti"""726 __tablename__ = 'VIS'727 obj_id = Column(Integer, primary_key=True)728729 value = Column(Text)730731 VisibilityCode = Column(Text)732 language = Column(Text)733 734 def __init__(self, root_xml):735 if root_xml == None :736 return737738 self.value = root_xml.text739740 self.VisibilityCode = get_attribute(root_xml, "VisibilityCode")741 self.language = get_attribute(root_xml, "language") 742743class WTXT(Base) :744 """agregovaná textová informace o povÄtrnostnÃch podmÃnkách ve zpravodajské oblasti"""745 __tablename__ = 'WTXT'746 obj_id = Column(Integer, primary_key=True)747748 value = Column(Text)749750 language = Column(Text)751 752 def __init__(self, root_xml):753 if root_xml == None :754 return755756 self.value = root_xml.text757 758 self.language = get_attribute(root_xml, "language") 759760class TTXT(Base) :761 """agregovaná textová informace o teplotnÃch podmÃnkách ve zpravodajské oblasti"""762 __tablename__ = 'TTXT'763 obj_id = Column(Integer, primary_key=True)764765 value = Column(Text)766767 language = Column(Text)768 769 def __init__(self, root_xml):770 if root_xml == None :771 return772773 self.value = root_xml.text774775 self.language = get_attribute(root_xml, "language") 776777class MTNCOND(Base) :778 """zapouzdÅuje informace o sjÃzdnosti a stavu povrchu u sledovaných Äástà silniÄnà sÃtÄ (tÅÃdy komunikace, Äást komunikace apod.)"""779 __tablename__ = 'MTNCOND'780 obj_id = Column(Integer, primary_key=True)781782 value = Column(Text)783784 ISTN = relationship("ISTN", cascade="all, delete-orphan", single_parent=True)785 786 def __init__(self, root_xml):787 if root_xml == None :788 return789790 self.value = root_xml.text791 792 self.ISTN = get_attribute(root_xml, ISTN, repeatable=True)793794class ISTN(Base) :795 """zapouzdÅuje informace o sjÃzdnosti a stavu povrchu u sledovaných Äástà silniÄnà sÃtÄ (tÅÃdy komunikace, Äást komunikace apod.)"""796 __tablename__ = 'ISTN'797 obj_id = Column(Integer, primary_key=True)798799 MTNCOND_id = Column(Integer, ForeignKey('MTNCOND.obj_id'))800801 value = Column(Text)802803 InterestsSectionCode = Column(Text)804 InterestsSectionName = Column(Text)805 urgency = Column(Text)806807 RCOND_id = Column(Integer, ForeignKey('RCOND.obj_id'))808 RCOND = relationship("RCOND", backref=backref('ISTN', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)809810 RSCOND_id = Column(Integer, ForeignKey('RSCOND.obj_id'))811 RSCOND = relationship("RSCOND", backref=backref('ISTN', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)812813 TXISTN_id = Column(Integer, ForeignKey('TXISTN.obj_id'))814 TXISTN = relationship("TXISTN", backref=backref('ISTN', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)815 816 def __init__(self, root_xml):817 if root_xml == None :818 return819820 self.value = root_xml.text821822 823 self.InterestsSectionCode = get_attribute(root_xml, "InterestsSectionCode")824 self.InterestsSectionName = get_attribute(root_xml, "InterestsSectionName")825 self.urgency = get_attribute(root_xml, "urgency")826 827 self.RCOND = get_attribute(root_xml, RCOND)828 self.RSCOND = get_attribute(root_xml, RSCOND)829 self.TXISTN = get_attribute(root_xml, TXISTN)830831class RCOND(Base) :832 """informace o sjÃzdnosti"""833 __tablename__ = 'RCOND'834 obj_id = Column(Integer, primary_key=True)835836 value = Column(Text)837838 RoadConditionCode = Column(Text)839 language = Column(Text)840 841 def __init__(self, root_xml):842 if root_xml == None :843 return844845 self.value = root_xml.text846 847 self.RoadConditionCode = get_attribute(root_xml, "RoadConditionCode")848 self.language = get_attribute(root_xml, "language") 849850class RSCOND(Base) :851 """informace o stavu povrchu vozovky"""852 __tablename__ = 'RSCOND'853 obj_id = Column(Integer, primary_key=True)854855 value = Column(Text)856857 RoadSurfaceConditionCode = Column(Text)858 language = Column(Text)859860 def __init__(self, root_xml):861 if root_xml == None :862 return863864 self.value = root_xml.text865 866 self.RoadSurfaceConditionCode = get_attribute(root_xml, "RoadSurfaceConditionCode")867 self.language = get_attribute(root_xml, "language") 868869class TXISTN(Base) :870 """agregovaná textová informace o sjÃzdnosti stavu povrchu vozovky"""871 __tablename__ = 'TXISTN'872 obj_id = Column(Integer, primary_key=True)873874 value = Column(Text)875876 language = Column(Text)877 878 def __init__(self, root_xml):879 if root_xml == None :880 return881882 self.value = root_xml.text883 884 self.language = get_attribute(root_xml, "language") 885886class WDEST(Base) :887 """zapouzdÅuje informace o mÃstu a názvu zpravodajské oblasti"""888 __tablename__ = 'WDEST'889 obj_id = Column(Integer, primary_key=True)890891 value = Column(Text)892893 coordsystem = Column(Text)894 NewsRegionCode = Column(Text)895 NewsRegionName = Column(Text)896897 COORD_id = Column(Integer, ForeignKey('COORD.obj_id'))898 COORD = relationship("COORD", backref=backref('WDEST', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)899 900 def __init__(self, root_xml):901 if root_xml == None :902 return903904 self.value = root_xml.text905 906 self.coordsystem = get_attribute(root_xml, "coordsystem")907 self.NewsRegionCode = get_attribute(root_xml, "NewsRegionCode")908 self.NewsRegionName = get_attribute(root_xml, "NewsRegionName")909 910 self.COORD = get_attribute(root_xml, COORD)911912class OTXT(Base) :913 """Volný text zadaný operátorem"""914 __tablename__ = 'OTXT'915 obj_id = Column(Integer, primary_key=True)916917 value = Column(Text)918 919 def __init__(self, root_xml):920 if root_xml == None :921 return922923 self.value = root_xml.text924925class MLOC(Base) :926 """TAG zapouzdÅujÃcà informace o mÃstu události"""927 __tablename__ = 'MLOC'928 obj_id = Column(Integer, primary_key=True)929930 value = Column(Text)931932 TXPL_id = Column(Integer, ForeignKey('TXPL.obj_id'))933 TXPL = relationship("TXPL", backref=backref('MLOC', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)934935 TMCL_id = Column(Integer, ForeignKey('TMCL.obj_id'))936 TMCL = relationship("TMCL", backref=backref('MLOC', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)937938 SNTL_id = Column(Integer, ForeignKey('SNTL.obj_id'))939 SNTL = relationship("SNTL", backref=backref('MLOC', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)940 941 def __init__(self, root_xml):942 if root_xml == None :943 return944945 self.value = root_xml.text946 947 self.TXPL = get_attribute(root_xml, TXPL)948 self.TMCL = get_attribute(root_xml, TMCL)949 self.SNTL = get_attribute(root_xml, SNTL)950951class TXPL(Base) :952 """textová informace popisujÃcà mÃsto události nebo trasu objÞÄky"""953 __tablename__ = 'TXPL'954 obj_id = Column(Integer, primary_key=True)955956 value = Column(Text)957 958 def __init__(self, root_xml):959 if root_xml == None :960 return961962 self.value = root_xml.text963964class TMCL(Base) :965 """TAG zapouzdÅujÃcà informace o mÃstu události zakódované pomocà lokalizaÄnà databáze"""966 __tablename__ = 'TMCL'967 obj_id = Column(Integer, primary_key=True)968969 value = Column(Text)970971 Primarycode = Column(Text)972 Extent = Column(Text)973 Direction = Column(Text)974 Roadid = Column(Text)975 976 def __init__(self, root_xml):977 if root_xml == None :978 return979980 self.value = root_xml.text981 982 self.Primarycode = get_attribute(root_xml, "Primarycode")983 self.Extent = get_attribute(root_xml, "Extent")984 self.Direction = get_attribute(root_xml, "Direction")985 self.Roadid = get_attribute(root_xml, "Roadid") 986987class SNTL(Base) :988 """informace o mÃstu události zadané pomocà úseků použité sÃtÄ komunikacÃ"""989 __tablename__ = 'SNTL'990 obj_id = Column(Integer, primary_key=True)991992 value = Column(Text)993994 coordsystem = Column(Text)995 count = Column(Text)996997 COORD_id = Column(Integer, ForeignKey('COORD.obj_id'))998 COORD = relationship("COORD", backref=backref('SNTL', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)9991000 STEL = relationship("STEL", cascade="all, delete-orphan", single_parent=True)1001 1002 def __init__(self, root_xml):1003 if root_xml == None :1004 return10051006 self.value = root_xml.text1007 1008 self.coordsystem = get_attribute(root_xml, "coordsystem")1009 self.count = get_attribute(root_xml, "count")1010 1011 self.COORD = get_attribute(root_xml, COORD)1012 self.STEL = get_attribute(root_xml, STEL, repeatable=True)10131014class COORD(Base) :1015 """souÅadnice události nebo zpravodajské oblasti v souÅadnicovém systému1016 definovaném v DOC\MJD\MSG\MLOC\SNTL â atribut âcoordsystemâ"""1017 __tablename__ = 'COORD'1018 obj_id = Column(Integer, primary_key=True)10191020 value = Column(Text)10211022 x = Column(Text)1023 y = Column(Text)10241025 Location_id = Column(Integer, ForeignKey('OSMLocation.obj_id'))1026 Location = relationship("OSMLocation", backref=backref('COORD', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)1027 1028 def __init__(self, root_xml, Location=None):1029 if root_xml == None :1030 return10311032 self.value = root_xml.text1033 1034 self.x = get_attribute(root_xml, "x")1035 self.y = get_attribute(root_xml, "y")10361037 self.Location = Location10381039 def set_Location(self, Location):1040 self.Location = Location10411042 def get_coordinations(self, db_session):1043 coord_encapsulation = db_session.query(SNTL).filter(SNTL.COORD == self).first()1044 if not coord_encapsulation:1045 coord_encapsulation = db_session.query(WDEST).filter(WDEST.COORD == self).first()10461047 if not coord_encapsulation:1048 raise Exception("There is not coord encapsulation!")10491050 return {1051 "coordsystem" : coord_encapsulation.coordsystem,1052 "x" : self.x,1053 "y" : self.y1054 }10551056 def get_doc_filename(self, db_session):1057 wdest_obj = db_session.query(WDEST).filter(WDEST.COORD == self).first()1058 if wdest_obj:1059 msg_obj = db_session.query(MSG).filter(MSG.WDEST == wdest_obj).first()1060 else:1061 sntl_obj = db_session.query(SNTL).filter(SNTL.COORD == self).first()10621063 if not sntl_obj:1064 return ""1065 mloc_obj = db_session.query(MLOC).filter(MLOC.SNTL == sntl_obj).first()10661067 if not mloc_obj:1068 return ""1069 msg_obj = db_session.query(MSG).filter(MSG.MLOC == mloc_obj).first()10701071 if not msg_obj:1072 return ""1073 mjd_obj = db_session.query(MJD).filter(MJD.MSG.contains(msg_obj)).first()10741075 if not mjd_obj:1076 return ""1077 doc_obj = db_session.query(DOC).filter(DOC.MJD == mjd_obj).first()10781079 return doc_obj.file_name108010811082coord_location_id_index = Index('COORD_location_id_index', COORD.Location_id)10831084class STEL(Base) :1085 """Seznam ÄÃsel ovlivnÄných úseku"""1086 __tablename__ = 'STEL'1087 obj_id = Column(Integer, primary_key=True)10881089 SNTL_id = Column(Integer, ForeignKey('SNTL.obj_id'))10901091 value = Column(Text)10921093 el_code = Column(Text)1094 1095 def __init__(self, root_xml):1096 if root_xml == None :1097 return10981099 self.value = root_xml.text1100 1101 self.el_code = get_attribute(root_xml, "el_code")11021103class MDST(Base) :1104 """Tag zapouzdÅujÃcà informace o mÃsta události v souladu s republikovým ÄÃselnÃkem UIRADR"""1105 __tablename__ = 'MDST'1106 obj_id = Column(Integer, primary_key=True)11071108 value = Column(Text)11091110 DEST = relationship("DEST", cascade="all, delete-orphan", single_parent=True)11111112 def __init__(self, root_xml):1113 if root_xml == None :1114 return11151116 self.value = root_xml.text1117 1118 self.DEST = get_attribute(root_xml, DEST, repeatable=True)11191120class DEST(Base) :1121 """Informace o názvu a kódu administrativnÃch jednotek"""1122 __tablename__ = 'DEST'1123 obj_id = Column(Integer, primary_key=True)11241125 MDST_id = Column(Integer, ForeignKey('MDST.obj_id'))11261127 value = Column(Text)11281129 CountryName = Column(Text)1130 TownDistrictName = Column(Text)1131 TownDistrictCode = Column(Text)1132 TownName = Column(Text)1133 TownCode = Column(Text)1134 TownShip = Column(Text)1135 TownShipCode = Column(Text)1136 RegionName = Column(Text)1137 RegionCode = Column(Text)11381139 STRE_id = Column(Integer, ForeignKey('STRE.obj_id'))1140 STRE = relationship("STRE", backref=backref('DEST', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)11411142 ROAD_id = Column(Integer, ForeignKey('ROAD.obj_id'))1143 ROAD = relationship("ROAD", backref=backref('DEST', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)11441145 def __init__(self, root_xml):1146 if root_xml == None :1147 return11481149 self.value = root_xml.text1150 1151 self.CountryName = get_attribute(root_xml, "CountryName")1152 self.TownDistrictName = get_attribute(root_xml, "TownDistrictName")1153 self.TownDistrictCode = get_attribute(root_xml, "TownDistrictCode")1154 self.TownName = get_attribute(root_xml, "TownName")1155 self.TownCode = get_attribute(root_xml, "TownCode")1156 self.TownShip = get_attribute(root_xml, "TownShip")1157 self.TownShipCode = get_attribute(root_xml, "TownShipCode")1158 self.RegionName = get_attribute(root_xml, "RegionName")1159 self.RegionCode = get_attribute(root_xml, "RegionCode")1160 1161 self.STRE = get_attribute(root_xml, STRE)1162 self.ROAD = get_attribute(root_xml, ROAD)11631164class STRE(Base) :1165 """Informace o administrativnà jednotce ulice"""1166 __tablename__ = 'STRE'1167 obj_id = Column(Integer, primary_key=True)11681169 value = Column(Text)11701171 StreetName = Column(Text)1172 StreetCode = Column(Text)1173 1174 def __init__(self, root_xml):1175 if root_xml == None :1176 return11771178 self.value = root_xml.text1179 1180 self.StreetName = get_attribute(root_xml, "StreetName")1181 self.StreetCode = get_attribute(root_xml, "StreetCode")11821183class ROAD(Base) :1184 """Informace o komunikaci vzhledem k UIRADR"""1185 __tablename__ = 'ROAD'1186 obj_id = Column(Integer, primary_key=True)11871188 value = Column(Text)11891190 RoadNumber = Column(Text)1191 RoadClass = Column(Text)1192 1193 def __init__(self, root_xml):1194 if root_xml == None :1195 return11961197 self.value = root_xml.text1198 1199 self.RoadNumber = get_attribute(root_xml, "RoadNumber")1200 self.RoadClass = get_attribute(root_xml, "RoadClass") 12011202class DIVLOC(Base) :1203 """TAG zapouzdÅujÃcà informace o trase objÞÄky"""1204 __tablename__ = 'DIVLOC'1205 obj_id = Column(Integer, primary_key=True)12061207 value = Column(Text)12081209 DIVROUTE = relationship("DIVROUTE", cascade="all, delete-orphan", single_parent=True)12101211 def __init__(self, root_xml):1212 if root_xml == None :1213 return12141215 self.value = root_xml.text12161217 self.DIVROUTE = get_attribute(root_xml, DIVROUTE, repeatable=True)12181219class DIVROUTE(Base) :1220 """TAG zapouzdÅujÃcà lokalizaci a detailnà informace o trase objÞÄky"""1221 __tablename__ = 'DIVROUTE'1222 obj_id = Column(Integer, primary_key=True)12231224 DIVLOC_id = Column(Integer, ForeignKey('DIVLOC.obj_id'))12251226 value = Column(Text)12271228 description = Column(Text)12291230 TXPL_id = Column(Integer, ForeignKey('TXPL.obj_id'))1231 TXPL = relationship("TXPL", backref=backref('DIVROUTE', order_by=obj_id), cascade="all, delete-orphan", single_parent=True)1232 1233 def __init__(self, root_xml):1234 if root_xml == None :1235 return12361237 self.value = root_xml.text1238 1239 self.description = get_attribute(root_xml, "description")1240 1241 self.TXPL = get_attribute(root_xml, TXPL)1242124312441245
...
main_page.py
Source:main_page.py
...41 # title42 assert 'Electric Cars, Solar & Clean Energy | Tesla' in driver.title43 print(driver.title)44 # description45 print(driver.find_element(By.XPATH, "//head/meta[2]").get_attribute("content"))46 if driver.find_element(By.XPATH, "//head/meta[2]"): # //meta[@name='description']47 print('I found the description')48 driver.find_element(By.XPATH, hp.Model_S).get_attribute("href")49 button = driver.find_element(By.XPATH, hp.Model_S)50 href_data = button.get_attribute('href')51 if href_data is None:52 is_clickable = False53 else:54 print(href_data)55 url_from_attr = driver.find_element(By.XPATH, hp.Model_S).get_attribute("href")56 url_from_attr_raw = "%r" % url_from_attr57 print(" URL from attribute -->> " + url_from_attr)58 print(" Raw string -->> " + url_from_attr_raw)59 menu = driver.find_elements_by_xpath(hp.side_menu)60 map_menu = []61 print(len(menu))62 for x in menu:63 d = {}64 t = x.get_attribute('textContent')65 l = x.get_attribute('href')66 r = requests.get(l)67 d['name'] = t68 d['link'] = l69 d['status code'] = r.status_code70 if r.status_code != 200:71 print(f'Fail!!! - {t}, {l}, Status Code is {r.status_code}')72 else:73 print(f'OK - {t}, {l}')74 map_menu.append(d)75 with open('output_chrome1.json', 'w') as json_file:76 json.dump(map_menu, open('output_chrome1.json', 'w'))77 # assertion header78 assert (driver.find_element(By.XPATH, hp.Model_3).get_attribute("href"))79 assert (driver.find_element(By.XPATH, hp.Model_X).get_attribute("href"))80 assert (driver.find_element(By.XPATH, hp.Model_Y).get_attribute("href"))81 assert (driver.find_element(By.XPATH, hp.Solar_Roof).get_attribute("href"))82 assert (driver.find_element(By.XPATH, hp.Solar_Panels).get_attribute("href"))83 assert (driver.find_element(By.XPATH,hp.Shop).get_attribute("href"))84 assert (driver.find_element(By.XPATH, hp.Account).get_attribute("href"))85 # driver.find_element(By.XPATH, "//span[contains(text(),'Menu')]").click()86 '''87 print(driver.find_element(By.XPATH, "//a[@href='/inventory/new/m3'][contains(.,'Existing Inventory')]").get_attribute("href"))88 print(driver.find_element(By.XPATH, "//a[@href='/inventory/used/m3'][contains(.,'Used Inventory')]").get_attribute("href"))89 print(driver.find_element(By.XPATH, "//a[@href='/tradein'][contains(.,'Trade-In')]").get_attribute("href"))90 print(driver.find_element(By.XPATH, "//a[@href='/drive'][contains(.,'Test Drive')]").get_attribute("href"))91 print(driver.find_element(By.XPATH, "//a[@href='/cybertruck'][contains(.,'Cybertruck')]").get_attribute("href"))92 print(driver.find_element(By.XPATH, "//a[@href='/roadster'][contains(.,'Roadster')]").get_attribute("href"))93 print(driver.find_element(By.XPATH, "//a[@href='/semi'][contains(.,'Semi')]").get_attribute("href"))94 print(driver.find_element(By.XPATH, "//a[@href='/charging'][contains(.,'Charging')]").get_attribute("href"))95 print(driver.find_element(By.XPATH, "//a[@href='/powerwall'][contains(.,'Powerwall')]").get_attribute("href"))96 print(driver.find_element(By.XPATH, "//a[@href='/commercial'][contains(.,'Commercial Energy')]").get_attribute("href"))97 print(driver.find_element(By.XPATH, "//a[@href='/utilities'][contains(.,'Utilities')]").get_attribute("href"))98 print(driver.find_element(By.XPATH, "//a[@href='/findus'][contains(.,'Find Us')]").get_attribute("href"))99 print(driver.find_element(By.XPATH, "//a[@href='/support'][contains(.,'Support')]").get_attribute("href"))100 print(driver.find_element(By.XPATH, "//a[@href='https://ir.tesla.com'][contains(.,'Investor Relations')]").get_attribute("href"))101 print(driver.find_element(By.XPATH, "//strong[contains(text(),'United States')]").get_attribute("href"))102 print(driver.find_element(By.XPATH, "//a[@href='/teslaaccount'][contains(.,'Account')]").get_attribute("href"))'''103 # scrolling104 time.sleep(3)105 assert (driver.find_element(By.XPATH, hp.logo_S))106 driver.find_element(By.XPATH, hp.btn_Custom_Order).send_keys(Keys.PAGE_DOWN)107 time.sleep(3)108 assert (driver.find_element(By.XPATH, hp.logo_Y))109 driver.find_element(By.XPATH, hp.btn_Existing_Inventory).send_keys(Keys.PAGE_DOWN)110 time.sleep(3)111 assert (driver.find_element(By.XPATH, hp.logo_3))112 driver.find_element(By.XPATH, hp.btn_Custom_Order).send_keys(Keys.PAGE_DOWN)113 time.sleep(3)114 assert (driver.find_element(By.XPATH, hp.logo_X))115 driver.find_element(By.XPATH, hp.btn_Existing_Inventory).send_keys(Keys.PAGE_DOWN)116 time.sleep(3)117 assert (driver.find_element(By.XPATH, hp.logo_Solar_Panels))118 driver.find_element(By.XPATH, hp.btn_Order_Now).send_keys(Keys.PAGE_DOWN)119 time.sleep(3)120 assert (driver.find_element(By.XPATH, hp.logo_Solar_Roof))121 driver.find_element(By.XPATH, hp.btn_Learn_More).send_keys(Keys.PAGE_DOWN)122 time.sleep(3)123 assert (driver.find_element(By.XPATH, hp.logo_Accessories))124 driver.find_element(By.XPATH, hp.btn_Shop_Now).send_keys(Keys.PAGE_DOWN)125 # assertion footer menu126 assert (driver.find_element(By.XPATH, hp.About).get_attribute("href"))127 assert (driver.find_element(By.XPATH, hp.Legal).get_attribute("href"))128 assert (driver.find_element(By.XPATH, hp.Contact).get_attribute("href"))129 assert (driver.find_element(By.XPATH, hp.Career).get_attribute("href"))130 assert (driver.find_element(By.XPATH, hp.News).get_attribute("href"))131 assert (driver.find_element(By.XPATH, hp.Engage).get_attribute("href"))132 assert (driver.find_element(By.XPATH, hp.Locations).get_attribute("href"))133 def tearDown(self):134 self.driver.quit()135class Chrome2(unittest.TestCase): # Создаем клаÑÑ ÑеÑÑа, пиÑем вÑегда (unittest.TestCase)136 def setUp(self):137 desired_cap = {138 'browser': 'Chrome',139 'browser_version': 'latest',140 'os': 'Windows',141 'os_version': '10',142 'resolution': '1920x1080',143 'name': 'Bstack-[Python] Chrome Test'144 }145 url = key.mykey1146 desired_cap['acceptSslCerts'] = True147 self.driver = webdriver.Remote(command_executor=url, desired_capabilities=desired_cap)148 # self.driver = webdriver.Chrome() #ÐÑиÑвоили дÑайвеÑÑ Ð·Ð½Ð°Ñение Chrome (иниÑиализаÑоÑ)149 # Methods in UnitTest should start from "test" keyword150 def test_1150x750(self):151 driver = self.driver # ÐÑиÑвоили Ð´Ð»Ñ ÑÑого меÑода driver = self.driver, ÑÑÐ¾Ð±Ñ Ð¾Ð±ÑаÑилÑÑÑ Ðº setUp152 driver.set_window_size(1150, 750)153 driver.get(hp.tesla_url)154 wait = WebDriverWait(driver, 3)155 wait.until(EC.element_to_be_clickable((By.XPATH, hp.tesla_logo)))156 '''driver.get(hp.tesla_url)157 driver.maximize_window()158 time.sleep(2)'''159 driver.find_element(By.XPATH, hp.tesla_logo).click() # click logo and renew page160 # title161 assert 'Electric Cars, Solar & Clean Energy | Tesla' in driver.title162 print(driver.title)163 # description164 print(driver.find_element(By.XPATH, "//head/meta[2]").get_attribute("content"))165 if driver.find_element(By.XPATH, "//head/meta[2]"): # //meta[@name='description']166 print('I found the description')167 driver.find_element(By.XPATH, hp.Model_S).get_attribute("href")168 button = driver.find_element(By.XPATH, hp.Model_S)169 href_data = button.get_attribute('href')170 if href_data is None:171 is_clickable = False172 else:173 print(href_data)174 url_from_attr = driver.find_element(By.XPATH, hp.Model_S).get_attribute("href")175 url_from_attr_raw = "%r" % url_from_attr176 print(" URL from attribute -->> " + url_from_attr)177 print(" Raw string -->> " + url_from_attr_raw)178 menu = driver.find_elements_by_xpath(hp.side_menu)179 map_menu = []180 print(len(menu))181 for x in menu:182 d = {}183 t = x.get_attribute('textContent')184 l = x.get_attribute('href')185 r = requests.get(l)186 d['name'] = t187 d['link'] = l188 d['status code'] = r.status_code189 if r.status_code != 200:190 print(f'Fail!!! - {t}, {l}, Status Code is {r.status_code}')191 else:192 print(f'OK - {t}, {l}')193 map_menu.append(d)194 with open('output_chrome2.json', 'w') as json_file:195 json.dump(map_menu, open('output_chrome2.json', 'w'))196 # assertion header197 assert (driver.find_element(By.XPATH, hp.Model_3).get_attribute("href"))198 assert (driver.find_element(By.XPATH, hp.Model_X).get_attribute("href"))199 assert (driver.find_element(By.XPATH, hp.Model_Y).get_attribute("href"))200 assert (driver.find_element(By.XPATH, hp.Solar_Roof).get_attribute("href"))201 assert (driver.find_element(By.XPATH, hp.Solar_Panels).get_attribute("href"))202 assert (driver.find_element(By.XPATH, hp.Shop).get_attribute("href"))203 assert (driver.find_element(By.XPATH, hp.Account).get_attribute("href"))204 # driver.find_element(By.XPATH, "//span[contains(text(),'Menu')]").click()205 '''206 print(driver.find_element(By.XPATH, "//a[@href='/inventory/new/m3'][contains(.,'Existing Inventory')]").get_attribute("href"))207 print(driver.find_element(By.XPATH, "//a[@href='/inventory/used/m3'][contains(.,'Used Inventory')]").get_attribute("href"))208 print(driver.find_element(By.XPATH, "//a[@href='/tradein'][contains(.,'Trade-In')]").get_attribute("href"))209 print(driver.find_element(By.XPATH, "//a[@href='/drive'][contains(.,'Test Drive')]").get_attribute("href"))210 print(driver.find_element(By.XPATH, "//a[@href='/cybertruck'][contains(.,'Cybertruck')]").get_attribute("href"))211 print(driver.find_element(By.XPATH, "//a[@href='/roadster'][contains(.,'Roadster')]").get_attribute("href"))212 print(driver.find_element(By.XPATH, "//a[@href='/semi'][contains(.,'Semi')]").get_attribute("href"))213 print(driver.find_element(By.XPATH, "//a[@href='/charging'][contains(.,'Charging')]").get_attribute("href"))214 print(driver.find_element(By.XPATH, "//a[@href='/powerwall'][contains(.,'Powerwall')]").get_attribute("href"))215 print(driver.find_element(By.XPATH, "//a[@href='/commercial'][contains(.,'Commercial Energy')]").get_attribute("href"))216 print(driver.find_element(By.XPATH, "//a[@href='/utilities'][contains(.,'Utilities')]").get_attribute("href"))217 print(driver.find_element(By.XPATH, "//a[@href='/findus'][contains(.,'Find Us')]").get_attribute("href"))218 print(driver.find_element(By.XPATH, "//a[@href='/support'][contains(.,'Support')]").get_attribute("href"))219 print(driver.find_element(By.XPATH, "//a[@href='https://ir.tesla.com'][contains(.,'Investor Relations')]").get_attribute("href"))220 print(driver.find_element(By.XPATH, "//strong[contains(text(),'United States')]").get_attribute("href"))221 print(driver.find_element(By.XPATH, "//a[@href='/teslaaccount'][contains(.,'Account')]").get_attribute("href"))'''222 # scrolling223 time.sleep(3)224 assert (driver.find_element(By.XPATH, hp.logo_S))225 driver.find_element(By.XPATH, hp.btn_Custom_Order).send_keys(Keys.PAGE_DOWN)226 time.sleep(3)227 assert (driver.find_element(By.XPATH, hp.logo_Y))228 driver.find_element(By.XPATH, hp.btn_Existing_Inventory).send_keys(Keys.PAGE_DOWN)229 time.sleep(3)230 assert (driver.find_element(By.XPATH, hp.logo_3))231 driver.find_element(By.XPATH, hp.btn_Custom_Order).send_keys(Keys.PAGE_DOWN)232 time.sleep(3)233 assert (driver.find_element(By.XPATH, hp.logo_X))234 driver.find_element(By.XPATH, hp.btn_Existing_Inventory).send_keys(Keys.PAGE_DOWN)235 time.sleep(3)236 assert (driver.find_element(By.XPATH, hp.logo_Solar_Panels))237 driver.find_element(By.XPATH, hp.btn_Order_Now).send_keys(Keys.PAGE_DOWN)238 time.sleep(3)239 assert (driver.find_element(By.XPATH, hp.logo_Solar_Roof))240 driver.find_element(By.XPATH, hp.btn_Learn_More).send_keys(Keys.PAGE_DOWN)241 time.sleep(3)242 assert (driver.find_element(By.XPATH, hp.logo_Accessories))243 driver.find_element(By.XPATH, hp.btn_Shop_Now).send_keys(Keys.PAGE_DOWN)244 # assertion footer menu245 assert (driver.find_element(By.XPATH, hp.About).get_attribute("href"))246 assert (driver.find_element(By.XPATH, hp.Legal).get_attribute("href"))247 assert (driver.find_element(By.XPATH, hp.Contact).get_attribute("href"))248 assert (driver.find_element(By.XPATH, hp.Career).get_attribute("href"))249 assert (driver.find_element(By.XPATH, hp.News).get_attribute("href"))250 assert (driver.find_element(By.XPATH, hp.Engage).get_attribute("href"))251 assert (driver.find_element(By.XPATH, hp.Locations).get_attribute("href"))252 def tearDown(self):253 self.driver.quit()254class Firefox(unittest.TestCase): # 4.Second Unit test for Firefox browser255 def setUp(self):256 desired_cap = {257 'browser': 'firefox',258 'browser_version': 'latest',259 'os': 'Windows',260 'os_version': '10',261 'resolution': '1920x1080',262 'name': 'Bstack-[Python] Chrome Test'263 }264 url = key.mykey1265 desired_cap['acceptSslCerts'] = True266 self.driver = webdriver.Remote(command_executor=url, desired_capabilities=desired_cap)267 # self.driver = webdriver.Chrome() #ÐÑиÑвоили дÑайвеÑÑ Ð·Ð½Ð°Ñение Chrome (иниÑиализаÑоÑ)268 # Methods in UnitTest should start from "test" keyword269 def test_fullscreen(self):270 driver = self.driver # ÐÑиÑвоили Ð´Ð»Ñ ÑÑого меÑода driver = self.driver, ÑÑÐ¾Ð±Ñ Ð¾Ð±ÑаÑилÑÑÑ Ðº setUp271 driver.maximize_window()272 driver.get(hp.tesla_url)273 wait = WebDriverWait(driver, 3)274 wait.until(EC.element_to_be_clickable((By.XPATH, hp.tesla_logo)))275 '''driver.get(hp.tesla_url)276 driver.maximize_window()277 time.sleep(2)'''278 driver.find_element(By.XPATH, hp.tesla_logo).click() # click logo and renew page279 # title280 assert 'Electric Cars, Solar & Clean Energy | Tesla' in driver.title281 print(driver.title)282 # description283 print(driver.find_element(By.XPATH, "//head/meta[2]").get_attribute("content"))284 if driver.find_element(By.XPATH, "//head/meta[2]"): # //meta[@name='description']285 print('I found the description')286 driver.find_element(By.XPATH, hp.Model_S).get_attribute("href")287 button = driver.find_element(By.XPATH, hp.Model_S)288 href_data = button.get_attribute('href')289 if href_data is None:290 is_clickable = False291 else:292 print(href_data)293 url_from_attr = driver.find_element(By.XPATH, hp.Model_S).get_attribute("href")294 url_from_attr_raw = "%r" % url_from_attr295 print(" URL from attribute -->> " + url_from_attr)296 print(" Raw string -->> " + url_from_attr_raw)297 menu = driver.find_elements_by_xpath(hp.side_menu)298 map_menu = []299 print(len(menu))300 for x in menu:301 d = {}302 t = x.get_attribute('textContent')303 l = x.get_attribute('href')304 r = requests.get(l)305 d['name'] = t306 d['link'] = l307 d['status code'] = r.status_code308 if r.status_code != 200:309 print(f'Fail!!! - {t}, {l}, Status Code is {r.status_code}')310 else:311 print(f'OK - {t}, {l}')312 map_menu.append(d)313 with open('output_firefox1.json', 'w') as json_file:314 json.dump(map_menu, open('output_firefox1.json', 'w'))315 # assertion header316 assert (driver.find_element(By.XPATH, hp.Model_3).get_attribute("href"))317 assert (driver.find_element(By.XPATH, hp.Model_X).get_attribute("href"))318 assert (driver.find_element(By.XPATH, hp.Model_Y).get_attribute("href"))319 assert (driver.find_element(By.XPATH, hp.Solar_Roof).get_attribute("href"))320 assert (driver.find_element(By.XPATH, hp.Solar_Panels).get_attribute("href"))321 assert (driver.find_element(By.XPATH, hp.Shop).get_attribute("href"))322 assert (driver.find_element(By.XPATH, hp.Account).get_attribute("href"))323 # driver.find_element(By.XPATH, "//span[contains(text(),'Menu')]").click()324 '''325 print(driver.find_element(By.XPATH, "//a[@href='/inventory/new/m3'][contains(.,'Existing Inventory')]").get_attribute("href"))326 print(driver.find_element(By.XPATH, "//a[@href='/inventory/used/m3'][contains(.,'Used Inventory')]").get_attribute("href"))327 print(driver.find_element(By.XPATH, "//a[@href='/tradein'][contains(.,'Trade-In')]").get_attribute("href"))328 print(driver.find_element(By.XPATH, "//a[@href='/drive'][contains(.,'Test Drive')]").get_attribute("href"))329 print(driver.find_element(By.XPATH, "//a[@href='/cybertruck'][contains(.,'Cybertruck')]").get_attribute("href"))330 print(driver.find_element(By.XPATH, "//a[@href='/roadster'][contains(.,'Roadster')]").get_attribute("href"))331 print(driver.find_element(By.XPATH, "//a[@href='/semi'][contains(.,'Semi')]").get_attribute("href"))332 print(driver.find_element(By.XPATH, "//a[@href='/charging'][contains(.,'Charging')]").get_attribute("href"))333 print(driver.find_element(By.XPATH, "//a[@href='/powerwall'][contains(.,'Powerwall')]").get_attribute("href"))334 print(driver.find_element(By.XPATH, "//a[@href='/commercial'][contains(.,'Commercial Energy')]").get_attribute("href"))335 print(driver.find_element(By.XPATH, "//a[@href='/utilities'][contains(.,'Utilities')]").get_attribute("href"))336 print(driver.find_element(By.XPATH, "//a[@href='/findus'][contains(.,'Find Us')]").get_attribute("href"))337 print(driver.find_element(By.XPATH, "//a[@href='/support'][contains(.,'Support')]").get_attribute("href"))338 print(driver.find_element(By.XPATH, "//a[@href='https://ir.tesla.com'][contains(.,'Investor Relations')]").get_attribute("href"))339 print(driver.find_element(By.XPATH, "//strong[contains(text(),'United States')]").get_attribute("href"))340 print(driver.find_element(By.XPATH, "//a[@href='/teslaaccount'][contains(.,'Account')]").get_attribute("href"))'''341 # scrolling342 time.sleep(3)343 assert (driver.find_element(By.XPATH, hp.logo_S))344 driver.find_element(By.XPATH, hp.btn_Custom_Order).send_keys(Keys.PAGE_DOWN)345 time.sleep(3)346 assert (driver.find_element(By.XPATH, hp.logo_Y))347 driver.find_element(By.XPATH, hp.btn_Existing_Inventory).send_keys(Keys.PAGE_DOWN)348 time.sleep(3)349 assert (driver.find_element(By.XPATH, hp.logo_3))350 driver.find_element(By.XPATH, hp.btn_Custom_Order).send_keys(Keys.PAGE_DOWN)351 time.sleep(3)352 assert (driver.find_element(By.XPATH, hp.logo_X))353 driver.find_element(By.XPATH, hp.btn_Existing_Inventory).send_keys(Keys.PAGE_DOWN)354 time.sleep(3)355 assert (driver.find_element(By.XPATH, hp.logo_Solar_Panels))356 driver.find_element(By.XPATH, hp.btn_Order_Now).send_keys(Keys.PAGE_DOWN)357 time.sleep(3)358 assert (driver.find_element(By.XPATH, hp.logo_Solar_Roof))359 driver.find_element(By.XPATH, hp.btn_Learn_More).send_keys(Keys.PAGE_DOWN)360 time.sleep(3)361 assert (driver.find_element(By.XPATH, hp.logo_Accessories))362 driver.find_element(By.XPATH, hp.btn_Shop_Now).send_keys(Keys.PAGE_DOWN)363 # assertion footer menu364 assert (driver.find_element(By.XPATH, hp.About).get_attribute("href"))365 assert (driver.find_element(By.XPATH, hp.Legal).get_attribute("href"))366 assert (driver.find_element(By.XPATH, hp.Contact).get_attribute("href"))367 assert (driver.find_element(By.XPATH, hp.Career).get_attribute("href"))368 assert (driver.find_element(By.XPATH, hp.News).get_attribute("href"))369 assert (driver.find_element(By.XPATH, hp.Engage).get_attribute("href"))370 assert (driver.find_element(By.XPATH, hp.Locations).get_attribute("href"))371 def tearDown(self):372 self.driver.quit()373class Firefox2(unittest.TestCase): # 4.Second Unit test for Firefox browser374 def setUp(self):375 desired_cap = {376 'browser': 'firefox',377 'browser_version': 'latest',378 'os': 'Windows',379 'os_version': '10',380 'resolution': '1920x1080',381 'name': 'Bstack-[Python] Chrome Test'382 }383 url = key.mykey1384 desired_cap['acceptSslCerts'] = True385 self.driver = webdriver.Remote(command_executor=url, desired_capabilities=desired_cap)386 # self.driver = webdriver.Chrome() #ÐÑиÑвоили дÑайвеÑÑ Ð·Ð½Ð°Ñение Chrome (иниÑиализаÑоÑ)387 # Methods in UnitTest should start from "test" keyword388 def test_1150x750(self):389 driver = self.driver # ÐÑиÑвоили Ð´Ð»Ñ ÑÑого меÑода driver = self.driver, ÑÑÐ¾Ð±Ñ Ð¾Ð±ÑаÑилÑÑÑ Ðº setUp390 driver.set_window_size(1150, 750)391 driver.get(hp.tesla_url)392 wait = WebDriverWait(driver, 3)393 wait.until(EC.element_to_be_clickable((By.XPATH, hp.tesla_logo)))394 '''driver.get(hp.tesla_url)395 driver.maximize_window()396 time.sleep(2)'''397 driver.find_element(By.XPATH, hp.tesla_logo).click() # click logo and renew page398 # title399 assert 'Electric Cars, Solar & Clean Energy | Tesla' in driver.title400 print(driver.title)401 # description402 print(driver.find_element(By.XPATH, "//head/meta[2]").get_attribute("content"))403 if driver.find_element(By.XPATH, "//head/meta[2]"): # //meta[@name='description']404 print('I found the description')405 driver.find_element(By.XPATH, hp.Model_S).get_attribute("href")406 button = driver.find_element(By.XPATH, hp.Model_S)407 href_data = button.get_attribute('href')408 if href_data is None:409 is_clickable = False410 else:411 print(href_data)412 url_from_attr = driver.find_element(By.XPATH, hp.Model_S).get_attribute("href")413 url_from_attr_raw = "%r" % url_from_attr414 print(" URL from attribute -->> " + url_from_attr)415 print(" Raw string -->> " + url_from_attr_raw)416 menu = driver.find_elements_by_xpath(hp.side_menu)417 map_menu = []418 print(len(menu))419 for x in menu:420 d = {}421 t = x.get_attribute('textContent')422 l = x.get_attribute('href')423 r = requests.get(l)424 d['name'] = t425 d['link'] = l426 d['status code'] = r.status_code427 if r.status_code != 200:428 print(f'Fail!!! - {t}, {l}, Status Code is {r.status_code}')429 else:430 print(f'OK - {t}, {l}')431 map_menu.append(d)432 with open('output_firefox1.json', 'w') as json_file:433 json.dump(map_menu, open('output_firefox1.json', 'w'))434 # assertion header435 assert (driver.find_element(By.XPATH, hp.Model_3).get_attribute("href"))436 assert (driver.find_element(By.XPATH, hp.Model_X).get_attribute("href"))437 assert (driver.find_element(By.XPATH, hp.Model_Y).get_attribute("href"))438 assert (driver.find_element(By.XPATH, hp.Solar_Roof).get_attribute("href"))439 assert (driver.find_element(By.XPATH, hp.Solar_Panels).get_attribute("href"))440 assert (driver.find_element(By.XPATH, hp.Shop).get_attribute("href"))441 assert (driver.find_element(By.XPATH, hp.Account).get_attribute("href"))442 # driver.find_element(By.XPATH, "//span[contains(text(),'Menu')]").click()443 '''444 print(driver.find_element(By.XPATH, "//a[@href='/inventory/new/m3'][contains(.,'Existing Inventory')]").get_attribute("href"))445 print(driver.find_element(By.XPATH, "//a[@href='/inventory/used/m3'][contains(.,'Used Inventory')]").get_attribute("href"))446 print(driver.find_element(By.XPATH, "//a[@href='/tradein'][contains(.,'Trade-In')]").get_attribute("href"))447 print(driver.find_element(By.XPATH, "//a[@href='/drive'][contains(.,'Test Drive')]").get_attribute("href"))448 print(driver.find_element(By.XPATH, "//a[@href='/cybertruck'][contains(.,'Cybertruck')]").get_attribute("href"))449 print(driver.find_element(By.XPATH, "//a[@href='/roadster'][contains(.,'Roadster')]").get_attribute("href"))450 print(driver.find_element(By.XPATH, "//a[@href='/semi'][contains(.,'Semi')]").get_attribute("href"))451 print(driver.find_element(By.XPATH, "//a[@href='/charging'][contains(.,'Charging')]").get_attribute("href"))452 print(driver.find_element(By.XPATH, "//a[@href='/powerwall'][contains(.,'Powerwall')]").get_attribute("href"))453 print(driver.find_element(By.XPATH, "//a[@href='/commercial'][contains(.,'Commercial Energy')]").get_attribute("href"))454 print(driver.find_element(By.XPATH, "//a[@href='/utilities'][contains(.,'Utilities')]").get_attribute("href"))455 print(driver.find_element(By.XPATH, "//a[@href='/findus'][contains(.,'Find Us')]").get_attribute("href"))456 print(driver.find_element(By.XPATH, "//a[@href='/support'][contains(.,'Support')]").get_attribute("href"))457 print(driver.find_element(By.XPATH, "//a[@href='https://ir.tesla.com'][contains(.,'Investor Relations')]").get_attribute("href"))458 print(driver.find_element(By.XPATH, "//strong[contains(text(),'United States')]").get_attribute("href"))459 print(driver.find_element(By.XPATH, "//a[@href='/teslaaccount'][contains(.,'Account')]").get_attribute("href"))'''460 # scrolling461 time.sleep(3)462 assert (driver.find_element(By.XPATH, hp.logo_S))463 driver.find_element(By.XPATH, hp.btn_Custom_Order).send_keys(Keys.PAGE_DOWN)464 time.sleep(3)465 assert (driver.find_element(By.XPATH, hp.logo_Y))466 driver.find_element(By.XPATH, hp.btn_Existing_Inventory).send_keys(Keys.PAGE_DOWN)467 time.sleep(3)468 assert (driver.find_element(By.XPATH, hp.logo_3))469 driver.find_element(By.XPATH, hp.btn_Custom_Order).send_keys(Keys.PAGE_DOWN)470 time.sleep(3)471 assert (driver.find_element(By.XPATH, hp.logo_X))472 driver.find_element(By.XPATH, hp.btn_Existing_Inventory).send_keys(Keys.PAGE_DOWN)473 time.sleep(3)474 assert (driver.find_element(By.XPATH, hp.logo_Solar_Panels))475 driver.find_element(By.XPATH, hp.btn_Order_Now).send_keys(Keys.PAGE_DOWN)476 time.sleep(3)477 assert (driver.find_element(By.XPATH, hp.logo_Solar_Roof))478 driver.find_element(By.XPATH, hp.btn_Learn_More).send_keys(Keys.PAGE_DOWN)479 time.sleep(3)480 assert (driver.find_element(By.XPATH, hp.logo_Accessories))481 driver.find_element(By.XPATH, hp.btn_Shop_Now).send_keys(Keys.PAGE_DOWN)482 # assertion footer menu483 assert (driver.find_element(By.XPATH, hp.About).get_attribute("href"))484 assert (driver.find_element(By.XPATH, hp.Legal).get_attribute("href"))485 assert (driver.find_element(By.XPATH, hp.Contact).get_attribute("href"))486 assert (driver.find_element(By.XPATH, hp.Career).get_attribute("href"))487 assert (driver.find_element(By.XPATH, hp.News).get_attribute("href"))488 assert (driver.find_element(By.XPATH, hp.Engage).get_attribute("href"))489 assert (driver.find_element(By.XPATH, hp.Locations).get_attribute("href"))490 def tearDown(self):491 self.driver.quit()492if __name__ == '__main__':...
__init__.py
Source:__init__.py
...33 META = {}34 METANodes = core.get_all_meta_nodes(active_node)35 for path in METANodes:36 node = METANodes[path]37 META[core.get_attribute(node, 'name')] = node38 children = core.load_children(active_node)39 self.model = {'name': core.get_attribute(active_node, 'name'),40 'metadata': {},41 'constant': [],42 'basicbuilder': {},43 'node': [],44 'geomTransf': [],45 'element': [],46 'analysis_pack': [],47 }48 # Let's categorize each child in the model49 for child in children:50 if core.is_type_of(child, META['MetaData']):51 self.process_metadata(child)52 elif core.is_type_of(child, META['constant']):53 self.process_constant(child)54 elif core.is_type_of(child, META['BasicBuilder']):55 self.process_basicBuilder(child)56 elif core.is_type_of(child, META['node']):57 self.process_node(child)58 elif core.is_type_of(child, META['geomTransf']):59 self.process_geomtransf(child)60 elif core.is_type_of(child, META['element']):61 self.process_element(child)62 elif core.is_type_of(child, META['rayleigh']):63 self.process_rayleigh(child)64 elif core.is_type_of(child, META['analysis_pack']):65 self.process_analysis_pack(child)66 else:67 logger.error("This is not a building block "68 "I am familiar with.\n"69 "Most probably, this is a "70 "documentation composition")71 os_code = self.get_code()72 logger.info(self.get_code())73 self.save_code(os_code)74 if self.config['simulate']:75 self.simulate_model(os_code)76 def process_metadata(self, node):77 model_data = {78 'description': self.core.get_attribute(node, 'analysis_description'),79 'name': self.core.get_attribute(node, 'analysis_name'),80 'type': self.core.get_attribute(node, 'analysis_type'),81 'unit_system': self.core.get_attribute(node, 'unit_system'),82 'author': self.core.get_attribute(node, 'author'),83 'date': self.core.get_attribute(node, 'date'),84 }85 self.model['metadata'] = model_data86 def process_constant(self, node):87 model_data = {88 'name': self.core.get_attribute(node, 'expression'),89 'parameter': self.core.get_attribute(node, 'value'),90 'comment': self.core.get_attribute(node, 'comment'),91 }92 self.model['constant'].append(model_data)93 def process_basicBuilder(self, node):94 model_data = {95 'comment': self.core.get_attribute(node, 'comment'),96 'ndf': self.core.get_attribute(node, 'ndf'),97 'ndm': self.core.get_attribute(node, 'ndm'),98 }99 self.model['basicbuilder'] = model_data100 def process_node(self, node):101 model_data = {102 'comment': self.core.get_attribute(node, 'comment'),103 'coords_dof1': self.core.get_attribute(node, 'coords_dof1'),104 'coords_dof2': self.core.get_attribute(node, 'coords_dof2'),105 'fix_dof1': self.core.get_attribute(node, 'fix_dof1'),106 'fix_dof2': self.core.get_attribute(node, 'fix_dof2'),107 'fix_dof3': self.core.get_attribute(node, 'fix_dof3'),108 'mass_dof1': self.core.get_attribute(node, 'mass_dof1'),109 'mass_dof2': self.core.get_attribute(node, 'mass_dof2'),110 'mass_dof3': self.core.get_attribute(node, 'mass_dof3'),111 'nodeTag': self.core.get_attribute(node, 'nodeTag'),112 }113 self.model['node'].append(model_data)114 def process_geomtransf(self, node):115 model_data = {116 'transfTag': self.core.get_attribute(node, 'transfTag'),117 'transfType': self.core.get_attribute(node, 'name')[11:],118 'comment': self.core.get_attribute(node, 'comment'),119 }120 self.model['geomTransf'].append(model_data)121 def process_element(self, node):122 src = self.core.load_pointer(node, 'src')123 dst = self.core.load_pointer(node, 'dst')124 if self.core.is_type_of(node, self.META['elasticBeamColumn']):125 model_data = {126 'comment': self.core.get_attribute(node, 'comment'),127 'eleType': self.core.get_attribute(node, 'name'),128 'eleTag': self.core.get_attribute(node, 'eleTag'),129 'A': self.core.get_attribute(node, 'A'),130 'E': self.core.get_attribute(node, 'E'),131 'Iz': self.core.get_attribute(node, 'Iz'),132 'cMass': self.core.get_attribute(node, 'cMass'),133 'massDens': self.core.get_attribute(node, 'massDens'),134 'transfTag': self.core.get_attribute(node, 'transfTag'),135 'src': self.core.get_attribute(src, 'nodeTag'),136 'dst': self.core.get_attribute(dst, 'nodeTag'),137 }138 self.model['element'].append(model_data)139 def process_rayleigh(self, node):140 model_data = {141 'comment': self.core.get_attribute(node, 'comment'),142 'a': self.core.get_attribute(node, 'a'),143 'b': self.core.get_attribute(node, 'b'),144 'c': self.core.get_attribute(node, 'c'),145 'd': self.core.get_attribute(node, 'd'),146 }147 self.model['rayleigh'] = model_data148 def process_analysis_pack(self, node):149 children = self.core.load_children(node)150 model_data = {151 'analysis_order': self.core.get_attribute(node, 'analysis_order'),152 'comment': self.core.get_attribute(node, 'comment'),153 }154 for child in children:155 if self.core.is_type_of(child, self.META['loadConst']):156 model_data['loadConst'] = self.process_loadconst(child)157 elif self.core.is_type_of(child, self.META['timeSeries']):158 model_data['timeSeries'] = self.process_timeseries(child)159 elif self.core.is_type_of(child, self.META['pattern']):160 model_data['pattern'] = self.process_pattern(child)161 elif self.core.is_type_of(child, self.META['system']):162 model_data['system'] = self.process_system(child)163 elif self.core.is_type_of(child, self.META['numberer']):164 model_data['numberer'] = self.process_numberer(child)165 elif self.core.is_type_of(child, self.META['constraints']):166 model_data['constraints'] = self.process_constraints(child)167 elif self.core.is_type_of(child, self.META['integrator']):168 model_data['integrator'] = self.process_integrator(child)169 elif self.core.is_type_of(child, self.META['test']):170 model_data['test'] = self.process_test(child)171 elif self.core.is_type_of(child, self.META['algorithm']):172 model_data['algorithm'] = self.process_algorithm(child)173 elif self.core.is_type_of(child, self.META['analysis']):174 model_data['analysis'] = self.process_analysis(child)175 elif self.core.is_type_of(child, self.META['analyze']):176 model_data['analyze'] = self.process_analyze(child)177 elif self.core.is_type_of(child, self.META['recorder']):178 model_data.setdefault('recorder', []).append(self.process_recorder(child))179 else:180 logger.error("This is not a building block "181 "I am familiar with.")182 self.model['analysis_pack'].append(model_data)183 def process_loadconst(self, node):184 model_data = {185 'comment': self.core.get_attribute(node, 'comment'),186 'pseudoTime': self.core.get_attribute(node, 'pseudoTime'),187 }188 return model_data189 def process_timeseries(self, node):190 model_data = {191 'comment': self.core.get_attribute(node, 'comment'),192 'tsType': self.core.get_attribute(node, 'name')[11:],193 'tag': self.core.get_attribute(node, 'tag'),194 }195 if self.core.get_attribute(node, 'name')[11:] == 'Path File':196 model_data['cFactor'] = self.core.get_attribute(node, 'cFactor')197 model_data['dt'] = self.core.get_attribute(node, 'dt')198 model_data['filePath'] = self.core.get_attribute(node, 'filePath')199 model_data['tsType'] = 'Path'200 return model_data201 def process_pattern(self, node):202 children = self.core.load_children(node)203 model_data = {204 'comment': self.core.get_attribute(node, 'comment'),205 'tsType': self.core.get_attribute(node, 'name')[8:],206 'tsTag': self.core.get_attribute(node, 'tsTag'),207 'patternTag': self.core.get_attribute(node, 'patternTag'),208 }209 for child in children:210 if self.core.is_type_of(child, self.META['load element single/multiple']):211 model_data.setdefault('eleLoad', []).append(self.process_loadelement(child))212 elif self.core.is_type_of(child, self.META['load node']):213 model_data.setdefault('nodeLoad', []).append(self.process_loadnode(child))214 if model_data['tsType'] == 'UniformExcitation':215 model_data['dir'] = self.core.get_attribute(node, 'dir')216 return model_data217 def process_loadelement(self, node):218 model_data = {219 'Wy': self.core.get_attribute(node, 'Wy'),220 'eleTag': self.core.get_attribute(node, 'eleTag'),221 }222 return model_data223 def process_loadnode(self, node):224 model_data = {225 'loadvalues': self.core.get_attribute(node, 'loadvalues'),226 'nodeTag': self.core.get_attribute(node, 'nodeTag'),227 }228 return model_data229 def process_system(self, node):230 model_data = {231 'comment': self.core.get_attribute(node, 'comment'),232 'name': self.core.get_attribute(node, 'name')[7:],233 }234 return model_data235 def process_numberer(self, node):236 model_data = {237 'comment': self.core.get_attribute(node, 'comment'),238 'name': self.core.get_attribute(node, 'name')[9:],239 }240 return model_data241 def process_constraints(self, node):242 model_data = {243 'comment': self.core.get_attribute(node, 'comment'),244 'name': self.core.get_attribute(node, 'name')[12:],245 }246 return model_data247 def process_integrator(self, node):248 model_data = {249 'comment': self.core.get_attribute(node, 'comment'),250 'name': self.core.get_attribute(node, 'name')[11:],251 }252 if model_data['name'] == 'LoadControl':253 model_data['lambda'] = self.core.get_attribute(node, 'lambda')254 if model_data['name'] == 'Newmark':255 model_data['beta'] = self.core.get_attribute(node, 'beta')256 model_data['gamma'] = self.core.get_attribute(node, 'gamma')257 return model_data258 def process_test(self, node):259 model_data = {260 'comment': self.core.get_attribute(node, 'comment'),261 'name': self.core.get_attribute(node, 'name')[5:],262 'tol': self.core.get_attribute(node, 'tol'),263 'iter': self.core.get_attribute(node, 'iter'),264 }265 return model_data266 def process_algorithm(self, node):267 model_data = {268 'name': self.core.get_attribute(node, 'name')[10:],269 'comment': self.core.get_attribute(node, 'comment'),270 }271 return model_data272 def process_analysis(self, node):273 model_data = {274 'name': self.core.get_attribute(node, 'name')[9:],275 'comment': self.core.get_attribute(node, 'comment'),276 }277 return model_data278 def process_analyze(self, node):279 model_data = {280 'numIncr': self.core.get_attribute(node, 'numIncr'),281 'comment': self.core.get_attribute(node, 'comment'),282 }283 if self.core.get_attribute(node, 'dT'):284 model_data['dT'] = self.core.get_attribute(node, 'dT')285 return model_data286 def process_recorder(self, node):287 if self.core.is_type_of(node, self.META['recorder Element']):288 model_data = {289 'name': self.core.get_attribute(node, 'name')[9:],290 'file': self.core.get_attribute(node, 'file'),291 'fileName': self.core.get_attribute(node, 'fileName'),292 'ele': self.core.get_attribute(node, 'ele'),293 'respType': self.core.get_attribute(node, 'respType'),294 'comment': self.core.get_attribute(node, 'comment'),295 }296 if self.core.is_type_of(node, self.META['recorder Node']):297 model_data = {298 'name': self.core.get_attribute(node, 'name')[9:],299 'file': self.core.get_attribute(node, 'file'),300 'fileName': self.core.get_attribute(node, 'fileName'),301 'startNode': self.core.get_attribute(node, 'startNode'),302 'endNode': self.core.get_attribute(node, 'endNode'),303 'disp': self.core.get_attribute(node, 'disp'),304 'dof': self.core.get_attribute(node, 'dof'),305 'comment': self.core.get_attribute(node, 'comment'),306 'time': self.core.get_attribute(node, 'time'),307 }308 return model_data309 def get_code(self):310 code_text = '# ' + self.model['name'] + '\n'311 # metadata312 code_text += '# Analysis Name: ' + self.model['metadata']['name'] + '\n'313 code_text += '# Analysis Description: ' + self.model['metadata']['description'] + '\n'314 code_text += '# Analysis Type: ' + self.model['metadata']['type'] + '\n'315 code_text += '#--------\n'316 code_text += '# Author: ' + self.model['metadata']['author'] + '\n'317 code_text += '# Unit System: ' + self.model['metadata']['unit_system'] + '\n'318 code_text += '# Date: ' + self.model['metadata']['date'] + '\n'319 # constants320 code_text += '\n'...
test_derived_props.py
Source:test_derived_props.py
...8889 target.row(0).select()90 target.row(1).select()9192 assert test.find_element("#active_cell").get_attribute("innerHTML") in [93 "None",94 json.dumps([]),95 ]96 assert test.find_element("#start_cell").get_attribute("innerHTML") in [97 "None",98 json.dumps([]),99 ]100 assert test.find_element("#end_cell").get_attribute("innerHTML") in [101 "None",102 json.dumps([]),103 ]104 assert test.find_element("#selected_cells").get_attribute("innerHTML") in [105 "None",106 json.dumps([]),107 ]108 assert test.find_element("#selected_rows").get_attribute("innerHTML") == json.dumps(109 list(range(2))110 )111 assert test.find_element("#selected_row_ids").get_attribute(112 "innerHTML"113 ) == json.dumps(list(range(3000, 3002)))114115 assert test.find_element("#derived_viewport_selected_rows").get_attribute(116 "innerHTML"117 ) == json.dumps(list(range(2)))118 assert test.find_element("#derived_viewport_selected_row_ids").get_attribute(119 "innerHTML"120 ) == json.dumps(list(range(3000, 3002)))121 assert test.find_element("#derived_viewport_indices").get_attribute(122 "innerHTML"123 ) == json.dumps(list(range(10)))124 assert test.find_element("#derived_viewport_row_ids").get_attribute(125 "innerHTML"126 ) == json.dumps(list(range(3000, 3010)))127128 assert test.find_element("#derived_virtual_selected_rows").get_attribute(129 "innerHTML"130 ) == json.dumps(list(range(2)))131 assert test.find_element("#derived_virtual_selected_row_ids").get_attribute(132 "innerHTML"133 ) == json.dumps(list(range(3000, 3002)))134 assert test.find_element("#derived_virtual_indices").get_attribute(135 "innerHTML"136 ) == json.dumps(list(range(100)))137 assert test.find_element("#derived_virtual_row_ids").get_attribute(138 "innerHTML"139 ) == json.dumps(list(range(3000, 3100)))140 assert test.get_log_errors() == []141142143def test_tdrp002_select_cell(test):144 test.start_server(get_app())145146 target = test.table("table")147148 target.cell(0, 0).click()149150 active = dict(row=0, column=0, column_id=rawDf.columns[0], row_id=3000)151152 time.sleep(1)153154 assert test.find_element("#active_cell").get_attribute("innerHTML") == json.dumps(155 active156 )157 assert test.find_element("#start_cell").get_attribute("innerHTML") == json.dumps(158 active159 )160 assert test.find_element("#end_cell").get_attribute("innerHTML") == json.dumps(161 active162 )163 assert test.find_element("#selected_cells").get_attribute(164 "innerHTML"165 ) == json.dumps([active])166 assert test.find_element("#selected_rows").get_attribute("innerHTML") in [167 "None",168 json.dumps([]),169 ]170 assert test.find_element("#selected_row_ids").get_attribute("innerHTML") in [171 "None",172 json.dumps([]),173 ]174175 assert test.find_element("#derived_viewport_selected_rows").get_attribute(176 "innerHTML"177 ) in ["None", json.dumps([])]178 assert test.find_element("#derived_viewport_selected_row_ids").get_attribute(179 "innerHTML"180 ) in ["None", json.dumps([])]181 assert test.find_element("#derived_viewport_indices").get_attribute(182 "innerHTML"183 ) == json.dumps(list(range(10)))184 assert test.find_element("#derived_viewport_row_ids").get_attribute(185 "innerHTML"186 ) == json.dumps(list(range(3000, 3010)))187188 assert test.find_element("#derived_virtual_selected_rows").get_attribute(189 "innerHTML"190 ) in ["None", json.dumps([])]191 assert test.find_element("#derived_virtual_selected_row_ids").get_attribute(192 "innerHTML"193 ) in ["None", json.dumps([])]194 assert test.find_element("#derived_virtual_indices").get_attribute(195 "innerHTML"196 ) == json.dumps(list(range(100)))197 assert test.find_element("#derived_virtual_row_ids").get_attribute(198 "innerHTML"199 ) == json.dumps(list(range(3000, 3100)))200 assert test.get_log_errors() == []201202203def test_tdrp003_select_cells(test):204 test.start_server(get_app())205206 target = test.table("table")207208 target.cell(0, 0).click()209 with test.hold(Keys.SHIFT):210 test.send_keys(Keys.DOWN + Keys.DOWN + Keys.RIGHT + Keys.RIGHT)211212 active = dict(row=0, column=0, column_id=rawDf.columns[0], row_id=3000)213214 selected = []215 for row in range(3):216 for col in range(3):217 selected.append(218 dict(219 row=row, column=col, column_id=rawDf.columns[col], row_id=row + 3000220 )221 )222223 assert test.find_element("#active_cell").get_attribute("innerHTML") == json.dumps(224 active225 )226 assert test.find_element("#start_cell").get_attribute("innerHTML") == json.dumps(227 selected[0]228 )229 assert test.find_element("#end_cell").get_attribute("innerHTML") == json.dumps(230 selected[-1]231 )232 assert test.find_element("#selected_cells").get_attribute(233 "innerHTML"234 ) == json.dumps(selected)235 assert test.find_element("#selected_rows").get_attribute("innerHTML") in [236 "None",237 json.dumps([]),238 ]239 assert test.find_element("#selected_row_ids").get_attribute("innerHTML") in [240 "None",241 json.dumps([]),242 ]243244 assert test.find_element("#derived_viewport_selected_rows").get_attribute(245 "innerHTML"246 ) in ["None", json.dumps([])]247 assert test.find_element("#derived_viewport_selected_row_ids").get_attribute(248 "innerHTML"249 ) in ["None", json.dumps([])]250 assert test.find_element("#derived_viewport_indices").get_attribute(251 "innerHTML"252 ) == json.dumps(list(range(10)))253 assert test.find_element("#derived_viewport_row_ids").get_attribute(254 "innerHTML"255 ) == json.dumps(list(range(3000, 3010)))256257 assert test.find_element("#derived_virtual_selected_rows").get_attribute(258 "innerHTML"259 ) in ["None", json.dumps([])]260 assert test.find_element("#derived_virtual_selected_row_ids").get_attribute(261 "innerHTML"262 ) in ["None", json.dumps([])]263 assert test.find_element("#derived_virtual_indices").get_attribute(264 "innerHTML"265 ) == json.dumps(list(range(100)))266 assert test.find_element("#derived_virtual_row_ids").get_attribute(267 "innerHTML"268 ) == json.dumps(list(range(3000, 3100)))269270 # reduce selection271 with test.hold(Keys.SHIFT):272 test.send_keys(Keys.UP + Keys.LEFT)273274 selected = []275 for row in range(2):276 for col in range(2):277 selected.append(278 dict(279 row=row, column=col, column_id=rawDf.columns[col], row_id=row + 3000280 )281 )282283 assert test.find_element("#active_cell").get_attribute("innerHTML") == json.dumps(284 active285 )286 assert test.find_element("#start_cell").get_attribute("innerHTML") == json.dumps(287 selected[0]288 )289 assert test.find_element("#end_cell").get_attribute("innerHTML") == json.dumps(290 selected[-1]291 )292 assert test.find_element("#selected_cells").get_attribute(293 "innerHTML"294 ) == json.dumps(selected)295 assert test.find_element("#selected_rows").get_attribute("innerHTML") in [296 "None",297 json.dumps([]),298 ]299 assert test.find_element("#selected_row_ids").get_attribute("innerHTML") in [300 "None",301 json.dumps([]),302 ]303304 assert test.find_element("#derived_viewport_selected_rows").get_attribute(305 "innerHTML"306 ) in ["None", json.dumps([])]307 assert test.find_element("#derived_viewport_selected_row_ids").get_attribute(308 "innerHTML"309 ) in ["None", json.dumps([])]310 assert test.find_element("#derived_viewport_indices").get_attribute(311 "innerHTML"312 ) == json.dumps(list(range(10)))313 assert test.find_element("#derived_viewport_row_ids").get_attribute(314 "innerHTML"315 ) == json.dumps(list(range(3000, 3010)))316317 assert test.find_element("#derived_virtual_selected_rows").get_attribute(318 "innerHTML"319 ) in ["None", json.dumps([])]320 assert test.find_element("#derived_virtual_selected_row_ids").get_attribute(321 "innerHTML"322 ) in ["None", json.dumps([])]323 assert test.find_element("#derived_virtual_indices").get_attribute(324 "innerHTML"325 ) == json.dumps(list(range(100)))326 assert test.find_element("#derived_virtual_row_ids").get_attribute(327 "innerHTML"328 ) == json.dumps(list(range(3000, 3100)))329 assert test.get_log_errors() == []330331332def test_tdrp004_navigate_selected_cells(test):333 test.start_server(get_app())334335 target = test.table("table")336337 target.cell(0, 0).click()338 with test.hold(Keys.SHIFT):339 test.send_keys(Keys.DOWN + Keys.DOWN + Keys.RIGHT + Keys.RIGHT)340341 selected = []342 for row in range(3):343 for col in range(3):344 selected.append(345 dict(346 row=row, column=col, column_id=rawDf.columns[col], row_id=row + 3000347 )348 )349350 for row in range(3):351 for col in range(3):352 # active = dict(353 # row=row, column=col, column_id=rawDf.columns[col], row_id=row + 3000354 # )355356 # assert test.find_element("#active_cell").get_attribute(357 # "innerHTML"358 # ) == json.dumps(active)359 assert test.find_element("#start_cell").get_attribute(360 "innerHTML"361 ) == json.dumps(selected[0])362 assert test.find_element("#end_cell").get_attribute(363 "innerHTML"364 ) == json.dumps(selected[-1])365 assert test.find_element("#selected_cells").get_attribute(366 "innerHTML"367 ) == json.dumps(selected)368 assert test.find_element("#selected_rows").get_attribute("innerHTML") in [369 "None",370 json.dumps([]),371 ]372 assert test.find_element("#selected_row_ids").get_attribute(373 "innerHTML"374 ) in ["None", json.dumps([])]375376 assert test.find_element("#derived_viewport_selected_rows").get_attribute(377 "innerHTML"378 ) in ["None", json.dumps([])]379 assert test.find_element(380 "#derived_viewport_selected_row_ids"381 ).get_attribute("innerHTML") in ["None", json.dumps([])]382 assert test.find_element("#derived_viewport_indices").get_attribute(383 "innerHTML"384 ) == json.dumps(list(range(10)))385 assert test.find_element("#derived_viewport_row_ids").get_attribute(386 "innerHTML"387 ) == json.dumps(list(range(3000, 3010)))388389 assert test.find_element("#derived_virtual_selected_rows").get_attribute(390 "innerHTML"391 ) in ["None", json.dumps([])]392 assert test.find_element("#derived_virtual_selected_row_ids").get_attribute(393 "innerHTML"394 ) in ["None", json.dumps([])]395 assert test.find_element("#derived_virtual_indices").get_attribute(396 "innerHTML"397 ) == json.dumps(list(range(100)))398 assert test.find_element("#derived_virtual_row_ids").get_attribute(399 "innerHTML"400 ) == json.dumps(list(range(3000, 3100)))401402 test.send_keys(Keys.TAB)403404 assert test.get_log_errors() == []405406407def test_tdrp005_filtered_and_sorted_row_select(test):408 test.start_server(get_app())409410 target = test.table("table")411412 target.row(0).select()413 target.row(1).select()414 target.row(2).select()415416 assert test.find_element("#active_cell").get_attribute("innerHTML") in [417 "None",418 json.dumps([]),419 ]420 assert test.find_element("#start_cell").get_attribute("innerHTML") in [421 "None",422 json.dumps([]),423 ]424 assert test.find_element("#end_cell").get_attribute("innerHTML") in [425 "None",426 json.dumps([]),427 ]428 assert test.find_element("#selected_cells").get_attribute("innerHTML") in [429 "None",430 json.dumps([]),431 ]432 assert test.find_element("#selected_rows").get_attribute("innerHTML") == json.dumps(433 list(range(3))434 )435 assert test.find_element("#selected_row_ids").get_attribute(436 "innerHTML"437 ) == json.dumps(list(range(3000, 3003)))438439 assert test.find_element("#derived_viewport_selected_rows").get_attribute(440 "innerHTML"441 ) == json.dumps(list(range(3)))442 assert test.find_element("#derived_viewport_selected_row_ids").get_attribute(443 "innerHTML"444 ) == json.dumps(list(range(3000, 3003)))445 assert test.find_element("#derived_viewport_indices").get_attribute(446 "innerHTML"447 ) == json.dumps(list(range(10)))448 assert test.find_element("#derived_viewport_row_ids").get_attribute(449 "innerHTML"450 ) == json.dumps(list(range(3000, 3010)))451452 assert test.find_element("#derived_virtual_selected_rows").get_attribute(453 "innerHTML"454 ) == json.dumps(list(range(3)))455 assert test.find_element("#derived_virtual_selected_row_ids").get_attribute(456 "innerHTML"457 ) == json.dumps(list(range(3000, 3003)))458 assert test.find_element("#derived_virtual_indices").get_attribute(459 "innerHTML"460 ) == json.dumps(list(range(100)))461 assert test.find_element("#derived_virtual_row_ids").get_attribute(462 "innerHTML"463 ) == json.dumps(list(range(3000, 3100)))464465 target.column(0).filter_value("is even")466467 assert test.find_element("#active_cell").get_attribute("innerHTML") in [468 "None",469 json.dumps([]),470 ]471 assert test.find_element("#start_cell").get_attribute("innerHTML") in [472 "None",473 json.dumps([]),474 ]475 assert test.find_element("#end_cell").get_attribute("innerHTML") in [476 "None",477 json.dumps([]),478 ]479 assert test.find_element("#selected_cells").get_attribute("innerHTML") in [480 "None",481 json.dumps([]),482 ]483 assert test.find_element("#selected_rows").get_attribute("innerHTML") == json.dumps(484 list(range(3))485 )486 assert test.find_element("#selected_row_ids").get_attribute(487 "innerHTML"488 ) == json.dumps(list(range(3000, 3003)))489490 assert test.find_element("#derived_viewport_selected_rows").get_attribute(491 "innerHTML"492 ) == json.dumps(list(range(0, 2)))493 assert test.find_element("#derived_viewport_selected_row_ids").get_attribute(494 "innerHTML"495 ) == json.dumps(list(range(3000, 3003, 2)))496 assert test.find_element("#derived_viewport_indices").get_attribute(497 "innerHTML"498 ) == json.dumps(list(range(0, 20, 2)))499 assert test.find_element("#derived_viewport_row_ids").get_attribute(500 "innerHTML"501 ) == json.dumps(list(range(3000, 3020, 2)))502503 assert test.find_element("#derived_virtual_selected_rows").get_attribute(504 "innerHTML"505 ) == json.dumps(list(range(0, 2)))506 assert test.find_element("#derived_virtual_selected_row_ids").get_attribute(507 "innerHTML"508 ) == json.dumps(list(range(3000, 3003, 2)))509 assert test.find_element("#derived_virtual_indices").get_attribute(510 "innerHTML"511 ) == json.dumps(list(range(0, 100, 2)))512 assert test.find_element("#derived_virtual_row_ids").get_attribute(513 "innerHTML"514 ) == json.dumps(list(range(3000, 3100, 2)))515516 target.column(rawDf.columns[0]).sort() # None -> ASC517 target.column(rawDf.columns[0]).sort() # ASC -> DESC518519 assert test.find_element("#active_cell").get_attribute("innerHTML") in [520 "None",521 json.dumps([]),522 ]523 assert test.find_element("#start_cell").get_attribute("innerHTML") in [524 "None",525 json.dumps([]),526 ]527 assert test.find_element("#end_cell").get_attribute("innerHTML") in [528 "None",529 json.dumps([]),530 ]531 assert test.find_element("#selected_cells").get_attribute("innerHTML") in [532 "None",533 json.dumps([]),534 ]535 assert test.find_element("#selected_rows").get_attribute("innerHTML") == json.dumps(536 list(range(3))537 )538 assert test.find_element("#selected_row_ids").get_attribute(539 "innerHTML"540 ) == json.dumps(list(range(3000, 3003)))541542 assert test.find_element("#derived_viewport_selected_rows").get_attribute(543 "innerHTML"544 ) in ["None", json.dumps([])]545 assert test.find_element("#derived_viewport_selected_row_ids").get_attribute(546 "innerHTML"547 ) in ["None", json.dumps([])]548 assert test.find_element("#derived_viewport_indices").get_attribute(549 "innerHTML"550 ) == json.dumps(list(range(80, 100, 2))[::-1])551 assert test.find_element("#derived_viewport_row_ids").get_attribute(552 "innerHTML"553 ) == json.dumps(list(range(3080, 3100, 2))[::-1])554555 assert test.find_element("#derived_virtual_selected_rows").get_attribute(556 "innerHTML"557 ) == json.dumps(list(range(48, 50))[::-1])558 assert test.find_element("#derived_virtual_selected_row_ids").get_attribute(559 "innerHTML"560 ) == json.dumps(list(range(3000, 3003, 2)))561 assert test.find_element("#derived_virtual_indices").get_attribute(562 "innerHTML"563 ) == json.dumps(list(range(0, 100, 2))[::-1])564 assert test.find_element("#derived_virtual_row_ids").get_attribute(565 "innerHTML"566 ) == json.dumps(list(range(3000, 3100, 2))[::-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!!