Best JavaScript code snippet using wpt
property_content.py
Source:property_content.py
1# coding: utf-82"""3 Rapid4 EPS Rapid V2.3 # noqa: E5015 OpenAPI spec version: 2.36 7 Generated by: https://github.com/swagger-api/swagger-codegen.git8"""9import pprint10import re # noqa: F40111import six12from eps_rapid.models.amenity import Amenity # noqa: F401,E50113from eps_rapid.models.brand import Brand # noqa: F401,E50114from eps_rapid.models.chain import Chain # noqa: F401,E50115from eps_rapid.models.property_content_address import PropertyContentAddress # noqa: F401,E50116from eps_rapid.models.property_content_airports import PropertyContentAirports # noqa: F401,E50117from eps_rapid.models.property_content_all_inclusive import PropertyContentAllInclusive # noqa: F401,E50118from eps_rapid.models.property_content_attributes import PropertyContentAttributes # noqa: F401,E50119from eps_rapid.models.property_content_business_model import PropertyContentBusinessModel # noqa: F401,E50120from eps_rapid.models.property_content_category import PropertyContentCategory # noqa: F401,E50121from eps_rapid.models.property_content_checkin import PropertyContentCheckin # noqa: F401,E50122from eps_rapid.models.property_content_checkout import PropertyContentCheckout # noqa: F401,E50123from eps_rapid.models.property_content_dates import PropertyContentDates # noqa: F401,E50124from eps_rapid.models.property_content_descriptions import PropertyContentDescriptions # noqa: F401,E50125from eps_rapid.models.property_content_fees import PropertyContentFees # noqa: F401,E50126from eps_rapid.models.property_content_images import PropertyContentImages # noqa: F401,E50127from eps_rapid.models.property_content_location import PropertyContentLocation # noqa: F401,E50128from eps_rapid.models.property_content_onsite_payments import PropertyContentOnsitePayments # noqa: F401,E50129from eps_rapid.models.property_content_policies import PropertyContentPolicies # noqa: F401,E50130from eps_rapid.models.property_content_ratings import PropertyContentRatings # noqa: F401,E50131from eps_rapid.models.rate_content import RateContent # noqa: F401,E50132from eps_rapid.models.room_content import RoomContent # noqa: F401,E50133from eps_rapid.models.spoken_language import SpokenLanguage # noqa: F401,E50134from eps_rapid.models.statistic import Statistic # noqa: F401,E50135from eps_rapid.models.theme import Theme # noqa: F401,E50136class PropertyContent(object):37 """NOTE: This class is auto generated by the swagger code generator program.38 Do not edit the class manually.39 """40 """41 Attributes:42 swagger_types (dict): The key is attribute name43 and the value is attribute type.44 attribute_map (dict): The key is attribute name45 and the value is json key in definition.46 """47 swagger_types = {48 'property_id': 'str',49 'name': 'str',50 'address': 'PropertyContentAddress',51 'ratings': 'PropertyContentRatings',52 'location': 'PropertyContentLocation',53 'phone': 'str',54 'fax': 'str',55 'category': 'PropertyContentCategory',56 'business_model': 'PropertyContentBusinessModel',57 'rank': 'float',58 'checkin': 'PropertyContentCheckin',59 'checkout': 'PropertyContentCheckout',60 'fees': 'PropertyContentFees',61 'policies': 'PropertyContentPolicies',62 'attributes': 'PropertyContentAttributes',63 'amenities': 'dict(str, Amenity)',64 'images': 'list[PropertyContentImages]',65 'onsite_payments': 'PropertyContentOnsitePayments',66 'rooms': 'dict(str, RoomContent)',67 'rates': 'dict(str, RateContent)',68 'dates': 'PropertyContentDates',69 'descriptions': 'PropertyContentDescriptions',70 'statistics': 'dict(str, Statistic)',71 'airports': 'PropertyContentAirports',72 'registry_number': 'str',73 'themes': 'dict(str, Theme)',74 'all_inclusive': 'PropertyContentAllInclusive',75 'tax_id': 'str',76 'chain': 'Chain',77 'brand': 'Brand',78 'spoken_languages': 'dict(str, SpokenLanguage)',79 'multi_unit': 'bool'80 }81 attribute_map = {82 'property_id': 'property_id',83 'name': 'name',84 'address': 'address',85 'ratings': 'ratings',86 'location': 'location',87 'phone': 'phone',88 'fax': 'fax',89 'category': 'category',90 'business_model': 'business_model',91 'rank': 'rank',92 'checkin': 'checkin',93 'checkout': 'checkout',94 'fees': 'fees',95 'policies': 'policies',96 'attributes': 'attributes',97 'amenities': 'amenities',98 'images': 'images',99 'onsite_payments': 'onsite_payments',100 'rooms': 'rooms',101 'rates': 'rates',102 'dates': 'dates',103 'descriptions': 'descriptions',104 'statistics': 'statistics',105 'airports': 'airports',106 'registry_number': 'registry_number',107 'themes': 'themes',108 'all_inclusive': 'all_inclusive',109 'tax_id': 'tax_id',110 'chain': 'chain',111 'brand': 'brand',112 'spoken_languages': 'spoken_languages',113 'multi_unit': 'multi_unit'114 }115 def __init__(self, property_id=None, name=None, address=None, ratings=None, location=None, phone=None, fax=None, category=None, business_model=None, rank=None, checkin=None, checkout=None, fees=None, policies=None, attributes=None, amenities=None, images=None, onsite_payments=None, rooms=None, rates=None, dates=None, descriptions=None, statistics=None, airports=None, registry_number=None, themes=None, all_inclusive=None, tax_id=None, chain=None, brand=None, spoken_languages=None, multi_unit=None): # noqa: E501116 """PropertyContent - a model defined in Swagger""" # noqa: E501117 self._property_id = None118 self._name = None119 self._address = None120 self._ratings = None121 self._location = None122 self._phone = None123 self._fax = None124 self._category = None125 self._business_model = None126 self._rank = None127 self._checkin = None128 self._checkout = None129 self._fees = None130 self._policies = None131 self._attributes = None132 self._amenities = None133 self._images = None134 self._onsite_payments = None135 self._rooms = None136 self._rates = None137 self._dates = None138 self._descriptions = None139 self._statistics = None140 self._airports = None141 self._registry_number = None142 self._themes = None143 self._all_inclusive = None144 self._tax_id = None145 self._chain = None146 self._brand = None147 self._spoken_languages = None148 self._multi_unit = None149 self.discriminator = None150 if property_id is not None:151 self.property_id = property_id152 if name is not None:153 self.name = name154 if address is not None:155 self.address = address156 if ratings is not None:157 self.ratings = ratings158 if location is not None:159 self.location = location160 if phone is not None:161 self.phone = phone162 if fax is not None:163 self.fax = fax164 if category is not None:165 self.category = category166 if business_model is not None:167 self.business_model = business_model168 if rank is not None:169 self.rank = rank170 if checkin is not None:171 self.checkin = checkin172 if checkout is not None:173 self.checkout = checkout174 if fees is not None:175 self.fees = fees176 if policies is not None:177 self.policies = policies178 if attributes is not None:179 self.attributes = attributes180 if amenities is not None:181 self.amenities = amenities182 if images is not None:183 self.images = images184 if onsite_payments is not None:185 self.onsite_payments = onsite_payments186 if rooms is not None:187 self.rooms = rooms188 if rates is not None:189 self.rates = rates190 if dates is not None:191 self.dates = dates192 if descriptions is not None:193 self.descriptions = descriptions194 if statistics is not None:195 self.statistics = statistics196 if airports is not None:197 self.airports = airports198 if registry_number is not None:199 self.registry_number = registry_number200 if themes is not None:201 self.themes = themes202 if all_inclusive is not None:203 self.all_inclusive = all_inclusive204 if tax_id is not None:205 self.tax_id = tax_id206 if chain is not None:207 self.chain = chain208 if brand is not None:209 self.brand = brand210 if spoken_languages is not None:211 self.spoken_languages = spoken_languages212 if multi_unit is not None:213 self.multi_unit = multi_unit214 @property215 def property_id(self):216 """Gets the property_id of this PropertyContent. # noqa: E501217 Unique Expedia property ID. # noqa: E501218 :return: The property_id of this PropertyContent. # noqa: E501219 :rtype: str220 """221 return self._property_id222 @property_id.setter223 def property_id(self, property_id):224 """Sets the property_id of this PropertyContent.225 Unique Expedia property ID. # noqa: E501226 :param property_id: The property_id of this PropertyContent. # noqa: E501227 :type: str228 """229 self._property_id = property_id230 @property231 def name(self):232 """Gets the name of this PropertyContent. # noqa: E501233 Property name. # noqa: E501234 :return: The name of this PropertyContent. # noqa: E501235 :rtype: str236 """237 return self._name238 @name.setter239 def name(self, name):240 """Sets the name of this PropertyContent.241 Property name. # noqa: E501242 :param name: The name of this PropertyContent. # noqa: E501243 :type: str244 """245 self._name = name246 @property247 def address(self):248 """Gets the address of this PropertyContent. # noqa: E501249 :return: The address of this PropertyContent. # noqa: E501250 :rtype: PropertyContentAddress251 """252 return self._address253 @address.setter254 def address(self, address):255 """Sets the address of this PropertyContent.256 :param address: The address of this PropertyContent. # noqa: E501257 :type: PropertyContentAddress258 """259 self._address = address260 @property261 def ratings(self):262 """Gets the ratings of this PropertyContent. # noqa: E501263 :return: The ratings of this PropertyContent. # noqa: E501264 :rtype: PropertyContentRatings265 """266 return self._ratings267 @ratings.setter268 def ratings(self, ratings):269 """Sets the ratings of this PropertyContent.270 :param ratings: The ratings of this PropertyContent. # noqa: E501271 :type: PropertyContentRatings272 """273 self._ratings = ratings274 @property275 def location(self):276 """Gets the location of this PropertyContent. # noqa: E501277 :return: The location of this PropertyContent. # noqa: E501278 :rtype: PropertyContentLocation279 """280 return self._location281 @location.setter282 def location(self, location):283 """Sets the location of this PropertyContent.284 :param location: The location of this PropertyContent. # noqa: E501285 :type: PropertyContentLocation286 """287 self._location = location288 @property289 def phone(self):290 """Gets the phone of this PropertyContent. # noqa: E501291 The property's phone number. # noqa: E501292 :return: The phone of this PropertyContent. # noqa: E501293 :rtype: str294 """295 return self._phone296 @phone.setter297 def phone(self, phone):298 """Sets the phone of this PropertyContent.299 The property's phone number. # noqa: E501300 :param phone: The phone of this PropertyContent. # noqa: E501301 :type: str302 """303 self._phone = phone304 @property305 def fax(self):306 """Gets the fax of this PropertyContent. # noqa: E501307 The property's fax number. # noqa: E501308 :return: The fax of this PropertyContent. # noqa: E501309 :rtype: str310 """311 return self._fax312 @fax.setter313 def fax(self, fax):314 """Sets the fax of this PropertyContent.315 The property's fax number. # noqa: E501316 :param fax: The fax of this PropertyContent. # noqa: E501317 :type: str318 """319 self._fax = fax320 @property321 def category(self):322 """Gets the category of this PropertyContent. # noqa: E501323 :return: The category of this PropertyContent. # noqa: E501324 :rtype: PropertyContentCategory325 """326 return self._category327 @category.setter328 def category(self, category):329 """Sets the category of this PropertyContent.330 :param category: The category of this PropertyContent. # noqa: E501331 :type: PropertyContentCategory332 """333 self._category = category334 @property335 def business_model(self):336 """Gets the business_model of this PropertyContent. # noqa: E501337 :return: The business_model of this PropertyContent. # noqa: E501338 :rtype: PropertyContentBusinessModel339 """340 return self._business_model341 @business_model.setter342 def business_model(self, business_model):343 """Sets the business_model of this PropertyContent.344 :param business_model: The business_model of this PropertyContent. # noqa: E501345 :type: PropertyContentBusinessModel346 """347 self._business_model = business_model348 @property349 def rank(self):350 """Gets the rank of this PropertyContent. # noqa: E501351 The propertyâs rank across all properties. This value sorts properties based on EPS transactional data and details about the property, with 1 indicating the best-performing property and others following in ascending numerical order. # noqa: E501352 :return: The rank of this PropertyContent. # noqa: E501353 :rtype: float354 """355 return self._rank356 @rank.setter357 def rank(self, rank):358 """Sets the rank of this PropertyContent.359 The propertyâs rank across all properties. This value sorts properties based on EPS transactional data and details about the property, with 1 indicating the best-performing property and others following in ascending numerical order. # noqa: E501360 :param rank: The rank of this PropertyContent. # noqa: E501361 :type: float362 """363 self._rank = rank364 @property365 def checkin(self):366 """Gets the checkin of this PropertyContent. # noqa: E501367 :return: The checkin of this PropertyContent. # noqa: E501368 :rtype: PropertyContentCheckin369 """370 return self._checkin371 @checkin.setter372 def checkin(self, checkin):373 """Sets the checkin of this PropertyContent.374 :param checkin: The checkin of this PropertyContent. # noqa: E501375 :type: PropertyContentCheckin376 """377 self._checkin = checkin378 @property379 def checkout(self):380 """Gets the checkout of this PropertyContent. # noqa: E501381 :return: The checkout of this PropertyContent. # noqa: E501382 :rtype: PropertyContentCheckout383 """384 return self._checkout385 @checkout.setter386 def checkout(self, checkout):387 """Sets the checkout of this PropertyContent.388 :param checkout: The checkout of this PropertyContent. # noqa: E501389 :type: PropertyContentCheckout390 """391 self._checkout = checkout392 @property393 def fees(self):394 """Gets the fees of this PropertyContent. # noqa: E501395 :return: The fees of this PropertyContent. # noqa: E501396 :rtype: PropertyContentFees397 """398 return self._fees399 @fees.setter400 def fees(self, fees):401 """Sets the fees of this PropertyContent.402 :param fees: The fees of this PropertyContent. # noqa: E501403 :type: PropertyContentFees404 """405 self._fees = fees406 @property407 def policies(self):408 """Gets the policies of this PropertyContent. # noqa: E501409 :return: The policies of this PropertyContent. # noqa: E501410 :rtype: PropertyContentPolicies411 """412 return self._policies413 @policies.setter414 def policies(self, policies):415 """Sets the policies of this PropertyContent.416 :param policies: The policies of this PropertyContent. # noqa: E501417 :type: PropertyContentPolicies418 """419 self._policies = policies420 @property421 def attributes(self):422 """Gets the attributes of this PropertyContent. # noqa: E501423 :return: The attributes of this PropertyContent. # noqa: E501424 :rtype: PropertyContentAttributes425 """426 return self._attributes427 @attributes.setter428 def attributes(self, attributes):429 """Sets the attributes of this PropertyContent.430 :param attributes: The attributes of this PropertyContent. # noqa: E501431 :type: PropertyContentAttributes432 """433 self._attributes = attributes434 @property435 def amenities(self):436 """Gets the amenities of this PropertyContent. # noqa: E501437 Lists all of the amenities available for all guests at the property. See our [amenities reference](https://developer.expediapartnersolutions.com/reference/content-reference-lists-2-3/) for current known amenity ID and name values. # noqa: E501438 :return: The amenities of this PropertyContent. # noqa: E501439 :rtype: dict(str, Amenity)440 """441 return self._amenities442 @amenities.setter443 def amenities(self, amenities):444 """Sets the amenities of this PropertyContent.445 Lists all of the amenities available for all guests at the property. See our [amenities reference](https://developer.expediapartnersolutions.com/reference/content-reference-lists-2-3/) for current known amenity ID and name values. # noqa: E501446 :param amenities: The amenities of this PropertyContent. # noqa: E501447 :type: dict(str, Amenity)448 """449 self._amenities = amenities450 @property451 def images(self):452 """Gets the images of this PropertyContent. # noqa: E501453 Contains all property images available. # noqa: E501454 :return: The images of this PropertyContent. # noqa: E501455 :rtype: list[PropertyContentImages]456 """457 return self._images458 @images.setter459 def images(self, images):460 """Sets the images of this PropertyContent.461 Contains all property images available. # noqa: E501462 :param images: The images of this PropertyContent. # noqa: E501463 :type: list[PropertyContentImages]464 """465 self._images = images466 @property467 def onsite_payments(self):468 """Gets the onsite_payments of this PropertyContent. # noqa: E501469 :return: The onsite_payments of this PropertyContent. # noqa: E501470 :rtype: PropertyContentOnsitePayments471 """472 return self._onsite_payments473 @onsite_payments.setter474 def onsite_payments(self, onsite_payments):475 """Sets the onsite_payments of this PropertyContent.476 :param onsite_payments: The onsite_payments of this PropertyContent. # noqa: E501477 :type: PropertyContentOnsitePayments478 """479 self._onsite_payments = onsite_payments480 @property481 def rooms(self):482 """Gets the rooms of this PropertyContent. # noqa: E501483 Information about all of the rooms at the property. # noqa: E501484 :return: The rooms of this PropertyContent. # noqa: E501485 :rtype: dict(str, RoomContent)486 """487 return self._rooms488 @rooms.setter489 def rooms(self, rooms):490 """Sets the rooms of this PropertyContent.491 Information about all of the rooms at the property. # noqa: E501492 :param rooms: The rooms of this PropertyContent. # noqa: E501493 :type: dict(str, RoomContent)494 """495 self._rooms = rooms496 @property497 def rates(self):498 """Gets the rates of this PropertyContent. # noqa: E501499 Additional information about the rates offered by the property. This should be used in conjunction with the pricing and other rate-related information in shopping. # noqa: E501500 :return: The rates of this PropertyContent. # noqa: E501501 :rtype: dict(str, RateContent)502 """503 return self._rates504 @rates.setter505 def rates(self, rates):506 """Sets the rates of this PropertyContent.507 Additional information about the rates offered by the property. This should be used in conjunction with the pricing and other rate-related information in shopping. # noqa: E501508 :param rates: The rates of this PropertyContent. # noqa: E501509 :type: dict(str, RateContent)510 """511 self._rates = rates512 @property513 def dates(self):514 """Gets the dates of this PropertyContent. # noqa: E501515 :return: The dates of this PropertyContent. # noqa: E501516 :rtype: PropertyContentDates517 """518 return self._dates519 @dates.setter520 def dates(self, dates):521 """Sets the dates of this PropertyContent.522 :param dates: The dates of this PropertyContent. # noqa: E501523 :type: PropertyContentDates524 """525 self._dates = dates526 @property527 def descriptions(self):528 """Gets the descriptions of this PropertyContent. # noqa: E501529 :return: The descriptions of this PropertyContent. # noqa: E501530 :rtype: PropertyContentDescriptions531 """532 return self._descriptions533 @descriptions.setter534 def descriptions(self, descriptions):535 """Sets the descriptions of this PropertyContent.536 :param descriptions: The descriptions of this PropertyContent. # noqa: E501537 :type: PropertyContentDescriptions538 """539 self._descriptions = descriptions540 @property541 def statistics(self):542 """Gets the statistics of this PropertyContent. # noqa: E501543 Statistics of the property, such as number of floors. See our [statistics reference](https://developer.expediapartnersolutions.com/reference/content-reference-lists-2-3/) for current known statistics ID and name values. # noqa: E501544 :return: The statistics of this PropertyContent. # noqa: E501545 :rtype: dict(str, Statistic)546 """547 return self._statistics548 @statistics.setter549 def statistics(self, statistics):550 """Sets the statistics of this PropertyContent.551 Statistics of the property, such as number of floors. See our [statistics reference](https://developer.expediapartnersolutions.com/reference/content-reference-lists-2-3/) for current known statistics ID and name values. # noqa: E501552 :param statistics: The statistics of this PropertyContent. # noqa: E501553 :type: dict(str, Statistic)554 """555 self._statistics = statistics556 @property557 def airports(self):558 """Gets the airports of this PropertyContent. # noqa: E501559 :return: The airports of this PropertyContent. # noqa: E501560 :rtype: PropertyContentAirports561 """562 return self._airports563 @airports.setter564 def airports(self, airports):565 """Sets the airports of this PropertyContent.566 :param airports: The airports of this PropertyContent. # noqa: E501567 :type: PropertyContentAirports568 """569 self._airports = airports570 @property571 def registry_number(self):572 """Gets the registry_number of this PropertyContent. # noqa: E501573 The property's registry number required by some jurisdictions. # noqa: E501574 :return: The registry_number of this PropertyContent. # noqa: E501575 :rtype: str576 """577 return self._registry_number578 @registry_number.setter579 def registry_number(self, registry_number):580 """Sets the registry_number of this PropertyContent.581 The property's registry number required by some jurisdictions. # noqa: E501582 :param registry_number: The registry_number of this PropertyContent. # noqa: E501583 :type: str584 """585 self._registry_number = registry_number586 @property587 def themes(self):588 """Gets the themes of this PropertyContent. # noqa: E501589 Themes that describe the property. See our [themes reference](https://developer.expediapartnersolutions.com/reference/content-reference-lists-2-3/) for current known theme ID and name values. # noqa: E501590 :return: The themes of this PropertyContent. # noqa: E501591 :rtype: dict(str, Theme)592 """593 return self._themes594 @themes.setter595 def themes(self, themes):596 """Sets the themes of this PropertyContent.597 Themes that describe the property. See our [themes reference](https://developer.expediapartnersolutions.com/reference/content-reference-lists-2-3/) for current known theme ID and name values. # noqa: E501598 :param themes: The themes of this PropertyContent. # noqa: E501599 :type: dict(str, Theme)600 """601 self._themes = themes602 @property603 def all_inclusive(self):604 """Gets the all_inclusive of this PropertyContent. # noqa: E501605 :return: The all_inclusive of this PropertyContent. # noqa: E501606 :rtype: PropertyContentAllInclusive607 """608 return self._all_inclusive609 @all_inclusive.setter610 def all_inclusive(self, all_inclusive):611 """Sets the all_inclusive of this PropertyContent.612 :param all_inclusive: The all_inclusive of this PropertyContent. # noqa: E501613 :type: PropertyContentAllInclusive614 """615 self._all_inclusive = all_inclusive616 @property617 def tax_id(self):618 """Gets the tax_id of this PropertyContent. # noqa: E501619 Tax ID. # noqa: E501620 :return: The tax_id of this PropertyContent. # noqa: E501621 :rtype: str622 """623 return self._tax_id624 @tax_id.setter625 def tax_id(self, tax_id):626 """Sets the tax_id of this PropertyContent.627 Tax ID. # noqa: E501628 :param tax_id: The tax_id of this PropertyContent. # noqa: E501629 :type: str630 """631 self._tax_id = tax_id632 @property633 def chain(self):634 """Gets the chain of this PropertyContent. # noqa: E501635 :return: The chain of this PropertyContent. # noqa: E501636 :rtype: Chain637 """638 return self._chain639 @chain.setter640 def chain(self, chain):641 """Sets the chain of this PropertyContent.642 :param chain: The chain of this PropertyContent. # noqa: E501643 :type: Chain644 """645 self._chain = chain646 @property647 def brand(self):648 """Gets the brand of this PropertyContent. # noqa: E501649 :return: The brand of this PropertyContent. # noqa: E501650 :rtype: Brand651 """652 return self._brand653 @brand.setter654 def brand(self, brand):655 """Sets the brand of this PropertyContent.656 :param brand: The brand of this PropertyContent. # noqa: E501657 :type: Brand658 """659 self._brand = brand660 @property661 def spoken_languages(self):662 """Gets the spoken_languages of this PropertyContent. # noqa: E501663 Languages spoken at the property. # noqa: E501664 :return: The spoken_languages of this PropertyContent. # noqa: E501665 :rtype: dict(str, SpokenLanguage)666 """667 return self._spoken_languages668 @spoken_languages.setter669 def spoken_languages(self, spoken_languages):670 """Sets the spoken_languages of this PropertyContent.671 Languages spoken at the property. # noqa: E501672 :param spoken_languages: The spoken_languages of this PropertyContent. # noqa: E501673 :type: dict(str, SpokenLanguage)674 """675 self._spoken_languages = spoken_languages676 @property677 def multi_unit(self):678 """Gets the multi_unit of this PropertyContent. # noqa: E501679 Boolean value indicating if a property is a multi-unit property. # noqa: E501680 :return: The multi_unit of this PropertyContent. # noqa: E501681 :rtype: bool682 """683 return self._multi_unit684 @multi_unit.setter685 def multi_unit(self, multi_unit):686 """Sets the multi_unit of this PropertyContent.687 Boolean value indicating if a property is a multi-unit property. # noqa: E501688 :param multi_unit: The multi_unit of this PropertyContent. # noqa: E501689 :type: bool690 """691 self._multi_unit = multi_unit692 def to_dict(self):693 """Returns the model properties as a dict"""694 result = {}695 for attr, _ in six.iteritems(self.swagger_types):696 value = getattr(self, attr)697 if isinstance(value, list):698 result[attr] = list(map(699 lambda x: x.to_dict() if hasattr(x, "to_dict") else x,700 value701 ))702 elif hasattr(value, "to_dict"):703 result[attr] = value.to_dict()704 elif isinstance(value, dict):705 result[attr] = dict(map(706 lambda item: (item[0], item[1].to_dict())707 if hasattr(item[1], "to_dict") else item,708 value.items()709 ))710 else:711 result[attr] = value712 if issubclass(PropertyContent, dict):713 for key, value in self.items():714 result[key] = value715 return result716 def to_str(self):717 """Returns the string representation of the model"""718 return pprint.pformat(self.to_dict())719 def __repr__(self):720 """For `print` and `pprint`"""721 return self.to_str()722 def __eq__(self, other):723 """Returns true if both objects are equal"""724 if not isinstance(other, PropertyContent):725 return False726 return self.__dict__ == other.__dict__727 def __ne__(self, other):728 """Returns true if both objects are not equal"""...
Object-defineProperty.js
Source:Object-defineProperty.js
1description("Test to ensure correct behaviour of Object.defineProperty");2shouldBe("JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {value:1}), 'foo'))",3 "JSON.stringify({value: 1, writable: false, enumerable: false, configurable: false})");4shouldBe("JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {}), 'foo'))",5 "JSON.stringify({writable: false, enumerable: false, configurable: false})");6shouldBe("JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {get:undefined}), 'foo'))",7 "JSON.stringify({enumerable: false, configurable: false})");8shouldBe("JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {value:1, writable: false}), 'foo'))",9 "JSON.stringify({value: 1, writable: false, enumerable: false, configurable: false})");10shouldBe("JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {value:1, writable: true}), 'foo'))",11 "JSON.stringify({value: 1, writable: true, enumerable: false, configurable: false})");12shouldBe("JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {value:1, enumerable: false}), 'foo'))",13 "JSON.stringify({value: 1, writable: false, enumerable: false, configurable: false})");14shouldBe("JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {value:1, enumerable: true}), 'foo'))",15 "JSON.stringify({value: 1, writable: false, enumerable: true, configurable: false})");16shouldBe("JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {value:1, configurable: false}), 'foo'))",17 "JSON.stringify({value: 1, writable: false, enumerable: false, configurable: false})");18shouldBe("JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty({}, 'foo', {value:1, configurable: true}), 'foo'))",19 "JSON.stringify({value: 1, writable: false, enumerable: false, configurable: true})");20shouldBe("JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty([1,2,3], 'foo', {value:1, configurable: true}), 'foo'))",21 "JSON.stringify({value: 1, writable: false, enumerable: false, configurable: true})");22shouldBe("Object.getOwnPropertyDescriptor(Object.defineProperty([1,2,3], '1', {value:'foo', configurable: true}), '1').value", "'foo'");23shouldBe("a=[1,2,3], Object.defineProperty(a, '1', {value:'foo', configurable: true}), a[1]", "'foo'");24shouldBe("Object.getOwnPropertyDescriptor(Object.defineProperty([1,2,3], '1', {get:getter, configurable: true}), '1').get", "getter");25shouldThrow("Object.defineProperty([1,2,3], '1', {get:getter, configurable: true})[1]", "'called getter'");26shouldThrow("Object.defineProperty()");27shouldThrow("Object.defineProperty(null)");28shouldThrow("Object.defineProperty('foo')");29shouldThrow("Object.defineProperty({})");30shouldThrow("Object.defineProperty({}, 'foo')");31shouldThrow("Object.defineProperty({}, 'foo', {get:undefined, value:true}).foo");32shouldBeTrue("Object.defineProperty({get foo() { return true; } }, 'foo', {configurable:false}).foo");33function createUnconfigurableProperty(o, prop, writable, enumerable) {34 writable = writable || false;35 enumerable = enumerable || false;36 return Object.defineProperty(o, prop, {value:1, configurable:false, writable: writable, enumerable: enumerable});37}38shouldThrow("Object.defineProperty(createUnconfigurableProperty({}, 'foo'), 'foo', {configurable: true})");39shouldThrow("Object.defineProperty(createUnconfigurableProperty({}, 'foo'), 'foo', {writable: true})");40shouldThrow("Object.defineProperty(createUnconfigurableProperty({}, 'foo'), 'foo', {enumerable: true})");41shouldThrow("Object.defineProperty(createUnconfigurableProperty({}, 'foo', false, true), 'foo', {enumerable: false}), 'foo'");42shouldBe("JSON.stringify(Object.getOwnPropertyDescriptor(Object.defineProperty(createUnconfigurableProperty({}, 'foo', true), 'foo', {writable: false}), 'foo'))",43 "JSON.stringify({value: 1, writable: false, enumerable: false, configurable: false})");44shouldThrow("Object.defineProperty({}, 'foo', {value:1, get: function(){}})");45shouldThrow("Object.defineProperty({}, 'foo', {value:1, set: function(){}})");46shouldThrow("Object.defineProperty({}, 'foo', {writable:true, get: function(){}})");47shouldThrow("Object.defineProperty({}, 'foo', {writable:true, set: function(){}})");48shouldThrow("Object.defineProperty({}, 'foo', {get: null})");49shouldThrow("Object.defineProperty({}, 'foo', {set: null})");50function getter(){ throw "called getter"; }51function getter1(){ throw "called getter1"; }52function setter(){ throw "called setter"; }53function setter1(){ throw "called setter1"; }54shouldThrow("Object.defineProperty({}, 'foo', {set: setter}).foo='test'", "'called setter'");55shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {set: setter}), 'foo', {set: setter1})");56shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {set: setter}), 'foo', {get: getter1})");57shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {set: setter}), 'foo', {value: 1})");58shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {set: setter, configurable: true}), 'foo', {set: setter1}).foo='test'", "'called setter1'");59shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {set: setter, configurable: true}), 'foo', {get: getter1}).foo", "'called getter1'");60shouldBeTrue("Object.defineProperty(Object.defineProperty({}, 'foo', {set: setter, configurable: true}), 'foo', {value: true}).foo");61shouldBeTrue("'foo' in Object.defineProperty(Object.defineProperty({}, 'foo', {set: setter, configurable: true}), 'foo', {writable: true})");62shouldBeUndefined("Object.defineProperty(Object.defineProperty({}, 'foo', {set: setter, configurable: true}), 'foo', {writable: true}).foo");63shouldThrow("Object.defineProperty({}, 'foo', {get: getter}).foo", "'called getter'");64shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {get: getter}), 'foo', {get: getter1})");65shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {get: getter}), 'foo', {set: setter1})");66shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {get: getter, configurable: true}), 'foo', {get: getter1}).foo", "'called getter1'");67shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {get: getter, configurable: true}), 'foo', {set: setter1}).foo='test'", "'called setter1'");68shouldBeTrue("Object.defineProperty(Object.defineProperty({}, 'foo', {get: getter, configurable: true}), 'foo', {value: true}).foo");69shouldBeUndefined("Object.defineProperty(Object.defineProperty({}, 'foo', {get: getter, configurable: true}), 'foo', {writable: true}).foo");70shouldBeTrue("'foo' in Object.defineProperty(Object.defineProperty({}, 'foo', {get: getter, configurable: true}), 'foo', {writable: true})");71shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1}), 'foo', {set: setter1})");72shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1, configurable: true}), 'foo', {set: setter1}).foo='test'", "'called setter1'");73shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1}), 'foo', {get: getter1})");74shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1}), 'foo', {set: setter1})");75shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1, configurable: true}), 'foo', {get: getter1}).foo", "'called getter1'");76shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1, configurable: true}), 'foo', {set: setter1}).foo='test'", "'called setter1'");77// Should be able to redefine an non-writable property, if it is configurable.78shouldBe("Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1, configurable: true, writable: false}), 'foo', {value: 2, configurable: true, writable: true}).foo", "2");79shouldBe("Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1, configurable: true, writable: false}), 'foo', {value: 2, configurable: true, writable: false}).foo", "2");80// Should be able to redefine an non-writable, non-configurable property, with the same value and attributes.81shouldBe("Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1, configurable: false, writable: false}), 'foo', {value: 1, configurable: false, writable: false}).foo", "1");82// Should be able to redefine a configurable accessor, with the same or with different attributes.83// Check the accessor function changed.84shouldBe("Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: true, enumerable: true}), 'foo', {get: function() { return 2; }, configurable: true, enumerable: false}).foo", "2");85shouldBe("Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: true, enumerable: false}), 'foo', {get: function() { return 2; }, configurable: true, enumerable: false}).foo", "2");86// Check the attributes changed.87shouldBeFalse("var result = false; var o = Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: true, enumerable: true}), 'foo', {get: function() { return 2; }, configurable: true, enumerable: false}); for (x in o) result = true; result");88shouldBeTrue("var result = false; var o = Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: true, enumerable: false}), 'foo', {get: function() { return 2; }, configurable: true, enumerable: true}); for (x in o) result = true; result");89// Should be able to define an non-configurable accessor.90shouldBeUndefined("var o = Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: true}); delete o.foo; o.foo");91shouldBe("var o = Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: false}); delete o.foo; o.foo", '1');92shouldBe("Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: true}), 'foo', {value:2}).foo", "2");93shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: false}), 'foo', {value:2}).foo");94// Defining a data descriptor over an accessor should result in a read only property.95shouldBe("var o = Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return 1; }, configurable: true}), 'foo', {value:2}); o.foo = 3; o.foo", "2");96// Trying to redefine a non-configurable property as configurable should throw.97shouldThrow("Object.defineProperty(Object.defineProperty({}, 'foo', {value: 1}), 'foo', {value:2, configurable: true})");98shouldThrow("Object.defineProperty(Object.defineProperty([], 'foo', {value: 1}), 'foo', {value:2, configurable: true})");99// Test an object with a getter setter.100// Either accessor may be omitted or replaced with undefined, or both may be replaced with undefined.101shouldBe("var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}); o.foo", '42')102shouldBe("var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}); o.foo = 42; o.result;", '42');103shouldBe("var o = Object.defineProperty({}, 'foo', {get:undefined, set:function(x){this.result = x;}}); o.foo", 'undefined')104shouldBe("var o = Object.defineProperty({}, 'foo', {get:undefined, set:function(x){this.result = x;}}); o.foo = 42; o.result;", '42');105shouldBe("var o = Object.defineProperty({}, 'foo', {set:function(x){this.result = x;}}); o.foo", 'undefined')106shouldBe("var o = Object.defineProperty({}, 'foo', {set:function(x){this.result = x;}}); o.foo = 42; o.result;", '42');107shouldBe("var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}, set:undefined}); o.foo", '42')108shouldBe("var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}, set:undefined}); o.foo = 42; o.result;", 'undefined');109shouldBe("var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}}); o.foo", '42')110shouldBe("var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}}); o.foo = 42; o.result;", 'undefined');111shouldBe("var o = Object.defineProperty({}, 'foo', {get:undefined, set:undefined}); o.foo", 'undefined')112shouldBe("var o = Object.defineProperty({}, 'foo', {get:undefined, set:undefined}); o.foo = 42; o.result;", 'undefined');113// Test replacing or removing either the getter or setter individually.114shouldBe("var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {get:function(){return 13;}}); o.foo", '13')115shouldBe("var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {get:function(){return 13;}}); o.foo = 42; o.result;", '42')116shouldBe("var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {get:undefined}); o.foo", 'undefined')117shouldBe("var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {get:undefined}); o.foo = 42; o.result;", '42')118shouldBe("var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:function(){this.result = 13;}}); o.foo", '42')119shouldBe("var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:function(){this.result = 13;}}); o.foo = 42; o.result;", '13')120shouldBe("var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:undefined}); o.foo", '42')121shouldBe("var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:undefined}); o.foo = 42; o.result;", 'undefined')122// Repeat of the above, in strict mode.123// Either accessor may be omitted or replaced with undefined, or both may be replaced with undefined.124shouldBe("'use strict'; var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}); o.foo", '42')125shouldBe("'use strict'; var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}); o.foo = 42; o.result;", '42');126shouldBe("'use strict'; var o = Object.defineProperty({}, 'foo', {get:undefined, set:function(x){this.result = x;}}); o.foo", 'undefined')127shouldBe("'use strict'; var o = Object.defineProperty({}, 'foo', {get:undefined, set:function(x){this.result = x;}}); o.foo = 42; o.result;", '42');128shouldBe("'use strict'; var o = Object.defineProperty({}, 'foo', {set:function(x){this.result = x;}}); o.foo", 'undefined')129shouldBe("'use strict'; var o = Object.defineProperty({}, 'foo', {set:function(x){this.result = x;}}); o.foo = 42; o.result;", '42');130shouldBe("'use strict'; var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}, set:undefined}); o.foo", '42')131shouldThrow("'use strict'; var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}, set:undefined}); o.foo = 42; o.result;");132shouldBe("'use strict'; var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}}); o.foo", '42')133shouldThrow("'use strict'; var o = Object.defineProperty({}, 'foo', {get:function(){return 42;}}); o.foo = 42; o.result;");134shouldBe("'use strict'; var o = Object.defineProperty({}, 'foo', {get:undefined, set:undefined}); o.foo", 'undefined')135shouldThrow("'use strict'; var o = Object.defineProperty({}, 'foo', {get:undefined, set:undefined}); o.foo = 42; o.result;");136// Test replacing or removing either the getter or setter individually.137shouldBe("'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {get:function(){return 13;}}); o.foo", '13')138shouldBe("'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {get:function(){return 13;}}); o.foo = 42; o.result;", '42')139shouldBe("'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {get:undefined}); o.foo", 'undefined')140shouldBe("'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {get:undefined}); o.foo = 42; o.result;", '42')141shouldBe("'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:function(){this.result = 13;}}); o.foo", '42')142shouldBe("'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:function(){this.result = 13;}}); o.foo = 42; o.result;", '13')143shouldBe("'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:undefined}); o.foo", '42')144shouldThrow("'use strict'; var o = Object.defineProperty(Object.defineProperty({foo:1}, 'foo', {get:function(){return 42;}, set:function(x){this.result = x;}}), 'foo', {set:undefined}); o.foo = 42; o.result;")145Object.defineProperty(Object.prototype, 0, {get:function(){ return false; }, configurable:true})146shouldBeTrue("0 in Object.prototype");147shouldBeTrue("'0' in Object.prototype");148delete Object.prototype[0];149Object.defineProperty(Object.prototype, 'readOnly', {value:true, configurable:true, writable:false})150shouldBeTrue("var o = {}; o.readOnly = false; o.readOnly");151shouldThrow("'use strict'; var o = {}; o.readOnly = false; o.readOnly");152delete Object.prototype.readOnly;153// Check the writable attribute is set correctly when redefining an accessor as a data descriptor.154shouldBeFalse("Object.getOwnPropertyDescriptor(Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return false; }, configurable: true}), 'foo', {value:false}), 'foo').writable");155shouldBeFalse("Object.getOwnPropertyDescriptor(Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return false; }, configurable: true}), 'foo', {value:false, writable: false}), 'foo').writable");156shouldBeTrue("Object.getOwnPropertyDescriptor(Object.defineProperty(Object.defineProperty({}, 'foo', {get: function() { return false; }, configurable: true}), 'foo', {value:false, writable: true}), 'foo').writable");157// If array length is read-only, [[Put]] should fail.158shouldBeFalse("var a = Object.defineProperty([], 'length', {writable: false}); a[0] = 42; 0 in a;");159shouldThrow("'use strict'; var a = Object.defineProperty([], 'length', {writable: false}); a[0] = 42; 0 in a;");160// If array property is read-only, [[Put]] should fail.161shouldBe("var a = Object.defineProperty([42], '0', {writable: false}); a[0] = false; a[0];", '42');162shouldThrow("'use strict'; var a = Object.defineProperty([42], '0', {writable: false}); a[0] = false; a[0];");163// If array property is an undefined setter, [[Put]] should fail.164shouldBeUndefined("var a = Object.defineProperty([], '0', {set: undefined}); a[0] = 42; a[0];");165shouldThrow("'use strict'; var a = Object.defineProperty([], '0', {set: undefined}); a[0] = 42; a[0];");166function testObject()167{168 // Test case from https://bugs.webkit.org/show_bug.cgi?id=38636169 Object.defineProperty(anObj, 'slot1', {value: 'foo', enumerable: true});170 Object.defineProperty(anObj, 'slot2', {value: 'bar', writable: true}); 171 Object.defineProperty(anObj, 'slot3', {value: 'baz', enumerable: false}); 172 Object.defineProperty(anObj, 'slot4', {value: 'goo', configurable: false}); 173 shouldBe("anObj.slot1", '"foo"');174 shouldBe("anObj.slot2", '"bar"');175 anObj.slot2 = 'bad value';176 shouldBeTrue("anObj.propertyIsEnumerable('slot1')");177 shouldBeFalse("anObj.propertyIsEnumerable('slot2')");178 delete anObj.slot4;179 shouldBe("anObj.slot4", '"goo"');180 // Test case from https://bugs.webkit.org/show_bug.cgi?id=48911181 Object.defineProperty(Object.getPrototypeOf(anObj), 'slot5', {get: function() { return this._Slot5; }, set: function(v) { this._Slot5 = v; }, configurable: false}); 182 anObj.slot5 = 123;183 shouldBe("anObj.slot5", '123');184 shouldBe("anObj._Slot5", '123');185 shouldBeUndefined("Object.getOwnPropertyDescriptor(anObj, 'slot5')");186 Object.defineProperty(anObj, 'slot5', { value: 456 });187 shouldBe("anObj.slot5", '456');188 shouldBe("anObj._Slot5", '123');189 shouldBe("Object.getOwnPropertyDescriptor(anObj, 'slot5').value", '456');190}191var anObj = {};192testObject();193var anObj = this;...
test_properties.py
Source:test_properties.py
...17 def tearDown(self):18 self.part_model.delete()19 super().tearDown()20 def test_create_and_delete_property_model(self):21 new_property = self.client.create_property(22 model=self.part_model,23 name="New property",24 description="Nice prop",25 property_type=PropertyType.CHAR_VALUE,26 default_value="EUREKA!",27 )28 # check whether the property has been created and whether it's name and type are correct29 self.part_model.refresh()30 new_prop = self.part_model.property(name="New property")31 self.assertEqual(new_property, new_prop)32 self.assertIsInstance(new_prop, Property)33 self.assertEqual(new_prop.value, "EUREKA!")34 self.assertEqual(new_prop._json_data["property_type"], PropertyType.CHAR_VALUE)35 # Now delete the property model36 new_property.delete()37 # Retrieve the model again38 self.part_model.refresh()39 # Check whether it still has the property model that has just been deleted40 with self.assertRaises(NotFoundError):41 self.part_model.property("New property")42 def test_create_property_unknown_type(self):43 with self.assertRaises(IllegalArgumentError):44 self.part_model.add_property(45 name="Incorrect property type", property_type="Incorrect property type"46 )47 def test_create_property_on_instance(self):48 with self.assertRaises(IllegalArgumentError):49 self.client.create_property(50 name="Properties are created on models only", model=self.part_instance51 )52 def test_create_property_incorrect_value(self):53 with self.assertRaises(APIError):54 self.part_model.add_property(55 name="Boolean",56 property_type=PropertyType.BOOLEAN_VALUE,57 default_value="Not gonna work",58 )59 # 1.1660 def test_creation_of_all_property_model_types(self):61 # set up62 types = [63 PropertyType.CHAR_VALUE,64 PropertyType.TEXT_VALUE,65 PropertyType.INT_VALUE,66 PropertyType.FLOAT_VALUE,67 PropertyType.BOOLEAN_VALUE,68 PropertyType.DATETIME_VALUE,69 PropertyType.LINK_VALUE,70 PropertyType.DATETIME_VALUE,71 PropertyType.SINGLE_SELECT_VALUE,72 PropertyType.REFERENCES_VALUE,73 ]74 values = [75 "string",76 "text",77 0,78 3.1415,79 False,80 datetime.now().isoformat(sep="T"),81 "https://google.com",82 None,83 None,84 None,85 ]86 for property_type, value in zip(types, values):87 with self.subTest(msg=property_type):88 # setUp89 prop = self.part_model.add_property(90 name=property_type,91 property_type=property_type,92 default_value=value,93 )94 # testing95 if value is not None:96 self.assertTrue(prop.has_value())97 else:98 self.assertFalse(prop.has_value())99 # tearDown100 prop.delete()101class TestProperties(TestBetamax):102 def setUp(self):103 super().setUp()104 self.wheel_model = self.project.model("Wheel")105 self.bike_model = self.project.model("Bike")106 self.prop_name = "__Test property"107 self.prop_model = self.bike_model.add_property(108 name=self.prop_name,109 property_type=PropertyType.INT_VALUE,110 description="description of the property",111 unit="unit of the property",112 default_value=42,113 )114 self.bike = self.bike_model.instance()115 self.prop = self.bike.property(name=self.prop_name)116 def tearDown(self):117 if self.prop_model:118 self.prop_model.delete()119 super().tearDown()120 def test_retrieve_properties(self):121 properties = self.project.properties("Diameter")122 self.assertIsInstance(properties, list)123 self.assertTrue(len(properties) > 0)124 def test_retrieve_property(self):125 prop = self.project.property(name="Cheap?", category=Category.MODEL)126 self.assertIsInstance(prop, Property)127 self.assertTrue(prop)128 def test_retrieve_property_model(self):129 model = self.prop.model()130 self.assertEqual(self.prop_model, model)131 models_model = self.prop_model.model()132 self.assertEqual(self.prop_model, models_model)133 def test_property_attributes(self):134 attributes = [135 "_client",136 "_json_data",137 "id",138 "name",139 "created_at",140 "updated_at",141 "ref",142 "output",143 "_value",144 "_options",145 "type",146 "category",147 "_validators",148 ]149 obj = self.project.property(name="Cheap?", category=Category.MODEL)150 for attribute in attributes:151 with self.subTest(msg=attribute):152 self.assertTrue(153 hasattr(obj, attribute),154 f"Could not find '{attribute}' in the object: '{obj.__dict__.keys()}'",155 )156 def test_retrieve_properties_with_kwargs(self):157 # setUp158 properties_with_kwargs = self.client.properties(part_id=self.bike.id)159 self.assertTrue(properties_with_kwargs)160 # testing161 for prop in properties_with_kwargs:162 with self.subTest(msg=prop.name):163 self.assertEqual(prop.part.id, self.bike.id)164 def test_get_property_by_name(self):165 gears_property = self.project.properties(name="Gears", category=Category.INSTANCE)[0]166 self.assertEqual(self.bike.property("Gears"), gears_property)167 def test_get_property_by_uuid(self):168 gears_id = self.bike.property("Gears").id169 gears_property = self.project.properties(pk=gears_id, category=Category.INSTANCE)[0]170 self.assertEqual(self.bike.property(gears_id), gears_property)171 def test_get_invalid_property(self):172 with self.assertRaises(NotFoundError):173 self.bike.property("Price")174 def test_set_property(self):175 new_value = self.prop.value * 2176 self.assertNotEqual(new_value, self.prop.value)177 self.prop.value = new_value178 refreshed_prop = self.bike.property(name=self.prop_name)179 self.assertEqual(new_value, self.prop.value)180 self.assertEqual(new_value, self.prop._value)181 self.assertEqual(new_value, self.prop._json_data.get("value"))182 self.assertEqual(self.prop, refreshed_prop)183 self.assertEqual(self.prop.value, refreshed_prop.value)184 def test_part_of_property(self):185 bike2 = self.bike.property("Gears").part186 self.assertEqual(self.bike.id, bike2.id)187 # 1.11188 def test_edit_property_model_name(self):189 # setUp190 new_name = "Cogs"191 self.prop_model.edit(name=new_name)192 reloaded_prop = self.bike_model.property(name=new_name)193 # testing194 self.assertEqual(self.prop_model.id, reloaded_prop.id)195 self.assertEqual(new_name, reloaded_prop.name)196 self.assertEqual(self.prop_model.name, reloaded_prop.name)197 with self.assertRaises(IllegalArgumentError):198 self.prop_model.edit(name=True)199 def test_edit_property_model_description(self):200 # setUp201 new_description = "Cogs, definitely cogs."202 self.prop_model.edit(description=new_description)203 reloaded_prop = self.bike_model.property(name=self.prop_name)204 # testing205 self.assertEqual(self.prop_model.id, reloaded_prop.id)206 self.assertEqual(self.prop_model.description, reloaded_prop.description)207 with self.assertRaises(IllegalArgumentError):208 self.prop_model.edit(description=True)209 def test_edit_property_model_unit(self):210 # setUp211 new_unit = "Totally new units"212 self.prop_model.edit(unit=new_unit)213 reloaded_prop = self.bike_model.property(name=self.prop_name)214 # testing215 self.assertEqual(self.prop_model.id, reloaded_prop.id)216 self.assertEqual(self.prop_model.unit, reloaded_prop.unit)217 with self.assertRaises(IllegalArgumentError):218 self.prop_model.edit(unit=4)219 # test added due to #847 - providing no inputs overwrites values220 def test_edit_property_clear_values(self):221 # setup222 initial_name = "Property first name"223 initial_description = "Property created to test clearing values."224 initial_unit = "mm"225 self.prop_model.edit(name=initial_name, description=initial_description, unit=initial_unit)226 # Edit without mentioning values, everything should stay the same227 new_name = "Property second name"228 self.prop_model.edit(name=new_name)229 # testing230 self.assertEqual(self.prop_model.name, new_name)231 self.assertEqual(self.prop_model.description, initial_description)232 self.assertEqual(self.prop_model.unit, initial_unit),233 # Edit with clearing the values, name and status cannot be cleared234 self.prop_model.edit(name=None, description=None, unit=None)235 self.assertEqual(self.prop_model.name, new_name)236 self.assertEqual(self.prop_model.description, "")237 self.assertEqual(self.prop_model.unit, "")238 # 2.5.4239 def test_property_type(self):240 self.assertEqual(PropertyType.INT_VALUE, str(self.prop_model.type))241 def test_property_unit(self):242 self.assertEqual("unit of the property", str(self.prop_model.unit))243 def test_property_description(self):244 self.assertEqual("description of the property", str(self.prop_model.description))245 # 3.0246 def test_copy_property_model(self):247 # setUp248 copied_property = self.prop_model.copy(249 target_part=self.wheel_model, name="Copied property"250 )251 # testing252 self.assertEqual(copied_property.name, "Copied property")253 self.assertEqual(copied_property.description, self.prop_model.description)254 self.assertEqual(copied_property.unit, self.prop_model.unit)255 self.assertEqual(copied_property.value, self.prop_model.value)256 # tearDown257 copied_property.delete()258 def test_copy_property_instance(self):259 # setUp260 self.prop.value = 200261 copied_property = self.prop.copy(262 target_part=self.project.part(name="Front Wheel"), name="Copied property instance"263 )264 # testing265 self.assertEqual(copied_property.name, "Copied property instance")266 self.assertEqual(copied_property.description, self.prop.description)267 self.assertEqual(copied_property.unit, self.prop.unit)268 self.assertEqual(copied_property.value, self.prop.value)269 # tearDown270 copied_property.model().delete()271 def test_copy_property_instance_to_model(self):272 with self.assertRaises(IllegalArgumentError):273 self.prop.copy(target_part=self.prop_model)274 def test_move_property_model(self):275 # setUp276 moved_property = self.prop_model.move(target_part=self.wheel_model, name="Moved property")277 # testing278 self.assertEqual(moved_property.name, "Moved property")279 self.assertEqual(moved_property.description, self.prop_model.description)280 self.assertEqual(moved_property.unit, self.prop_model.unit)281 self.assertEqual(moved_property.value, self.prop_model.value)282 with self.assertRaises(NotFoundError):283 self.project.property(id=self.prop_model.id)284 # tearDown285 # for a correct teardown in the unittest we need to -reassign- the moved one to the self.test_property_model286 self.prop_model = moved_property287 def test_move_property_instance(self):288 # setUp289 moved_property = self.prop.move(290 target_part=self.wheel_model.instances()[0], name="moved property"291 )292 # testing293 with self.assertRaises(APIError):294 self.project.property(id=self.prop_model.id)295 # tearDown296 # for a correct teardown in the unittest we need to -reassign- the moved one to the self.test_property_model297 self.prop_model = moved_property.model()298 def test_retrieve_properties_with_refs(self):299 # setup300 dual_pad_ref = "dual-pad"301 dual_pad_name = "Dual Pad?"302 dual_pad_property = self.project.property(ref=dual_pad_ref)303 dual_pad_property_model = self.project.property(ref=dual_pad_ref, category=Category.MODEL)304 seat_part = self.project.part(name="Seat")305 dual_pad_prop_retrieved_from_seat = seat_part.property(dual_pad_ref)306 # testing307 self.assertIsInstance(dual_pad_property, Property)308 self.assertEqual(dual_pad_name, dual_pad_property.name)309 self.assertEqual(Category.INSTANCE, dual_pad_property.category)310 self.assertIsInstance(dual_pad_property_model, Property)311 self.assertEqual(dual_pad_name, dual_pad_property_model.name)312 self.assertEqual(Category.MODEL, dual_pad_property_model.category)313 self.assertIsInstance(dual_pad_prop_retrieved_from_seat, Property)314 self.assertEqual(dual_pad_name, dual_pad_prop_retrieved_from_seat.name)315 self.assertEqual(Category.INSTANCE, dual_pad_prop_retrieved_from_seat.category)316 self.assertEqual(dual_pad_property.id, dual_pad_prop_retrieved_from_seat.id)317class TestPropertiesUpdateProperties(TestBetamax):318 def setUp(self):319 super().setUp()320 self.bike = self.project.model("Bike")321 self.submodel = self.project.create_model(name="_test submodel", parent=self.bike)322 self.prop_1 = self.submodel.add_property(323 name=PropertyType.CHAR_VALUE, property_type=PropertyType.CHAR_VALUE324 )325 self.prop_2 = self.submodel.add_property(326 name=PropertyType.TEXT_VALUE, property_type=PropertyType.TEXT_VALUE327 )328 self.props = [self.prop_1, self.prop_2]329 def tearDown(self):330 self.submodel.delete()331 super().tearDown()332 def _refresh_prop(self, p):333 return self.client.property(pk=p.id, category=p.category)334 def test_bulk_update(self):335 """Test the API using the Client method."""336 update = [dict(id=p.id, value="new value") for p in self.props]337 updated_properties = self.client.update_properties(properties=update)338 # testing339 self.assertIsInstance(updated_properties, list)340 self.assertTrue(all(p1 == p2 for p1, p2 in zip(self.props, updated_properties)))341 self.assertTrue(all(isinstance(p, Property) for p in updated_properties))342 self.assertTrue(all(p.value == "new value" for p in updated_properties))343 def test_bulk_update_manual(self):344 """Test storing of value updates in the Property class."""345 # setUp346 Property.set_bulk_update(True)347 self.prop_1.value = "new value"348 self.prop_2.value = "another value"349 # testing350 self.assertIsNone(self._refresh_prop(self.prop_1).value)351 self.assertIsNone(self._refresh_prop(self.prop_2).value)352 Property.update_values(client=self.client)353 self.assertEqual(self._refresh_prop(self.prop_1).value, "new value")354 self.assertEqual(self._refresh_prop(self.prop_2).value, "another value")355 def test_bulk_update_reset(self):356 """Test whether bulk update is reset to `False` after update is performed."""357 # setUp358 Property.set_bulk_update(True)359 self.prop_1.value = "new value"360 # testing361 self.assertIsNone(self._refresh_prop(self.prop_1).value)362 Property.update_values(client=self.client)363 self.assertEqual(self._refresh_prop(self.prop_1).value, "new value")364 self.assertFalse(Property._USE_BULK_UPDATE)365 # setUp 2366 Property.set_bulk_update(True)367 self.prop_2.value = "another value"368 # testing 2369 self.assertIsNone(self._refresh_prop(self.prop_2).value)370 Property.update_values(client=self.client, use_bulk_update=True)371 self.assertEqual(self._refresh_prop(self.prop_2).value, "another value")372 self.assertTrue(Property._USE_BULK_UPDATE)373 # tearDown374 Property.set_bulk_update(False)375class TestPropertiesWithReferenceProperty(TestBetamax):376 def setUp(self):377 super().setUp()378 self.wheel_model = self.project.model("Wheel")379 self.bike = self.project.model("Bike")380 self.test_ref_property_model = self.bike.add_property(381 name=f"__Test ref property @ {datetime.now()}",382 property_type=PropertyType.REFERENCES_VALUE,383 description="Description of test ref property",384 unit="no unit",385 default_value=[self.wheel_model],386 )387 self.test_ref_property_model.validators = [SingleReferenceValidator()]388 def tearDown(self):389 self.test_ref_property_model.delete()390 super().tearDown()391 def test_copy_reference_property_with_options(self):392 # setUp393 copied_ref_property = self.test_ref_property_model.copy(394 target_part=self.wheel_model, name="__Copied ref property"...
11.2.1-1.js
Source:11.2.1-1.js
1/* The contents of this file are subject to the Netscape Public2 * License Version 1.1 (the "License"); you may not use this file3 * except in compliance with the License. You may obtain a copy of4 * the License at http://www.mozilla.org/NPL/5 *6 * Software distributed under the License is distributed on an "AS7 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or8 * implied. See the License for the specific language governing9 * rights and limitations under the License.10 *11 * The Original Code is Mozilla Communicator client code, released March12 * 31, 1998.13 *14 * The Initial Developer of the Original Code is Netscape Communications15 * Corporation. Portions created by Netscape are16 * Copyright (C) 1998 Netscape Communications Corporation. All17 * Rights Reserved.18 *19 * Contributor(s): 20 * 21 */22/**23 File Name: 11.2.1-1.js24 ECMA Section: 11.2.1 Property Accessors25 Description:26 Properties are accessed by name, using either the dot notation:27 MemberExpression . Identifier28 CallExpression . Identifier29 or the bracket notation: MemberExpression [ Expression ]30 CallExpression [ Expression ]31 The dot notation is explained by the following syntactic conversion:32 MemberExpression . Identifier33 is identical in its behavior to34 MemberExpression [ <identifier-string> ]35 and similarly36 CallExpression . Identifier37 is identical in its behavior to38 CallExpression [ <identifier-string> ]39 where <identifier-string> is a string literal containing the same sequence40 of characters as the Identifier.41 The production MemberExpression : MemberExpression [ Expression ] is42 evaluated as follows:43 1. Evaluate MemberExpression.44 2. Call GetValue(Result(1)).45 3. Evaluate Expression.46 4. Call GetValue(Result(3)).47 5. Call ToObject(Result(2)).48 6. Call ToString(Result(4)).49 7. Return a value of type Reference whose base object is Result(5) and50 whose property name is Result(6).51 The production CallExpression : CallExpression [ Expression ] is evaluated52 in exactly the same manner, except that the contained CallExpression is53 evaluated in step 1.54 Author: christine@netscape.com55 Date: 12 november 199756*/57 var SECTION = "11.2.1-1";58 var VERSION = "ECMA_1";59 startTest();60 var TITLE = "Property Accessors";61 writeHeaderToLog( SECTION + " "+TITLE );62 var testcases = new Array();63 // go through all Native Function objects, methods, and properties and get their typeof.64 var PROPERTY = new Array();65 var p = 0;66 // properties and functions of the global object67 PROPERTY[p++] = new Property( "this", "NaN", "number" );68 PROPERTY[p++] = new Property( "this", "Infinity", "number" );69 PROPERTY[p++] = new Property( "this", "eval", "function" );70 PROPERTY[p++] = new Property( "this", "parseInt", "function" );71 PROPERTY[p++] = new Property( "this", "parseFloat", "function" );72 PROPERTY[p++] = new Property( "this", "escape", "function" );73 PROPERTY[p++] = new Property( "this", "unescape", "function" );74 PROPERTY[p++] = new Property( "this", "isNaN", "function" );75 PROPERTY[p++] = new Property( "this", "isFinite", "function" );76 PROPERTY[p++] = new Property( "this", "Object", "function" );77 PROPERTY[p++] = new Property( "this", "Number", "function" );78 PROPERTY[p++] = new Property( "this", "Function", "function" );79 PROPERTY[p++] = new Property( "this", "Array", "function" );80 PROPERTY[p++] = new Property( "this", "String", "function" );81 PROPERTY[p++] = new Property( "this", "Boolean", "function" );82 PROPERTY[p++] = new Property( "this", "Date", "function" );83 PROPERTY[p++] = new Property( "this", "Math", "object" );84 // properties and methods of Object objects85 PROPERTY[p++] = new Property( "Object", "prototype", "object" );86 PROPERTY[p++] = new Property( "Object", "toString", "function" );87 PROPERTY[p++] = new Property( "Object", "valueOf", "function" );88 PROPERTY[p++] = new Property( "Object", "constructor", "function" );89 // properties of the Function object90 PROPERTY[p++] = new Property( "Function", "prototype", "function" );91 PROPERTY[p++] = new Property( "Function.prototype", "toString", "function" );92 PROPERTY[p++] = new Property( "Function.prototype", "length", "number" );93 PROPERTY[p++] = new Property( "Function.prototype", "valueOf", "function" );94 Function.prototype.myProperty = "hi";95 PROPERTY[p++] = new Property( "Function.prototype", "myProperty", "string" );96 // properties of the Array object97 PROPERTY[p++] = new Property( "Array", "prototype", "object" );98 PROPERTY[p++] = new Property( "Array", "length", "number" );99 PROPERTY[p++] = new Property( "Array.prototype", "constructor", "function" );100 PROPERTY[p++] = new Property( "Array.prototype", "toString", "function" );101 PROPERTY[p++] = new Property( "Array.prototype", "join", "function" );102 PROPERTY[p++] = new Property( "Array.prototype", "reverse", "function" );103 PROPERTY[p++] = new Property( "Array.prototype", "sort", "function" );104 // properties of the String object105 PROPERTY[p++] = new Property( "String", "prototype", "object" );106 PROPERTY[p++] = new Property( "String", "fromCharCode", "function" );107 PROPERTY[p++] = new Property( "String.prototype", "toString", "function" );108 PROPERTY[p++] = new Property( "String.prototype", "constructor", "function" );109 PROPERTY[p++] = new Property( "String.prototype", "valueOf", "function" );110 PROPERTY[p++] = new Property( "String.prototype", "charAt", "function" );111 PROPERTY[p++] = new Property( "String.prototype", "charCodeAt", "function" );112 PROPERTY[p++] = new Property( "String.prototype", "indexOf", "function" );113 PROPERTY[p++] = new Property( "String.prototype", "lastIndexOf", "function" );114 PROPERTY[p++] = new Property( "String.prototype", "split", "function" );115 PROPERTY[p++] = new Property( "String.prototype", "substring", "function" );116 PROPERTY[p++] = new Property( "String.prototype", "toLowerCase", "function" );117 PROPERTY[p++] = new Property( "String.prototype", "toUpperCase", "function" );118 PROPERTY[p++] = new Property( "String.prototype", "length", "number" );119 // properties of the Boolean object120 PROPERTY[p++] = new Property( "Boolean", "prototype", "object" );121 PROPERTY[p++] = new Property( "Boolean", "constructor", "function" );122 PROPERTY[p++] = new Property( "Boolean.prototype", "valueOf", "function" );123 PROPERTY[p++] = new Property( "Boolean.prototype", "toString", "function" );124 // properties of the Number object125 PROPERTY[p++] = new Property( "Number", "MAX_VALUE", "number" );126 PROPERTY[p++] = new Property( "Number", "MIN_VALUE", "number" );127 PROPERTY[p++] = new Property( "Number", "NaN", "number" );128 PROPERTY[p++] = new Property( "Number", "NEGATIVE_INFINITY", "number" );129 PROPERTY[p++] = new Property( "Number", "POSITIVE_INFINITY", "number" );130 PROPERTY[p++] = new Property( "Number.prototype", "toString", "function" );131 PROPERTY[p++] = new Property( "Number.prototype", "constructor", "function" );132 PROPERTY[p++] = new Property( "Number.prototype", "valueOf", "function" );133 // properties of the Math Object.134 PROPERTY[p++] = new Property( "Math", "E", "number" );135 PROPERTY[p++] = new Property( "Math", "LN10", "number" );136 PROPERTY[p++] = new Property( "Math", "LN2", "number" );137 PROPERTY[p++] = new Property( "Math", "LOG2E", "number" );138 PROPERTY[p++] = new Property( "Math", "LOG10E", "number" );139 PROPERTY[p++] = new Property( "Math", "PI", "number" );140 PROPERTY[p++] = new Property( "Math", "SQRT1_2", "number" );141 PROPERTY[p++] = new Property( "Math", "SQRT2", "number" );142 PROPERTY[p++] = new Property( "Math", "abs", "function" );143 PROPERTY[p++] = new Property( "Math", "acos", "function" );144 PROPERTY[p++] = new Property( "Math", "asin", "function" );145 PROPERTY[p++] = new Property( "Math", "atan", "function" );146 PROPERTY[p++] = new Property( "Math", "atan2", "function" );147 PROPERTY[p++] = new Property( "Math", "ceil", "function" );148 PROPERTY[p++] = new Property( "Math", "cos", "function" );149 PROPERTY[p++] = new Property( "Math", "exp", "function" );150 PROPERTY[p++] = new Property( "Math", "floor", "function" );151 PROPERTY[p++] = new Property( "Math", "log", "function" );152 PROPERTY[p++] = new Property( "Math", "max", "function" );153 PROPERTY[p++] = new Property( "Math", "min", "function" );154 PROPERTY[p++] = new Property( "Math", "pow", "function" );155 PROPERTY[p++] = new Property( "Math", "random", "function" );156 PROPERTY[p++] = new Property( "Math", "round", "function" );157 PROPERTY[p++] = new Property( "Math", "sin", "function" );158 PROPERTY[p++] = new Property( "Math", "sqrt", "function" );159 PROPERTY[p++] = new Property( "Math", "tan", "function" );160 // properties of the Date object161 PROPERTY[p++] = new Property( "Date", "parse", "function" );162 PROPERTY[p++] = new Property( "Date", "prototype", "object" );163 PROPERTY[p++] = new Property( "Date", "UTC", "function" );164 PROPERTY[p++] = new Property( "Date.prototype", "constructor", "function" );165 PROPERTY[p++] = new Property( "Date.prototype", "toString", "function" );166 PROPERTY[p++] = new Property( "Date.prototype", "valueOf", "function" );167 PROPERTY[p++] = new Property( "Date.prototype", "getTime", "function" );168 PROPERTY[p++] = new Property( "Date.prototype", "getYear", "function" );169 PROPERTY[p++] = new Property( "Date.prototype", "getFullYear", "function" );170 PROPERTY[p++] = new Property( "Date.prototype", "getUTCFullYear", "function" );171 PROPERTY[p++] = new Property( "Date.prototype", "getMonth", "function" );172 PROPERTY[p++] = new Property( "Date.prototype", "getUTCMonth", "function" );173 PROPERTY[p++] = new Property( "Date.prototype", "getDate", "function" );174 PROPERTY[p++] = new Property( "Date.prototype", "getUTCDate", "function" );175 PROPERTY[p++] = new Property( "Date.prototype", "getDay", "function" );176 PROPERTY[p++] = new Property( "Date.prototype", "getUTCDay", "function" );177 PROPERTY[p++] = new Property( "Date.prototype", "getHours", "function" );178 PROPERTY[p++] = new Property( "Date.prototype", "getUTCHours", "function" );179 PROPERTY[p++] = new Property( "Date.prototype", "getMinutes", "function" );180 PROPERTY[p++] = new Property( "Date.prototype", "getUTCMinutes", "function" );181 PROPERTY[p++] = new Property( "Date.prototype", "getSeconds", "function" );182 PROPERTY[p++] = new Property( "Date.prototype", "getUTCSeconds", "function" );183 PROPERTY[p++] = new Property( "Date.prototype", "getMilliseconds","function" );184 PROPERTY[p++] = new Property( "Date.prototype", "getUTCMilliseconds", "function" );185 PROPERTY[p++] = new Property( "Date.prototype", "setTime", "function" );186 PROPERTY[p++] = new Property( "Date.prototype", "setMilliseconds","function" );187 PROPERTY[p++] = new Property( "Date.prototype", "setUTCMilliseconds", "function" );188 PROPERTY[p++] = new Property( "Date.prototype", "setSeconds", "function" );189 PROPERTY[p++] = new Property( "Date.prototype", "setUTCSeconds", "function" );190 PROPERTY[p++] = new Property( "Date.prototype", "setMinutes", "function" );191 PROPERTY[p++] = new Property( "Date.prototype", "setUTCMinutes", "function" );192 PROPERTY[p++] = new Property( "Date.prototype", "setHours", "function" );193 PROPERTY[p++] = new Property( "Date.prototype", "setUTCHours", "function" );194 PROPERTY[p++] = new Property( "Date.prototype", "setDate", "function" );195 PROPERTY[p++] = new Property( "Date.prototype", "setUTCDate", "function" );196 PROPERTY[p++] = new Property( "Date.prototype", "setMonth", "function" );197 PROPERTY[p++] = new Property( "Date.prototype", "setUTCMonth", "function" );198 PROPERTY[p++] = new Property( "Date.prototype", "setFullYear", "function" );199 PROPERTY[p++] = new Property( "Date.prototype", "setUTCFullYear", "function" );200 PROPERTY[p++] = new Property( "Date.prototype", "setYear", "function" );201 PROPERTY[p++] = new Property( "Date.prototype", "toLocaleString", "function" );202 PROPERTY[p++] = new Property( "Date.prototype", "toUTCString", "function" );203 PROPERTY[p++] = new Property( "Date.prototype", "toGMTString", "function" );204 for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) {205 RESULT = eval("typeof " + PROPERTY[i].object + "." + PROPERTY[i].name );206 testcases[tc++] = new TestCase( SECTION,207 "typeof " + PROPERTY[i].object + "." + PROPERTY[i].name,208 PROPERTY[i].type,209 RESULT );210 RESULT = eval("typeof " + PROPERTY[i].object + "['" + PROPERTY[i].name +"']");211 testcases[tc++] = new TestCase( SECTION,212 "typeof " + PROPERTY[i].object + "['" + PROPERTY[i].name +"']",213 PROPERTY[i].type,214 RESULT );215 }216 test();217function test() {218 for ( tc=0; tc < testcases.length; tc++ ) {219 testcases[tc].passed = writeTestCaseResult(220 testcases[tc].expect,221 testcases[tc].actual,222 testcases[tc].description +" = "+223 testcases[tc].actual );224 testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value ";225 }226 stopTest();227 return ( testcases );228}229function MyObject( arg0, arg1, arg2, arg3, arg4 ) {230 this.name = arg0;231}232function Property( object, name, type ) {233 this.object = object;234 this.name = name;235 this.type = type;...
GridMaterialPropertySpec.js
Source:GridMaterialPropertySpec.js
1defineSuite([2 'DataSources/GridMaterialProperty',3 'Core/Cartesian2',4 'Core/Color',5 'Core/JulianDate',6 'Core/TimeInterval',7 'DataSources/ConstantProperty',8 'DataSources/SampledProperty',9 'DataSources/TimeIntervalCollectionProperty'10 ], function(11 GridMaterialProperty,12 Cartesian2,13 Color,14 JulianDate,15 TimeInterval,16 ConstantProperty,17 SampledProperty,18 TimeIntervalCollectionProperty) {19 'use strict';2021 it('constructor provides the expected defaults', function() {22 var property = new GridMaterialProperty();23 expect(property.color).toBeUndefined();24 expect(property.cellAlpha).toBeUndefined();25 expect(property.lineCount).toBeUndefined();26 expect(property.lineThickness).toBeUndefined();27 expect(property.lineOffset).toBeUndefined();2829 expect(property.getType()).toEqual('Grid');3031 var result = property.getValue();32 expect(result.color).toEqual(Color.WHITE);33 expect(result.cellAlpha).toEqual(0.1);34 expect(result.lineCount).toEqual(new Cartesian2(8, 8));35 expect(result.lineThickness).toEqual(new Cartesian2(1.0, 1.0));36 expect(result.lineOffset).toEqual(new Cartesian2(0.0, 0.0));37 });3839 it('constructor sets options and allows raw assignment', function() {40 var options = {41 color : Color.RED,42 cellAlpha : 1,43 lineCount : new Cartesian2(2, 3),44 lineThickness : new Cartesian2(4, 5),45 lineOffset : new Cartesian2(6, 7)46 };4748 var property = new GridMaterialProperty(options);49 expect(property.color).toBeInstanceOf(ConstantProperty);50 expect(property.cellAlpha).toBeInstanceOf(ConstantProperty);51 expect(property.lineCount).toBeInstanceOf(ConstantProperty);52 expect(property.lineThickness).toBeInstanceOf(ConstantProperty);53 expect(property.lineOffset).toBeInstanceOf(ConstantProperty);5455 expect(property.color.getValue()).toEqual(options.color);56 expect(property.cellAlpha.getValue()).toEqual(options.cellAlpha);57 expect(property.lineCount.getValue()).toEqual(options.lineCount);58 expect(property.lineThickness.getValue()).toEqual(options.lineThickness);59 expect(property.lineOffset.getValue()).toEqual(options.lineOffset);60 });6162 it('works with constant values', function() {63 var property = new GridMaterialProperty();64 property.color = new ConstantProperty(Color.RED);65 property.cellAlpha = new ConstantProperty(1.0);66 property.lineCount = new ConstantProperty(new Cartesian2(3.4, 5.0));67 property.lineThickness = new ConstantProperty(new Cartesian2(2, 3));68 property.lineOffset = new ConstantProperty(new Cartesian2(0.7, 0.8));6970 var result = property.getValue(JulianDate.now());71 expect(result.color).toEqual(Color.RED);72 expect(result.cellAlpha).toEqual(1);73 expect(result.lineCount).toEqual(new Cartesian2(3.4, 5.0));74 expect(result.lineThickness).toEqual(new Cartesian2(2, 3));75 expect(result.lineOffset).toEqual(new Cartesian2(0.7, 0.8));76 });7778 it('works with dynamic values', function() {79 var property = new GridMaterialProperty();80 property.color = new TimeIntervalCollectionProperty();81 property.cellAlpha = new TimeIntervalCollectionProperty();82 property.lineCount = new TimeIntervalCollectionProperty();83 property.lineThickness = new TimeIntervalCollectionProperty();84 property.lineOffset = new TimeIntervalCollectionProperty();8586 var start = new JulianDate(1, 0);87 var stop = new JulianDate(2, 0);88 property.color.intervals.addInterval(new TimeInterval({89 start : start,90 stop : stop,91 data : Color.BLUE92 }));93 property.cellAlpha.intervals.addInterval(new TimeInterval({94 start : start,95 stop : stop,96 data : 1.097 }));98 property.lineCount.intervals.addInterval(new TimeInterval({99 start : start,100 stop : stop,101 data : new Cartesian2(3.4, 5.0)102 }));103 property.lineThickness.intervals.addInterval(new TimeInterval({104 start : start,105 stop : stop,106 data : new Cartesian2(2, 3)107 }));108 property.lineOffset.intervals.addInterval(new TimeInterval({109 start : start,110 stop : stop,111 data : new Cartesian2(0.7, 0.8)112 }));113114 var result = property.getValue(start);115 expect(result.color).toEqual(Color.BLUE);116 expect(result.cellAlpha).toEqual(1);117 expect(result.lineCount).toEqual(new Cartesian2(3.4, 5.0));118 expect(result.lineThickness).toEqual(new Cartesian2(2, 3));119 expect(result.lineOffset).toEqual(new Cartesian2(0.7, 0.8));120 });121122 it('works with a result parameter', function() {123 var property = new GridMaterialProperty();124 property.color = new ConstantProperty(Color.RED);125 property.cellAlpha = new ConstantProperty(1.0);126 property.lineCount = new ConstantProperty(new Cartesian2(3.4, 5.0));127 property.lineThickness = new ConstantProperty(new Cartesian2(2, 3));128 property.lineOffset = new ConstantProperty(new Cartesian2(0.7, 0.8));129130 var result = {};131 var returnedResult = property.getValue(JulianDate.now(), result);132 expect(result).toBe(returnedResult);133 expect(result.color).toEqual(Color.RED);134 expect(result.cellAlpha).toEqual(1.0);135 expect(result.lineCount).toEqual(new Cartesian2(3.4, 5.0));136 expect(result.lineThickness).toEqual(new Cartesian2(2, 3));137 expect(result.lineOffset).toEqual(new Cartesian2(0.7, 0.8));138 });139140 it('equals works', function() {141 var left = new GridMaterialProperty();142 left.color = new ConstantProperty(Color.RED);143 left.cellAlpha = new ConstantProperty(1.0);144 left.lineCount = new ConstantProperty(new Cartesian2(3.4, 5.0));145 left.lineThickness = new ConstantProperty(new Cartesian2(2, 3));146 left.lineOffset = new ConstantProperty(new Cartesian2(0.7, 0.8));147148 var right = new GridMaterialProperty();149 right.color = new ConstantProperty(Color.RED);150 right.cellAlpha = new ConstantProperty(1.0);151 right.lineCount = new ConstantProperty(new Cartesian2(3.4, 5.0));152 right.lineThickness = new ConstantProperty(new Cartesian2(2, 3));153 right.lineOffset = new ConstantProperty(new Cartesian2(0.7, 0.8));154155 expect(left.equals(right)).toEqual(true);156157 right.color = new ConstantProperty(Color.BLUE);158 expect(left.equals(right)).toEqual(false);159160 right.color = left.color;161 right.cellAlpha = new ConstantProperty(0.5);162 expect(left.equals(right)).toEqual(false);163164 right.cellAlpha = left.cellAlpha;165 right.lineCount = new ConstantProperty(new Cartesian2(4, 5.0));166 expect(left.equals(right)).toEqual(false);167168 right.lineCount = left.lineCount;169 right.lineThickness = new ConstantProperty(new Cartesian2(3, 2));170 expect(left.equals(right)).toEqual(false);171172 right.lineThickness = left.lineThickness;173 right.lineOffset = new ConstantProperty(new Cartesian2(0.8, 0.7));174 expect(left.equals(right)).toEqual(false);175176 right.lineOffset = left.lineOffset;177 expect(left.equals(right)).toEqual(true);178 });179180 it('raises definitionChanged when a property is assigned or modified', function() {181 var property = new GridMaterialProperty();182 var listener = jasmine.createSpy('listener');183 property.definitionChanged.addEventListener(listener);184185 var oldValue = property.color;186 property.color = new ConstantProperty(Color.WHITE);187 expect(listener).toHaveBeenCalledWith(property, 'color', property.color, oldValue);188 listener.calls.reset();189190 property.color.setValue(Color.BLACK);191 expect(listener).toHaveBeenCalledWith(property, 'color', property.color, property.color);192 listener.calls.reset();193194 property.color = property.color;195 expect(listener.calls.count()).toEqual(0);196 listener.calls.reset();197198 oldValue = property.cellAlpha;199 property.cellAlpha = new ConstantProperty(0.0);200 expect(listener).toHaveBeenCalledWith(property, 'cellAlpha', property.cellAlpha, oldValue);201 listener.calls.reset();202203 property.cellAlpha.setValue(1.0);204 expect(listener).toHaveBeenCalledWith(property, 'cellAlpha', property.cellAlpha, property.cellAlpha);205 listener.calls.reset();206207 property.cellAlpha = property.cellAlpha;208 expect(listener.calls.count()).toEqual(0);209 listener.calls.reset();210211 oldValue = property.lineCount;212 property.lineCount = new ConstantProperty(5.0);213 expect(listener).toHaveBeenCalledWith(property, 'lineCount', property.lineCount, oldValue);214 listener.calls.reset();215216 property.lineCount.setValue(10.0);217 expect(listener).toHaveBeenCalledWith(property, 'lineCount', property.lineCount, property.lineCount);218 listener.calls.reset();219220 property.lineCount = property.lineCount;221 expect(listener.calls.count()).toEqual(0);222 listener.calls.reset();223224 oldValue = property.lineThickness;225 property.lineThickness = new ConstantProperty(5.0);226 expect(listener).toHaveBeenCalledWith(property, 'lineThickness', property.lineThickness, oldValue);227 listener.calls.reset();228229 property.lineThickness.setValue(10.0);230 expect(listener).toHaveBeenCalledWith(property, 'lineThickness', property.lineThickness, property.lineThickness);231 listener.calls.reset();232233 oldValue = property.lineOffset;234 property.lineOffset = new ConstantProperty(5.0);235 expect(listener).toHaveBeenCalledWith(property, 'lineOffset', property.lineOffset, oldValue);236 listener.calls.reset();237238 property.lineOffset.setValue(10.0);239 expect(listener).toHaveBeenCalledWith(property, 'lineOffset', property.lineOffset, property.lineOffset);240 listener.calls.reset();241242 property.lineOffset = property.lineOffset;243 expect(listener.calls.count()).toEqual(0);244 });245246 it('isConstant is only true when all properties are constant or undefined', function() {247 var property = new GridMaterialProperty();248 expect(property.isConstant).toBe(true);249250 property.color = undefined;251 property.cellAlpha = undefined;252 property.lineCount = undefined;253 property.lineThickness = undefined;254 property.lineOffset = undefined;255 expect(property.isConstant).toBe(true);256257 property.color = new SampledProperty(Color);258 property.color.addSample(JulianDate.now(), Color.WHITE);259 expect(property.isConstant).toBe(false);260261 property.color = undefined;262 expect(property.isConstant).toBe(true);263 property.cellAlpha = new SampledProperty(Number);264 property.cellAlpha.addSample(JulianDate.now(), 0);265 expect(property.isConstant).toBe(false);266267 property.cellAlpha = undefined;268 expect(property.isConstant).toBe(true);269 property.lineCount = new SampledProperty(Number);270 property.lineCount.addSample(JulianDate.now(), 1);271 expect(property.isConstant).toBe(false);272273 property.lineCount = undefined;274 expect(property.isConstant).toBe(true);275 property.lineThickness = new SampledProperty(Number);276 property.lineThickness.addSample(JulianDate.now(), 1);277 expect(property.isConstant).toBe(false);278279 property.lineThickness = undefined;280 expect(property.isConstant).toBe(true);281 property.lineOffset = new SampledProperty(Number);282 property.lineOffset.addSample(JulianDate.now(), 1);283 expect(property.isConstant).toBe(false);284 });
...
PropertyBagSpec.js
Source:PropertyBagSpec.js
1defineSuite([2 'DataSources/PropertyBag',3 'Core/JulianDate',4 'DataSources/ConstantProperty',5 'DataSources/SampledProperty'6 ], function(7 PropertyBag,8 JulianDate,9 ConstantProperty,10 SampledProperty) {11 'use strict';1213 var time = JulianDate.now();1415 it('sets correct values when constructed with no arguments', function() {16 var property = new PropertyBag();17 expect(property.isConstant).toBe(true);18 expect(property.getValue(time)).toEqual({});19 });2021 it('sets correct values when constructed with arguments', function() {22 var property = new PropertyBag({23 a : new ConstantProperty(1),24 b : new ConstantProperty(2)25 });2627 expect(property.propertyNames).toContain('a');28 expect(property.a).toBeDefined();29 expect(property.a).toBeInstanceOf(ConstantProperty);30 expect(property.hasProperty('a')).toEqual(true);3132 expect(property.propertyNames).toContain('b');33 expect(property.b).toBeDefined();34 expect(property.b).toBeInstanceOf(ConstantProperty);35 expect(property.hasProperty('b')).toEqual(true);3637 expect(property.getValue(time)).toEqual({38 a : 1,39 b : 240 });41 });4243 it('works with result parameter', function() {44 var property = new PropertyBag({45 a : new ConstantProperty(1),46 b : new ConstantProperty(2)47 });4849 var expectedResult = {50 a : -151 };52 var result = property.getValue(time, expectedResult);53 expect(result).toEqual({54 a : 1,55 b : 256 });57 expect(result).toBe(expectedResult);58 });5960 it('leaves extra properties in result object in place', function() {61 var property = new PropertyBag({62 a : new ConstantProperty(1)63 });6465 var expectedResult = {66 q : -167 };68 var result = property.getValue(time, expectedResult);69 expect(result).toEqual({70 a : 1,71 q : -172 });73 expect(result).toBe(expectedResult);74 });7576 it('converts raw values to properties when constructed', function() {77 var property = new PropertyBag({78 a : 1,79 b : 280 });8182 expect(property.propertyNames).toContain('a');83 expect(property.a).toBeInstanceOf(ConstantProperty);8485 expect(property.propertyNames).toContain('b');86 expect(property.b).toBeInstanceOf(ConstantProperty);8788 expect(property.getValue(time)).toEqual({89 a : 1,90 b : 291 });92 });9394 function FakeProperty(v) {95 this.v = v;96 }97 FakeProperty.prototype.getValue = function() {98 return this.v;99 };100 function createFakeProperty(v) {101 return new FakeProperty(v);102 }103104 it('uses the provided function to convert raw values to properties when constructed', function() {105 var property = new PropertyBag({106 a : 1,107 b : 2108 }, createFakeProperty);109110 expect(property.propertyNames).toContain('a');111 expect(property.a).toBeDefined();112 expect(property.a).toBeInstanceOf(FakeProperty);113114 expect(property.propertyNames).toContain('b');115 expect(property.b).toBeDefined();116 expect(property.b).toBeInstanceOf(FakeProperty);117118 expect(property.getValue(time)).toEqual({119 a : 1,120 b : 2121 });122 });123124 it('returns correct results from hasProperty', function() {125 var property = new PropertyBag();126 expect(property.hasProperty('a')).toEqual(false);127 property.addProperty('a');128 expect(property.hasProperty('a')).toEqual(true);129 });130131 it('allows adding a property without a value', function() {132 var property = new PropertyBag();133 property.addProperty('a');134135 expect(property.propertyNames).toEqual(['a']);136 expect(property.a).toBeUndefined();137 expect(property.hasProperty('a')).toEqual(true);138139 expect(property.getValue(time)).toEqual({140 a : undefined141 });142 });143144 it('allows adding a property with a value', function() {145 var property = new PropertyBag();146 property.addProperty('a', new ConstantProperty(1));147148 expect(property.propertyNames).toEqual(['a']);149 expect(property.a).toBeInstanceOf(ConstantProperty);150151 expect(property.getValue(time)).toEqual({152 a : 1153 });154 });155156 it('uses the provided function to convert raw values to properties when added with a value', function() {157 var property = new PropertyBag();158 property.addProperty('a', 1, createFakeProperty);159160 expect(property.propertyNames).toEqual(['a']);161 expect(property.a).toBeInstanceOf(FakeProperty);162163 expect(property.getValue(time)).toEqual({164 a : 1165 });166 });167168 it('uses the provided function to convert raw values to properties when added without a value', function() {169 var property = new PropertyBag();170 property.addProperty('a', undefined, createFakeProperty);171172 expect(property.propertyNames).toEqual(['a']);173 expect(property.a).toBeUndefined();174175 property.a = 1;176 expect(property.a).toBeInstanceOf(FakeProperty);177178 expect(property.getValue(time)).toEqual({179 a : 1180 });181 });182183 it('allows removing a property that was previously added', function() {184 var property = new PropertyBag();185186 property.addProperty('a', new ConstantProperty(1));187 expect(property.hasProperty('a')).toEqual(true);188189 property.removeProperty('a');190191 expect(property.propertyNames).toEqual([]);192 expect(property.a).toBeUndefined();193 expect(property.hasProperty('a')).toEqual(false);194195 expect(property.getValue(time)).toEqual({});196 });197198 it('throws when removing a property that was not added', function() {199 var property = new PropertyBag();200 expect(function() {201 property.removeProperty('a');202 }).toThrowDeveloperError();203 });204205 it('raises definitionChanged event when addProperty is called', function() {206 var property = new PropertyBag();207 var listener = jasmine.createSpy('listener');208 property.definitionChanged.addEventListener(listener);209 property.addProperty('a');210 expect(listener).toHaveBeenCalledWith(property);211 });212213 it('raises definitionChanged event when properties are changed', function() {214 var property = new PropertyBag();215 property.addProperty('a');216217 var listener = jasmine.createSpy('listener');218 property.definitionChanged.addEventListener(listener);219220 var a = new ConstantProperty(1);221 property.a = a;222223 expect(listener).toHaveBeenCalledWith(property, 'a', a, undefined);224 });225226 it('requires propertyName in addProperty', function() {227 var property = new PropertyBag();228 expect(function() {229 property.addProperty();230 }).toThrowDeveloperError();231 });232233 it('requires propertyName in removeProperty', function() {234 var property = new PropertyBag();235 expect(function() {236 property.removeProperty();237 }).toThrowDeveloperError();238 });239240 it('has working equals function', function() {241 var left = new PropertyBag({242 a : new ConstantProperty(1)243 });244 var right = new PropertyBag({245 a : new ConstantProperty(1)246 });247248 expect(left.equals(right)).toEqual(true);249250 right.addProperty('c');251 expect(left.equals(right)).toEqual(false);252253 right = new PropertyBag({254 a : new ConstantProperty(2)255 });256 expect(left.equals(right)).toEqual(false);257258 right = new PropertyBag({259 b : new ConstantProperty(1)260 });261 expect(left.equals(right)).toEqual(false);262263 right = new PropertyBag();264 expect(left.equals(right)).toEqual(false);265266 left = new PropertyBag();267 right = new PropertyBag();268 expect(left.equals(right)).toEqual(true);269 });270271 it('returns true from isConstant only if all members are constant', function() {272 var property = new PropertyBag();273274 property.addProperty('a', new ConstantProperty(2));275 expect(property.isConstant).toBe(true);276277 var sampledProperty = new SampledProperty(Number);278 sampledProperty.addSample(time, 1);279 property.addProperty('b', sampledProperty);280281 expect(property.isConstant).toBe(false);282 });
...
array-defineOwnProperty.js
Source:array-defineOwnProperty.js
1description("This test checks the behavior of [[DefineOwnProperty]] applied to Array objects (see ES5.1 15.4.5.1).");2// Test that properties other than length, array indices are handled as normal.3shouldBeTrue("Object.defineProperty([], 'x', { get:function(){return true;} }).x");4// The length property can be set, and can be made read-only.5shouldBe("Object.defineProperty([], 'length', { value: 1 }).length", '1');6shouldBe("var a = Object.defineProperty([], 'length', { writable: false }); a[1] = 1; a.length", '0');7shouldBe("var a = Object.defineProperty([], 'length', { writable: false }); a.length = 1; a.length", '0');8// If writable is not specified, it should not change.9shouldBe("var a = Object.defineProperty([], 'length', {}); a.length = 1; a.length", '1');10// The length property can be replaced with an accessor, or made either enumerable or configurable.11shouldThrow("Object.defineProperty([], 'length', { get:function(){return true;} })");12shouldThrow("Object.defineProperty([], 'length', { enumerable: true })");13shouldThrow("Object.defineProperty([], 'length', { configurable: true })");14shouldThrow("Object.defineProperty(Object.defineProperty([], 'length', { writable: false }), 'length', { writable: true })");15// The value of an indexed property can be set.16shouldBe("var a = Object.defineProperty([], '0', { value: 42 }); a[0]", '42');17// An indexed property can be made non-writable/enumerable/configurable.18shouldBe("var a = Object.defineProperty([42], '0', { writable: false }); a[0] = 1; a[0]", '42');19shouldBe("var a = Object.defineProperty([42], '0', { enumerable: false }); a[0] + Object.keys(a).length", '42');20shouldBe("var a = Object.defineProperty([42], '0', { configurable: false }); a.length = 0; a[0]", '42');21// An indexed property can be defined as an accessor.22shouldBe("var foo = 0; Object.defineProperty([], '0', { set:function(x){foo = x;} })[0] = 42; foo", '42');23shouldBeTrue("Object.defineProperty([], '0', { get:function(){return true;} })[0]")24// A configurable, non-writable property can be made writable, but a non-configurable one cannot.25shouldBeTrue("Object.defineProperty(Object.defineProperty([true], '0', { configurable:true, writable: false }), '0', { writable: true })[0]");26shouldThrow("Object.defineProperty(Object.defineProperty([true], '0', { configurable:false, writable: false }), '0', { writable: true })[0]");27// Reassigning the value is okay if the property is writable.28shouldBe("Object.defineProperty(Object.defineProperty([], '0', { value: 1, writable:true }), '0', { value: 2 })[0]", '2');29// Reassigning the value is okay if the value doesn't change.30shouldBe("Object.defineProperty(Object.defineProperty([], '0', { value: 1 }), '0', { value: 1 })[0]", '1');31shouldBe("Object.defineProperty(Object.defineProperty([], '0', { value: Number.NaN }), '0', { value: -Number.NaN })[0]", 'Number.NaN');32shouldBe("Object.defineProperty(Object.defineProperty([], '0', { value: 'okay'.substring(0,2) }), '0', { value: 'not ok'.substring(4,6) })[0]", '"ok"');33shouldBe("Object.defineProperty(Object.defineProperty([], '0', { value: true }), '0', { value: true })[0]", 'true');34shouldBe("Object.defineProperty(Object.defineProperty([], '0', { value: false }), '0', { value: false })[0]", 'false');35shouldBe("Object.defineProperty(Object.defineProperty([], '0', { value: null }), '0', { value: null })[0]", 'null');36shouldBe("Object.defineProperty(Object.defineProperty([], '0', { value: undefined }), '0', { value: undefined })[0]", 'undefined');37shouldBe("Object.defineProperty(Object.defineProperty([], '0', { value: Math }), '0', { value: Math })[0]", 'Math');38// Reassigning the value is not okay if the value changes.39shouldThrow("Object.defineProperty(Object.defineProperty([], '0', { value: 1 }), '0', { value: 2 })[0]");40shouldThrow("Object.defineProperty(Object.defineProperty([], '0', { value: 'okay' }), '0', { value: 'not ok' })[0]");41shouldThrow("Object.defineProperty(Object.defineProperty([], '0', { value: true }), '0', { value: false })[0]");42shouldThrow("Object.defineProperty(Object.defineProperty([], '0', { value: false }), '0', { value: true })[0]");43shouldThrow("Object.defineProperty(Object.defineProperty([], '0', { value: Math }), '0', { value: Object })[0]");44// Reassigning the value is not okay if the type changes.45shouldThrow("Object.defineProperty(Object.defineProperty([], '0', { value: null }), '0', { value: undefined })[0]");46shouldThrow("Object.defineProperty(Object.defineProperty([], '0', { value: undefined }), '0', { value: null })[0]");...
__init__.py
Source:__init__.py
1"""All pykechain surrogate models based on KE-chain models."""2from typing import Union3from .base import Base, BaseInScope4from .notification import Notification5from .scope import Scope6from .scope2 import Scope27from .activity import Activity8from .activity2 import Activity29from .association import Association10from .part import Part11from .part2 import Part212from .property import Property13from .property_attachment import AttachmentProperty14from .property_selectlist import SelectListProperty, MultiSelectListProperty15from .property_multi_reference import MultiReferenceProperty16from .property_datetime import DatetimeProperty17from .property2 import Property218from .property2_attachment import AttachmentProperty219from .property2_selectlist import SelectListProperty220from .property2_multi_reference import MultiReferenceProperty221from .property2_datetime import DatetimeProperty222from .property_reference import (23 ActivityReferencesProperty,24 ContextReferencesProperty,25 ScopeReferencesProperty,26 StatusReferencesProperty,27 UserReferencesProperty,28 FormReferencesProperty,29)30from .partset import PartSet31from .service import Service, ServiceExecution32from .team import Team33from .user import User34from .value_filter import PropertyValueFilter35from ..enums import PropertyType36AnyProperty = Union[37 "Property",38 "MultiReferenceProperty",39 "AttachmentProperty",40 "SelectListProperty",41 "DatetimeProperty",42 "Property2",43 "MultiReferenceProperty2",44 "AttachmentProperty2",45 "SelectListProperty2",46 "DatetimeProperty2",47 "ActivityReferencesProperty",48 "ScopeReferencesProperty",49 "UserReferencesProperty",50 "FormReferencesProperty",51 "ContextReferencesProperty",52 "StatusReferencesProperty",53]54# This map is used to identify the correct class for the (KE-chain provided) property type.55property_type_to_class_map = {56 PropertyType.ATTACHMENT_VALUE: AttachmentProperty,57 PropertyType.SINGLE_SELECT_VALUE: SelectListProperty,58 PropertyType.MULTI_SELECT_VALUE: MultiSelectListProperty,59 PropertyType.REFERENCES_VALUE: MultiReferenceProperty,60 PropertyType.DATETIME_VALUE: DatetimeProperty,61 PropertyType.ACTIVITY_REFERENCES_VALUE: ActivityReferencesProperty,62 PropertyType.SCOPE_REFERENCES_VALUE: ScopeReferencesProperty,63 PropertyType.USER_REFERENCES_VALUE: UserReferencesProperty,64 PropertyType.FORM_REFERENCES_VALUE: FormReferencesProperty,65 PropertyType.CONTEXT_REFERENCES_VALUE: ContextReferencesProperty,66 PropertyType.STATUS_REFERENCES_VALUE: StatusReferencesProperty,67}68__all__ = (69 "Base",70 "BaseInScope",71 "Scope",72 "Scope2",73 "Activity",74 "Association",75 "Activity2",76 "Part",77 "Part2",78 "PartSet",79 "Service",80 "ServiceExecution",81 "User",82 "Team",83 "Property",84 "MultiReferenceProperty",85 "AttachmentProperty",86 "SelectListProperty",87 "DatetimeProperty",88 "Property2",89 "MultiReferenceProperty2",90 "AttachmentProperty2",91 "SelectListProperty2",92 "DatetimeProperty2",93 "ActivityReferencesProperty",94 "ScopeReferencesProperty",95 "UserReferencesProperty",96 "FormReferencesProperty",97 "StatusReferencesProperty",98 "AnyProperty",99 "PropertyValueFilter",100 "Notification",101 "property_type_to_class_map",...
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.12345678901234567890123456789012');3wpt.getLocations(function(err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data);8 }9});10 if (err) {11 console.log(err);12 } else {13 console.log(data);14 }15});16wpt.getTestResults('140303_4F_2c2f6d4c6a4c9e9d1e3c3a3e1a1c6d06', function(err, data) {17 if (err) {18 console.log(err);19 } else {20 console.log(data);21 }22});23wpt.getTestStatus('140303_4F_2c2f6d4c6a4c9e9d1e3c3a3e1a1c6d06', function(err, data) {24 if (err) {25 console.log(err);26 } else {27 console.log(data);28 }29});30wpt.getTestStatus('140303_4F_2c2f6d4c6a4c9e9d1e3c3a3e1a1c6d06', function(err, data) {31 if (err) {32 console.log(err);33 } else {34 console.log(data);35 }36});37wpt.getTestStatus('140303_4F_2c2f6d4c6a4c9e9d1e3c3a3e1a1c6d06', function(err, data) {38 if (err) {39 console.log(err);40 } else {41 console.log(data);42 }43});44wpt.getTestStatus('140303_4F_2c2f6d4c6a4c9e9d1e3c3a3e1a1c6d06', function(err, data) {45 if (err) {46 console.log(err);47 } else {48 console.log(data);49 }50});51wpt.getTestStatus('140303_4F_2c2f6d4
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.12345678912345678912345678912345');3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9var wpt = require('webpagetest');10var wpt = new WebPageTest('www.webpagetest.org', 'A.12345678912345678912345678912345');11 if (err) {12 console.log(err);13 } else {14 console.log(data);15 }16});17var wpt = require('webpagetest');18var wpt = new WebPageTest('www.webpagetest.org', 'A.12345678912345678912345678912345');19 if (err) {20 console.log(err);21 } else {22 console.log(data);23 }24});25var wpt = require('webpagetest');26var wpt = new WebPageTest('www.webpagetest.org', 'A.12345678912345678912345678912345');27 if (err) {28 console.log(err);29 } else {30 console.log(data);31 }32});33var wpt = require('webpagetest');34var wpt = new WebPageTest('www.webpagetest.org', 'A.12345678912345678912345678912345');35 if (err) {36 console.log(err);37 } else {38 console.log(data);39 }40});41var wpt = require('webpagetest');
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.getLocations(function(err, data) {4 console.log(data)5});6var wpt = require('webpagetest');7var wpt = new WebPageTest('www.webpagetest.org');8wpt.getLocations(function(err, data) {9 console.log(data)10});11var wpt = require('webpagetest');12var wpt = new WebPageTest('www.webpagetest.org');13wpt.getLocations(function(err, data) {14 console.log(data)15});16var wpt = require('webpagetest');17var wpt = new WebPageTest('www.webpagetest.org');18wpt.getLocations(function(err, data) {19 console.log(data)20});21var wpt = require('webpagetest');22var wpt = new WebPageTest('www.webpagetest.org');23wpt.getLocations(function(err, data) {24 console.log(data)25});26var wpt = require('webpagetest');27var wpt = new WebPageTest('www.webpagetest.org');28wpt.getLocations(function(err, data) {29 console.log(data)30});31var wpt = require('webpagetest');32var wpt = new WebPageTest('www.webpagetest.org');33wpt.getLocations(function(err, data) {34 console.log(data)35});36var wpt = require('webpagetest');37var wpt = new WebPageTest('www.webpagetest.org');38wpt.getLocations(function(err, data) {39 console.log(data)40});41var wpt = require('webpagetest');42var wpt = new WebPageTest('www.webpagetest.org');43wpt.getLocations(function(err, data) {44 console.log(data)45});46var wpt = require('webpagetest');47var wpt = new WebPageTest('www.webpagetest.org');48wpt.getLocations(function(err, data) {49 console.log(data
Using AI Code Generation
1var wptoolkit = require('wptoolkit');2wp.property('blogname', function(err, data) {3 console.log(data);4});5var wptoolkit = require('wptoolkit');6wp.property('blogname', function(err, data) {7 console.log(data);8});9var wptoolkit = require('wptoolkit');10wp.property('blogname', function(err, data) {11 console.log(data);12});13var wptoolkit = require('wptoolkit');14wp.property('blogname', function(err, data) {15 console.log(data);16});17var wptoolkit = require('wptoolkit');18wp.property('blogname', function(err, data) {19 console.log(data);20});21var wptoolkit = require('wptoolkit');22wp.property('blogname', function(err, data) {23 console.log(data);24});25var wptoolkit = require('wptoolkit');26wp.property('blogname', function(err, data) {27 console.log(data);28});
Using AI Code Generation
1var wptools = require('wptools');2var wiki = wptools.page('Barack Obama');3wiki.get(function(err, resp) {4 if (err) {5 console.log(err);6 } else {7 console.log(resp);8 }9});10The result will be a huge JSON object. We can use the property() method to get the data of a specific property. For example:11var wptools = require('wptools');12var wiki = wptools.page('Barack Obama');13wiki.get(function(err, resp) {14 if (err) {15 console.log(err);16 } else {17 console.log(resp);18 }19});20The above code will print the birth date of Barack Obama. We can use the infobox() method to get the infobox data of a specific property. For example:21var wptools = require('wptools');22var wiki = wptools.page('Barack Obama');23wiki.get(function(err, resp) {24 if (err) {25 console.log(err);26 } else {27 console.log(resp);28 }29});30The above code will print the infobox data of Barack Obama. We can use the categories() method to get the categories of a page. For example:31var wptools = require('wptools');32var wiki = wptools.page('Barack Obama');33wiki.get(function(err, resp) {34 if (err) {35 console.log(err);36 } else {37 console.log(resp);38 }39});40The above code will print the categories of Barack Obama. We can use the templates() method to get the templates of a page. For example:41var wptools = require('wptools');42var wiki = wptools.page('Barack Obama');43wiki.get(function(err, resp) {44 if (err) {45 console.log(err);46 } else {47 console.log(resp);48 }49});
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.5a7b5c6d7e8f9g0h1i2j3k4l5m6n7o8p9q0r1s2t3u4v5w6x7y8z9a0b1c2d3e4f5');3 if (err) return console.error(err);4 console.log('Test status:', data.statusText);5 wpt.getTestResults(data.data.testId, function(err, data) {6 if (err) return console.error(err);7 console.log('Test completed:', data.data.runs[1].firstView.SpeedIndex);8 });9});
Using AI Code Generation
1var wptools = require('wptools');2var page = wptools.page('Albert Einstein');3page.get(function(err, info) {4 console.log(info);5});6{ title: 'Albert Einstein',7 { type: 'person',8 death_date: 'April 18, 1955 (aged 76)',9 resting_place_coordinates: '40°22′44″N 74°39′38″W / 40.379°N 74.660°W / 40.379; -74.660',10 thesis: 'The Foundation of the General Theory of Relativity (1905)',11 notable_works: 'The Special Theory of Relativity (1905), The General Theory of Relativity (1916), The Foundation of
Using AI Code Generation
1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) return console.error(err);4 console.log('Test status:', data.statusText);5 console.log('Test ID:', data.data.testId);6 console.log('Test URL:', data.data.summary);7});8var wpt = require('webpagetest');9var wpt = new WebPageTest('www.webpagetest.org');10 if (err) return console.error(err);11 console.log('Test status:', data.statusText);12 console.log('Test ID:', data.data.testId);13 console.log('Test URL:', data.data.summary);14});15var wpt = require('webpagetest');16var wpt = new WebPageTest('www.webpagetest.org');17 if (err) return console.error(err);18 console.log('Test status:', data.statusText);19 console.log('Test ID:', data.data.testId);20 console.log('Test URL:', data.data.summary);21});22var wpt = require('webpagetest');23var wpt = new WebPageTest('www.webpagetest.org');24 if (err) return console.error(err);25 console.log('Test status:', data.statusText);26 console.log('Test ID:', data.data.testId);
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!!