Best Python code snippet using autotest_python
scheduler_models.py
Source:scheduler_models.py
...147 if not rows:148 raise DBError("row not found (table=%s, row id=%s)"149 % (self.__table, row_id))150 return rows[0]151 def _assert_row_length(self, row):152 assert len(row) == len(self._fields), (153 "table = %s, row = %s/%d, fields = %s/%d" % (154 self.__table, row, len(row), self._fields, len(self._fields)))155 def _compare_fields_in_row(self, row):156 """157 Given a row as returned by a SELECT query, compare it to our existing in158 memory fields. Fractional seconds are stripped from datetime values159 before comparison.160 @param row - A sequence of values corresponding to fields named in161 The class attribute _fields.162 @returns A dictionary listing the differences keyed by field name163 containing tuples of (current_value, row_value).164 """165 self._assert_row_length(row)166 differences = {}167 for field, row_value in itertools.izip(self._fields, row):168 current_value = getattr(self, field)169 if (isinstance(current_value, datetime.datetime)170 and isinstance(row_value, datetime.datetime)):171 current_value = current_value.strftime(time_utils.TIME_FMT)172 row_value = row_value.strftime(time_utils.TIME_FMT)173 if current_value != row_value:174 differences[field] = (current_value, row_value)175 return differences176 def _update_fields_from_row(self, row):177 """178 Update our field attributes using a single row returned by SELECT.179 @param row - A sequence of values corresponding to fields named in180 the class fields list.181 """182 self._assert_row_length(row)183 self._valid_fields = set()184 for field, value in itertools.izip(self._fields, row):185 setattr(self, field, value)186 self._valid_fields.add(field)187 self._valid_fields.remove('id')188 def update_from_database(self):189 assert self.id is not None190 row = self._fetch_row_from_db(self.id)191 self._update_fields_from_row(row)192 def count(self, where, table = None):193 if not table:194 table = self.__table195 rows = _db.execute("""196 SELECT count(*) FROM %s...
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!!