Last active
March 4, 2017 00:09
-
-
Save nowucca/b440c04dbf13fe22e49f218f4c65453a to your computer and use it in GitHub Desktop.
Netflix Merch Server Test Framework for Postman
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isIntegerList(arr) { | |
for(i=0;i<arr.length;i++) { | |
if (! Number.isInteger(arr[i])) { | |
return false | |
} | |
} | |
return true | |
} | |
function isNotEmpty(str) { | |
return !isEmpty(str) | |
} | |
function isEmpty(str) { | |
return (!str || 0 === str.length); | |
} | |
function isBoolean(v) { | |
return typeof v === 'boolean' || | |
(typeof v === 'object' && typeof v.valueOf() === 'boolean'); | |
} | |
// Validate that the shape of a serialed MovieGroup is reasonable | |
function isMovieGroup(group) { | |
var result = | |
isIntegerList(group.movieIdList) && | |
!isEmpty(group.type) && !isEmpty(group.name) && !isEmpty(group.movieGroupId) && Number.isInteger(group.score); | |
tests["Group "+group.name+" appears valid"] = result; | |
return result; | |
} | |
function isFacet(f) { | |
var result = | |
isNotEmpty(f.displayName) && | |
isNotEmpty(f.categoryName) && | |
Number.isInteger(f.count) && | |
isBoolean(f.selected); | |
tests["Facet '"+f.displayName+"' appears valid"] = result; | |
return result; | |
} | |
function isFacetGroup(group) { | |
group.facets.forEach(isFacet); | |
var result = | |
isBoolean(group.frozen) && | |
isBoolean(group.dropDown) && | |
isBoolean(group.catGroupInAltGenre) && | |
isNotEmpty(group.name) && | |
(isNotEmpty(group.displayName) || | |
(group.name === "media" && group.displayName == null)); | |
tests["Facet group'"+group.displayName+"' appears valid"] = result; | |
return result; | |
} | |
function isMovieGalleryPage(p, displayName) { | |
var result = | |
isIntegerList(p.movieIds) && | |
(p.genreIds == null || isIntegerList(p.genreIds)) && | |
Number.isInteger(p.totalPages); | |
tests["Movie gallery page '"+displayName+"' appears valid"] = result; | |
return result; | |
} | |
function isRatingObject(o) { | |
var result = | |
Number.isInteger(o.movieId) && | |
parseFloat(o.rating) >= 0 && | |
parseFloat(o.prediction) >= 0 && | |
parseFloat(o.averageRating) >= 0 && | |
parseInt(o.numRatings) >= 0; | |
tests["Rating appears valid"] = result; | |
} | |
function readTestVariable(name) { | |
return data[name] != null ? data[name] : | |
environment[name] != null ? environment[name] : | |
postman.getGlobalVariable(name) != null ? postman.getGlobalVariable(name) : null; | |
} | |
function isTestNonMember(customerId) { | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment