Best Python code snippet using yandex-tank
test_validation.py
Source:test_validation.py
...50 assert v._validate_title('./somepath/metadata.json', {'title': ''}) == (False, "'title' property not formatted correctly in metadata './somepath/metadata.json'")51 assert v._validate_title('./somepath/metadata.json', {'title': 10}) == (False, "'title' property not formatted correctly in metadata './somepath/metadata.json'")52 assert v._validate_title('./somepath/metadata.json', {'title': ' '}) == (False, "'title' property not formatted correctly in metadata './somepath/metadata.json'")53 assert v._validate_title('./somepath/metadata.json', {'title': 'lorem ipsum'}) == (True)54def test_validate_description():55 v = helpers.Validation()56 assert v._validate_description('./somepath/metadata.json', {}) == (False, "'description' property not found in metadata './somepath/metadata.json'")57 assert v._validate_description('./somepath/metadata.json', {'description': ''}) == (True)58 assert v._validate_description('./somepath/metadata.json', {'description': 10}) == (False, "'description' property not formatted correctly in metadata './somepath/metadata.json'")59 assert v._validate_description('./somepath/metadata.json', {'description': ' '}) == (True)60 assert v._validate_description('./somepath/metadata.json', {'description': 'lorem ipsum'}) == (True)61def test_validate_tags():62 v = helpers.Validation()63 assert v._validate_tags('./somepath/metadata.json', {}, MockedFiles._mock_config()) == (False, "'tags' property not found in metadata './somepath/metadata.json'")64 assert v._validate_tags('./somepath/metadata.json', {'tags': 'lorem ipsum'}, MockedFiles._mock_config()) == (False, "'tags' property is not in correct format in metadata './somepath/metadata.json'")65 assert v._validate_tags('./somepath/metadata.json', {'tags': ['lorem ipsum']}, MockedFiles._mock_config()) == (False, "invalid tag 'lorem ipsum' in metadata './somepath/metadata.json'")66 assert v._validate_tags('./somepath/metadata.json', {'tags': ['01_Folder']}, MockedFiles._mock_config()) is True67def test_validate_roles():68 v = helpers.Validation()69 assert v._validate_roles('./somepath/metadata.json', {}, MockedFiles._mock_config()) == (False, "'roles' property not found in metadata './somepath/metadata.json'")70 assert v._validate_roles('./somepath/metadata.json', {'roles': 'lorem ipsum'}, MockedFiles._mock_config()) == (False, "'roles' property is not in correct format in metadata './somepath/metadata.json'")71 assert v._validate_roles('./somepath/metadata.json', {'roles': ['lorem ipsum']}, MockedFiles._mock_config()) == (False, "invalid role 'lorem ipsum' in metadata './somepath/metadata.json'")72 assert v._validate_roles('./somepath/metadata.json', {'roles': ['AppDev']}, MockedFiles._mock_config()) is True73def test_validate_config():74 v = helpers.Validation()...
movie.py
Source:movie.py
...11 :param genre: genre of the movie12 """13 self.__id = str(_id)14 Movie._validate_title(title)15 Movie._validate_description(desc)16 Movie._validate_genre(genre)17 self._title = title18 self._description = desc19 self._genre = genre20 def __str__(self):21 """22 String conversion23 :return: the string form of a movie24 """25 s = f"ID: {self.id}\n" \26 f"Title: {self.title}\n" \27 f"Genre: {self.genre}\n" \28 f"Description: {self.description}"29 return s30 """31 Getters and Setters32 """33 @property34 def id(self):35 return self.__id36 @property37 def title(self):38 return self._title39 @title.setter40 def title(self, value):41 Movie._validate_title(value)42 self._title = value43 @property44 def description(self):45 return self._description46 @description.setter47 def description(self, value):48 Movie._validate_description(value)49 self._description = value50 @property51 def genre(self):52 return self._genre53 @genre.setter54 def genre(self, value):55 Movie._validate_genre(value)56 self._genre = value57 @staticmethod58 def _validate_title(value):59 if not isinstance(value, str):60 raise ValueError("Title not a string")61 if value == "":62 raise ValueError("Empty title")63 @staticmethod64 def _validate_description(value):65 if not isinstance(value, str):66 raise ValueError("Description not a string")67 if value == "":68 raise ValueError("Empty description")69 @staticmethod70 def _validate_genre(value):71 if not isinstance(value, str):72 raise ValueError("Genre not a string")73 if value == "":74 raise ValueError("Empty genre")75 @staticmethod76 def get_from_string(st):77 s = st.strip().split(",")78 return Movie(s[0], s[1], s[2], s[3])...
validator.py
Source:validator.py
2class Validator:3 @staticmethod4 def validate(data, config_object):5 Validator._validate_title(data['title'])6 Validator._validate_description(data['description'])7 Validator._validate_icon(data['icon'], config_object)8 Validator._validate_time(data['time'])9 @staticmethod10 def _validate_title(title) -> bool:11 if len(title) == 0:12 raise TitleValidationException('small')13 elif len(title) > 30:14 raise TitleValidationException('long')15 return True16 @staticmethod17 def _validate_description(desc) -> bool:18 if len(desc) == 0:19 raise DescriptionValidationException('small')20 elif len(desc) > 50:21 raise DescriptionValidationException('long')22 return True23 @staticmethod24 def _validate_icon(icon, config_object) -> bool:25 if icon == config_object.base_icon:26 raise IconValidationException()27 return True28 @staticmethod29 def _validate_time(time) -> bool:30 if time == 0:31 raise TimeValidationException()...
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!!