How to use exists method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

win_secedit_facts.py

Source:win_secedit_facts.py Github

copy

Full Screen

1#!/usr/bin/python2# -*- coding: utf-8 -*-3# Copyright 2016, Red Hat Inc 4#5# This file is part of Ansible6#7# Ansible is free software: you can redistribute it and/or modify8# it under the terms of the GNU General Public License as published by9# the Free Software Foundation, either version 3 of the License, or10# (at your option) any later version.11#12# Ansible is distributed in the hope that it will be useful,13# but WITHOUT ANY WARRANTY; without even the implied warranty of14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the15# GNU General Public License for more details.16#17# You should have received a copy of the GNU General Public License18# along with Ansible. If not, see <http://www.gnu.org/licenses/>.19# this is a windows documentation stub. actual code lives in the .ps120# file of the same name21DOCUMENTATION = '''22---23module: win_secedit_facts24version_added: '2.3'25short_description: Gets facts about local security policies via secedit26description:27 - Gathers key values for local security policies from secedit. Note that all the return examples are not guaranteed to be present. Secedit removes all keys that have blank values, so systems that do not have anything set for a given key will not be returned. Also note that the categories are returned with the spaces replaced with underscores since they are keys in the dictionary.28options: {}29author:30 - James Mighion (@jmighion) 31'''32EXAMPLES = '''33# Gather all secedit facts34- name: Gather secedit facts 35win_secedit_facts:36'''37RETURN = '''38# Event Audit39AuditAccountLogon: 40 description:41 returned: if exists42 type: string43 sample: 044AuditAccountManage: 45 description:46 returned: if exists47 type: string48 sample: 049AuditDSAccess: 50 description:51 returned: if exists52 type: string53 sample: 054AuditLogonEvents: 55 description:56 returned: if exists57 type: string58 sample: 059AuditObjectAccess: 60 description:61 returned: if exists62 type: string63 sample: 064AuditPolicyChange: 65 description:66 returned: if exists67 type: string68 sample: 069AuditPrivilegeUse: 70 description:71 returned: if exists72 type: string73 sample: 074AuditProcessTracking: 75 description:76 returned: if exists77 type: string78 sample: 079AuditSystemEvents: 80 description:81 returned: if exists82 type: string83 sample: 084# Privilege Rights85SeAssignPrimaryTokenPrivilege: 86 description:87 returned: if exists88 type: string89 sample: *S-1-5-19,*S-1-5-2090SeAuditPrivilege: 91 description:92 returned: if exists93 type: string94 sample: *S-1-5-19,*S-1-5-2095SeBackupPrivilege: 96 description:97 returned: if exists98 type: string99 sample: *S-1-5-32-544,*S-1-5-32-551100SeBatchLogonRight: 101 description:102 returned: if exists103 type: string104 sample: *S-1-5-32-544,*S-1-5-32-551,*S-1-5-32-559,*S-1-5-32-568105SeChangeNotifyPrivilege: 106 description:107 returned: if exists108 type: string109 sample: *S-1-1-0,*S-1-5-19,*S-1-5-20,*S-1-5-32-544,*S-1-5-32-545,*S-1-5-32-551110SeCreateGlobalPrivilege: 111 description:112 returned: if exists113 type: string114 sample: *S-1-5-19,*S-1-5-20,*S-1-5-32-544,*S-1-5-6115SeCreatePagefilePrivilege: 116 description:117 returned: if exists118 type: string119 sample: *S-1-5-32-544120SeCreateSymbolicLinkPrivilege: 121 description:122 returned: if exists123 type: string124 sample: *S-1-5-32-544125SeDebugPrivilege: 126 description:127 returned: if exists128 type: string129 sample: *S-1-5-32-544130SeImpersonatePrivilege: 131 description:132 returned: if exists133 type: string134 sample: *S-1-5-19,*S-1-5-20,*S-1-5-32-544,*S-1-5-32-568,*S-1-5-6135SeIncreaseBasePriorityPrivilege: 136 description:137 returned: if exists138 type: string139 sample: *S-1-5-32-544140SeIncreaseQuotaPrivilege: 141 description:142 returned: if exists143 type: string144 sample: *S-1-5-19,*S-1-5-20,*S-1-5-32-544145SeIncreaseWorkingSetPrivilege: 146 description:147 returned: if exists148 type: string149 sample: *S-1-5-32-545150SeInteractiveLogonRight: 151 description:152 returned: if exists153 type: string154 sample: *S-1-5-32-544,*S-1-5-32-545,*S-1-5-32-551155SeLoadDriverPrivilege: 156 description:157 returned: if exists158 type: string159 sample: *S-1-5-32-544160SeManageVolumePrivilege: 161 description:162 returned: if exists163 type: string164 sample: *S-1-5-32-544165SeNetworkLogonRight: 166 description:167 returned: if exists168 type: string169 sample: *S-1-1-0,*S-1-5-32-544,*S-1-5-32-545,*S-1-5-32-551170SeProfileSingleProcessPrivilege: 171 description:172 returned: if exists173 type: string174 sample: *S-1-5-32-544175SeRemoteInteractiveLogonRight: 176 description:177 returned: if exists178 type: string179 sample: *S-1-5-32-544,*S-1-5-32-555180SeRemoteShutdownPrivilege: 181 description:182 returned: if exists183 type: string184 sample: *S-1-5-32-544185SeRestorePrivilege: 186 description:187 returned: if exists188 type: string189 sample: *S-1-5-32-544,*S-1-5-32-551190SeSecurityPrivilege: 191 description:192 returned: if exists193 type: string194 sample: *S-1-5-32-544195SeServiceLogonRight: 196 description:197 returned: if exists198 type: string199 sample: *S-1-5-80-0200SeShutdownPrivilege: 201 description:202 returned: if exists203 type: string204 sample: *S-1-5-32-544,*S-1-5-32-551205SeSystemEnvironmentPrivilege: 206 description:207 returned: if exists208 type: string209 sample: *S-1-5-32-544210SeSystemProfilePrivilege: 211 description:212 returned: if exists213 type: string214 sample: *S-1-5-32-544,*S-1-5-80-3139157870-2983391045-3678747466-658725712-1809340420215SeSystemtimePrivilege: 216 description:217 returned: if exists218 type: string219 sample: *S-1-5-19,*S-1-5-32-544220SeTakeOwnershipPrivilege: 221 description:222 returned: if exists223 type: string224 sample: *S-1-5-32-544225SeTimeZonePrivilege: 226 description:227 returned: if exists228 type: string229 sample: *S-1-5-19,*S-1-5-32-544230SeUndockPrivilege: 231 description:232 returned: if exists233 type: string234 sample: *S-1-5-32-544235# Registry Values236MACHINE\\\\Software\\\\Microsoft\\\\Windows NT\\\\CurrentVersion\\\\Setup\\\\RecoveryConsole\\\\SecurityLevel: 237 description:238 returned: if exists239 type: string240 sample: 4,0 241MACHINE\\\\Software\\\\Microsoft\\\\Windows NT\\\\CurrentVersion\\\\Setup\\\\RecoveryConsole\\\\SetCommand: 242 description:243 returned: if exists244 type: string245 sample: 4,0 246MACHINE\\\\Software\\\\Microsoft\\\\Windows NT\\\\CurrentVersion\\\\Winlogon\\\\CachedLogonsCount: 247 description:248 returned: if exists249 type: string250 sample: 1,\\"10\\" 251MACHINE\\\\Software\\\\Microsoft\\\\Windows NT\\\\CurrentVersion\\\\Winlogon\\\\ForceUnlockLogon: 252 description:253 returned: if exists254 type: string255 sample: 4,0 256MACHINE\\\\Software\\\\Microsoft\\\\Windows NT\\\\CurrentVersion\\\\Winlogon\\\\PasswordExpiryWarning: 257 description:258 returned: if exists259 type: string260 sample: 4,5 261MACHINE\\\\Software\\\\Microsoft\\\\Windows NT\\\\CurrentVersion\\\\Winlogon\\\\ScRemoveOption: 262 description:263 returned: if exists264 type: string265 sample: 1,\\"0\\" 266MACHINE\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Policies\\\\System\\\\ConsentPromptBehaviorAdmin: 267 description:268 returned: if exists269 type: string270 sample: 4,5 271MACHINE\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Policies\\\\System\\\\ConsentPromptBehaviorUser: 272 description:273 returned: if exists274 type: string275 sample: 4,3 276MACHINE\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Policies\\\\System\\\\DisableCAD: 277 description:278 returned: if exists279 type: string280 sample: 4,0 281MACHINE\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Policies\\\\System\\\\DontDisplayLastUserName: 282 description:283 returned: if exists284 type: string285 sample: 4,0 286MACHINE\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Policies\\\\System\\\\EnableInstallerDetection: 287 description:288 returned: if exists289 type: string290 sample: 4,1 291MACHINE\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Policies\\\\System\\\\EnableLUA: 292 description:293 returned: if exists294 type: string295 sample: 4,1 296MACHINE\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Policies\\\\System\\\\EnableSecureUIAPaths: 297 description:298 returned: if exists299 type: string300 sample: 4,1 301MACHINE\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Policies\\\\System\\\\EnableUIADesktopToggle: 302 description:303 returned: if exists304 type: string305 sample: 4,0 306MACHINE\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Policies\\\\System\\\\EnableVirtualization: 307 description:308 returned: if exists309 type: string310 sample: 4,1 311MACHINE\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Policies\\\\System\\\\FilterAdministratorToken: 312 description:313 returned: if exists314 type: string315 sample: 4,0 316MACHINE\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Policies\\\\System\\\\LegalNoticeCaption: 317 description:318 returned: if exists319 type: string320 sample: 1,\\"\\" 321MACHINE\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Policies\\\\System\\\\LegalNoticeText: 322 description:323 returned: if exists324 type: string325 sample: 7, 326MACHINE\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Policies\\\\System\\\\PromptOnSecureDesktop: 327 description:328 returned: if exists329 type: string330 sample: 4,1 331MACHINE\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Policies\\\\System\\\\ScForceOption: 332 description:333 returned: if exists334 type: string335 sample: 4,0 336MACHINE\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Policies\\\\System\\\\ShutdownWithoutLogon: 337 description:338 returned: if exists339 type: string340 sample: 4,0 341MACHINE\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Policies\\\\System\\\\UndockWithoutLogon: 342 description:343 returned: if exists344 type: string345 sample: 4,1 346MACHINE\\\\Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Policies\\\\System\\\\ValidateAdminCodeSignatures: 347 description:348 returned: if exists349 type: string350 sample: 4,0 351MACHINE\\\\Software\\\\Policies\\\\Microsoft\\\\Windows\\\\Safer\\\\CodeIdentifiers\\\\AuthenticodeEnabled: 352 description:353 returned: if exists354 type: string355 sample: 4,0 356MACHINE\\\\System\\\\CurrentControlSet\\\\Control\\\\Lsa\\\\AuditBaseObjects: 357 description:358 returned: if exists359 type: string360 sample: 4,0 361MACHINE\\\\System\\\\CurrentControlSet\\\\Control\\\\Lsa\\\\CrashOnAuditFail: 362 description:363 returned: if exists364 type: string365 sample: 4,0 366MACHINE\\\\System\\\\CurrentControlSet\\\\Control\\\\Lsa\\\\DisableDomainCreds: 367 description:368 returned: if exists369 type: string370 sample: 4,0 371MACHINE\\\\System\\\\CurrentControlSet\\\\Control\\\\Lsa\\\\EveryoneIncludesAnonymous: 372 description:373 returned: if exists374 type: string375 sample: 4,0 376MACHINE\\\\System\\\\CurrentControlSet\\\\Control\\\\Lsa\\\\FIPSAlgorithmPolicy\\\\Enabled: 377 description:378 returned: if exists379 type: string380 sample: 4,0 381MACHINE\\\\System\\\\CurrentControlSet\\\\Control\\\\Lsa\\\\ForceGuest: 382 description:383 returned: if exists384 type: string385 sample: 4,0 386MACHINE\\\\System\\\\CurrentControlSet\\\\Control\\\\Lsa\\\\FullPrivilegeAuditing: 387 description:388 returned: if exists389 type: string390 sample: 3,0 391MACHINE\\\\System\\\\CurrentControlSet\\\\Control\\\\Lsa\\\\LimitBlankPasswordUse: 392 description:393 returned: if exists394 type: string395 sample: 4,1 396MACHINE\\\\System\\\\CurrentControlSet\\\\Control\\\\Lsa\\\\MSV1_0\\\\NTLMMinClientSec: 397 description:398 returned: if exists399 type: string400 sample: 4,536870912 401MACHINE\\\\System\\\\CurrentControlSet\\\\Control\\\\Lsa\\\\MSV1_0\\\\NTLMMinServerSec: 402 description:403 returned: if exists404 type: string405 sample: 4,536870912 406MACHINE\\\\System\\\\CurrentControlSet\\\\Control\\\\Lsa\\\\NoLMHash: 407 description:408 returned: if exists409 type: string410 sample: 4,1 411MACHINE\\\\System\\\\CurrentControlSet\\\\Control\\\\Lsa\\\\RestrictAnonymous: 412 description:413 returned: if exists414 type: string415 sample: 4,0 416MACHINE\\\\System\\\\CurrentControlSet\\\\Control\\\\Lsa\\\\RestrictAnonymousSAM: 417 description:418 returned: if exists419 type: string420 sample: 4,1 421MACHINE\\\\System\\\\CurrentControlSet\\\\Control\\\\Print\\\\Providers\\\\LanMan Print Services\\\\Servers\\\\AddPrinterDrivers: 422 description:423 returned: if exists424 type: string425 sample: 4,1 426MACHINE\\\\System\\\\CurrentControlSet\\\\Control\\\\SecurePipeServers\\\\Winreg\\\\AllowedExactPaths\\\\Machine: 427 description:428 returned: if exists429 type: string430 sample: 7,System\\\\CurrentControlSet\\\\Control\\\\ProductOptions,System\\\\CurrentControlSet\\\\Control\\\\Server Applications,Software\\\\Microsoft\\\\Windows NT\\\\CurrentVersion 431MACHINE\\\\System\\\\CurrentControlSet\\\\Control\\\\SecurePipeServers\\\\Winreg\\\\AllowedPaths\\\\Machine: 432 description:433 returned: if exists434 type: string435 sample: 7,System\\\\CurrentControlSet\\\\Control\\\\Print\\\\Printers,System\\\\CurrentControlSet\\\\Services\\\\Eventlog,Software\\\\Microsoft\\\\OLAP Server,Software\\\\Microsoft\\\\Windows NT\\\\CurrentVersion\\\\Print,Software\\\\Microsoft\\\\Windows NT\\\\CurrentVersion\\\\Windows,System\\\\CurrentControlSet\\\\Control\\\\ContentIndex,System\\\\CurrentControlSet\\\\Control\\\\Terminal Server,System\\\\CurrentControlSet\\\\Control\\\\Terminal Server\\\\UserConfig,System\\\\CurrentControlSet\\\\Control\\\\Terminal Server\\\\DefaultUserConfiguration,Software\\\\Microsoft\\\\Windows NT\\\\CurrentVersion\\\\Perflib,System\\\\CurrentControlSet\\\\Services\\\\SysmonLog 436MACHINE\\\\System\\\\CurrentControlSet\\\\Control\\\\Session Manager\\\\Kernel\\\\ObCaseInsensitive: 437 description:438 returned: if exists439 type: string440 sample: 4,1 441MACHINE\\\\System\\\\CurrentControlSet\\\\Control\\\\Session Manager\\\\Memory Management\\\\ClearPageFileAtShutdown: 442 description:443 returned: if exists444 type: string445 sample: 4,0 446MACHINE\\\\System\\\\CurrentControlSet\\\\Control\\\\Session Manager\\\\ProtectionMode: 447 description:448 returned: if exists449 type: string450 sample: 4,1 451MACHINE\\\\System\\\\CurrentControlSet\\\\Control\\\\Session Manager\\\\SubSystems\\\\optional: 452 description:453 returned: if exists454 type: string455 sample: 7, 456MACHINE\\\\System\\\\CurrentControlSet\\\\Services\\\\LDAP\\\\LDAPClientIntegrity: 457 description:458 returned: if exists459 type: string460 sample: 4,1 461MACHINE\\\\System\\\\CurrentControlSet\\\\Services\\\\LanManServer\\\\Parameters\\\\AutoDisconnect: 462 description:463 returned: if exists464 type: string465 sample: 4,15 466MACHINE\\\\System\\\\CurrentControlSet\\\\Services\\\\LanManServer\\\\Parameters\\\\EnableForcedLogOff: 467 description:468 returned: if exists469 type: string470 sample: 4,1 471MACHINE\\\\System\\\\CurrentControlSet\\\\Services\\\\LanManServer\\\\Parameters\\\\EnableSecuritySignature: 472 description:473 returned: if exists474 type: string475 sample: 4,1 476MACHINE\\\\System\\\\CurrentControlSet\\\\Services\\\\LanManServer\\\\Parameters\\\\NullSessionPipes: 477 description:478 returned: if exists479 type: string480 sample: 7,,netlogon,samr,lsarpc 481MACHINE\\\\System\\\\CurrentControlSet\\\\Services\\\\LanManServer\\\\Parameters\\\\RequireSecuritySignature: 482 description:483 returned: if exists484 type: string485 sample: 4,1 486MACHINE\\\\System\\\\CurrentControlSet\\\\Services\\\\LanManServer\\\\Parameters\\\\RestrictNullSessAccess: 487 description:488 returned: if exists489 type: string490 sample: 4,1 491MACHINE\\\\System\\\\CurrentControlSet\\\\Services\\\\LanmanWorkstation\\\\Parameters\\\\EnablePlainTextPassword: 492 description:493 returned: if exists494 type: string495 sample: 4,0 496MACHINE\\\\System\\\\CurrentControlSet\\\\Services\\\\LanmanWorkstation\\\\Parameters\\\\EnableSecuritySignature: 497 description:498 returned: if exists499 type: string500 sample: 4,1 501MACHINE\\\\System\\\\CurrentControlSet\\\\Services\\\\LanmanWorkstation\\\\Parameters\\\\RequireSecuritySignature: 502 description:503 returned: if exists504 type: string505 sample: 4,0 506MACHINE\\\\System\\\\CurrentControlSet\\\\Services\\\\NTDS\\\\Parameters\\\\LDAPServerIntegrity: 507 description:508 returned: if exists509 type: string510 sample: 4,1 511MACHINE\\\\System\\\\CurrentControlSet\\\\Services\\\\Netlogon\\\\Parameters\\\\DisablePasswordChange: 512 description:513 returned: if exists514 type: string515 sample: 4,0 516MACHINE\\\\System\\\\CurrentControlSet\\\\Services\\\\Netlogon\\\\Parameters\\\\MaximumPasswordAge: 517 description:518 returned: if exists519 type: string520 sample: 4,30 521MACHINE\\\\System\\\\CurrentControlSet\\\\Services\\\\Netlogon\\\\Parameters\\\\RequireSignOrSeal: 522 description:523 returned: if exists524 type: string525 sample: 4,1 526MACHINE\\\\System\\\\CurrentControlSet\\\\Services\\\\Netlogon\\\\Parameters\\\\RequireStrongKey: 527 description:528 returned: if exists529 type: string530 sample: 4,1 531MACHINE\\\\System\\\\CurrentControlSet\\\\Services\\\\Netlogon\\\\Parameters\\\\SealSecureChannel: 532 description:533 returned: if exists534 type: string535 sample: 4,1 536MACHINE\\\\System\\\\CurrentControlSet\\\\Services\\\\Netlogon\\\\Parameters\\\\SignSecureChannel: 537 description:538 returned: if exists539 type: string540 sample: 4,1541# System Access542ClearTextPassword: 543 description:544 returned: if exists545 type: string546 sample: 0 547EnableAdminAccount: 548 description:549 returned: if exists550 type: string551 sample: 1 552EnableGuestAccount: 553 description:554 returned: if exists555 type: string556 sample: 0 557ForceLogoffWhenHourExpire: 558 description:559 returned: if exists560 type: string561 sample: 0 562LSAAnonymousNameLookup: 563 description:564 returned: if exists565 type: string566 sample: 0 567LockoutBadCount: 568 description:569 returned: if exists570 type: string571 sample: 0 572MaximumPasswordAge: 573 description:574 returned: if exists575 type: string576 sample: 42 577MinimumPasswordAge: 578 description:579 returned: if exists580 type: string581 sample: 1 582MinimumPasswordLength: 583 description:584 returned: if exists585 type: string586 sample: 7 587NewAdministratorName: 588 description:589 returned: if exists590 type: string591 sample: \\"Administrator\\" 592NewGuestName: 593 description:594 returned: if exists595 type: string596 sample: \\"Guest\\" 597PasswordComplexity: 598 description:599 returned: if exists600 type: string601 sample: 1 602PasswordHistorySize: 603 description:604 returned: if exists605 type: string606 sample: 24 607RequireLogonToChangePassword: 608 description:609 returned: if exists610 type: string611 sample: 0612# Unicode613Unicode: 614 description:615 returned: if exists616 type: string617 sample: yes618# Version619Revision: 620 description:621 returned: if exists622 type: string623 sample: 1624signature: 625 description:626 returned: if exists627 type: string628 sample: \\"$CHICAGO$\\"...

Full Screen

Full Screen

files-and-ignores.js

Source:files-and-ignores.js Github

copy

Full Screen

1'use strict'2var test = require('tap').test3var common = require('../common-tap.js')4var path = require('path')5var rimraf = require('rimraf')6var mkdirp = require('mkdirp')7var fs = require('graceful-fs')8var tar = require('tar')9var zlib = require('zlib')10var basepath = path.resolve(__dirname, path.basename(__filename, '.js'))11var fixturepath = path.resolve(basepath, 'npm-test-files')12var targetpath = path.resolve(basepath, 'target')13var Tacks = require('tacks')14var File = Tacks.File15var Dir = Tacks.Dir16test('basic file inclusion', function (t) {17 var fixture = new Tacks(18 Dir({19 'package.json': File({20 name: 'npm-test-files',21 version: '1.2.5',22 files: [23 'include',24 'sub/include'25 ]26 }),27 include: File(''),28 sub: Dir({ include: File('') }),29 notincluded: File('')30 })31 )32 withFixture(t, fixture, function (done) {33 t.ok(fileExists('include'), 'toplevel file included')34 t.ok(fileExists('sub/include'), 'nested file included')35 t.notOk(fileExists('notincluded'), 'unspecified file not included')36 done()37 })38})39test('basic file exclusion', function (t) {40 var fixture = new Tacks(41 Dir({42 'package.json': File({43 name: 'npm-test-files',44 version: '1.2.5'45 }),46 '.npmignore': File(47 'ignore\n' +48 'sub/ignore\n'49 ),50 include: File(''),51 ignore: File(''),52 sub: Dir({ ignore: File('') })53 })54 )55 withFixture(t, fixture, function (done) {56 t.notOk(fileExists('ignore'), 'toplevel file excluded')57 t.notOk(fileExists('sub/ignore'), 'nested file excluded')58 t.ok(fileExists('include'), 'unignored file included')59 done()60 })61})62test('toplevel-only and blanket ignores', function (t) {63 var fixture = new Tacks(64 Dir({65 'package.json': File({66 name: 'npm-test-files',67 version: '1.2.5'68 }),69 '.npmignore': File(70 './shallow1\n' +71 '/shallow2\n' +72 '/sub/onelevel\n' +73 'deep\n' +74 ''75 ),76 shallow1: File(''),77 shallow2: File(''),78 deep: File(''),79 sub: Dir({80 shallow1: File(''),81 shallow2: File(''),82 onelevel: File(''),83 deep: File(''),84 sub: Dir({85 deep: File(''),86 onelevel: File('')87 })88 })89 })90 )91 withFixture(t, fixture, function (done) {92 t.notOk(fileExists('shallow2'), '/ file excluded')93 t.ok(fileExists('sub/shallow1'), 'nested ./ file included')94 t.ok(fileExists('sub/shallow2'), 'nested / file included')95 t.ok(fileExists('sub/sub/onelevel'), 'double-nested file included')96 t.notOk(fileExists('sub/onelevel'), 'nested / file excluded')97 t.notOk(fileExists('deep'), 'deep file excluded')98 t.notOk(fileExists('sub/deep'), 'nested deep file excluded')99 t.notOk(fileExists('sub/sub/deep'), 'double-nested deep file excluded')100 t.ok(fileExists('shallow1'), './ file included')101 done()102 })103})104test('.npmignore works for nested directories recursively', function (t) {105 var fixture = new Tacks(106 Dir({107 'package.json': File({108 name: 'npm-test-files',109 version: '1.2.5'110 }),111 '.npmignore': File(112 '/ignore\n' +113 'deep\n'114 ),115 include: File(''),116 ignore: File(''),117 deep: File(''),118 sub: Dir({119 ignore: File(''),120 include: File(''),121 deep: File(''),122 sub: Dir({123 '.npmignore': File(124 '/ignore\n'125 ),126 ignore: File(''),127 include: File(''),128 deep: File('')129 })130 })131 })132 )133 withFixture(t, fixture, function (done) {134 t.notOk(fileExists('ignore'), 'toplevel file excluded')135 t.ok(fileExists('include'), 'unignored file included')136 t.ok(fileExists('sub/ignore'), 'same-name file in nested dir included')137 t.ok(fileExists('sub/include'), 'unignored nested dir file included')138 t.notOk(fileExists('sub/sub/ignore'), 'sub-sub-directory file excluded')139 t.ok(fileExists('sub/sub/include'), 'sub-sube-directory file included')140 t.notOk(fileExists('deep'), 'deep file excluded')141 t.notOk(fileExists('sub/deep'), 'sub-dir deep file excluded')142 t.notOk(fileExists('sub/sub/deep'), 'sub-sub-dir deep file excluded')143 done()144 })145})146test('.gitignore should have identical semantics', function (t) {147 var fixture = new Tacks(148 Dir({149 'package.json': File({150 name: 'npm-test-files',151 version: '1.2.5'152 }),153 '.gitignore': File(154 './shallow1\n' +155 '/shallow2\n' +156 '/sub/onelevel\n' +157 'deep\n' +158 ''159 ),160 shallow1: File(''),161 shallow2: File(''),162 deep: File(''),163 sub: Dir({164 shallow1: File(''),165 shallow2: File(''),166 onelevel: File(''),167 deep: File(''),168 sub: Dir({169 deep: File(''),170 onelevel: File('')171 })172 })173 })174 )175 withFixture(t, fixture, function (done) {176 t.notOk(fileExists('shallow2'), '/ file excluded')177 t.ok(fileExists('sub/shallow1'), 'nested ./ file included')178 t.ok(fileExists('sub/shallow2'), 'nested / file included')179 t.ok(fileExists('sub/sub/onelevel'), 'double-nested file included')180 t.notOk(fileExists('sub/onelevel'), 'nested / file excluded')181 t.notOk(fileExists('deep'), 'deep file excluded')182 t.notOk(fileExists('sub/deep'), 'nested deep file excluded')183 t.notOk(fileExists('sub/sub/deep'), 'double-nested deep file excluded')184 t.ok(fileExists('shallow1'), './ file included')185 done()186 })187})188test('.npmignore should always be overridden by files array', function (t) {189 var fixture = new Tacks(190 Dir({191 'package.json': File({192 name: 'npm-test-files',193 version: '1.2.5',194 files: [195 'include',196 'sub'197 ]198 }),199 '.npmignore': File(200 'include\n' +201 'ignore\n' +202 'sub/included\n'203 ),204 include: File(''),205 ignore: File(''),206 sub: Dir({207 include: File('')208 })209 })210 )211 withFixture(t, fixture, function (done) {212 t.notOk(fileExists('ignore'), 'toplevel file excluded')213 t.ok(fileExists('include'), 'unignored file included')214 t.ok(fileExists('sub/include'), 'nested file included')215 done()216 })217})218test('.gitignore supported for ignores', function (t) {219 var fixture = new Tacks(220 Dir({221 'package.json': File({222 name: 'npm-test-files',223 version: '1.2.5'224 }),225 '.gitignore': File(226 'ignore\n' +227 'sub/ignore\n'228 ),229 include: File(''),230 ignore: File(''),231 sub: Dir({ ignore: File('') })232 })233 )234 withFixture(t, fixture, function (done) {235 t.notOk(fileExists('ignore'), 'toplevel file excluded')236 t.notOk(fileExists('sub/ignore'), 'nested file excluded')237 t.ok(fileExists('include'), 'unignored file included')238 done()239 })240})241test('.npmignore completely overrides .gitignore', function (t) {242 var fixture = new Tacks(243 Dir({244 'package.json': File({245 name: 'npm-test-files',246 version: '1.2.5'247 }),248 '.npmignore': File(249 'ignore\n' +250 'sub/ignore\n'251 ),252 '.gitignore': File(253 'include\n' +254 'sub/include\n' +255 'extra\n'256 ),257 include: File(''),258 sub: Dir({ include: File('') }),259 extra: File('')260 })261 )262 withFixture(t, fixture, function (done) {263 t.ok(fileExists('include'), 'gitignored toplevel file included')264 t.ok(fileExists('extra'), 'gitignored extra toplevel file included')265 t.ok(fileExists('sub/include'), 'gitignored nested file included')266 t.notOk(fileExists('ignore'), 'toplevel file excluded')267 t.notOk(fileExists('sub/ignore'), 'nested file excluded')268 done()269 })270})271test('files array overrides .npmignore', function (t) {272 var fixture = new Tacks(273 Dir({274 'package.json': File({275 name: 'npm-test-files',276 version: '1.2.5',277 files: [278 'include',279 'sub/include'280 ]281 }),282 '.npmignore': File(283 'include\n' +284 'sub/include\n'285 ),286 include: File(''),287 sub: Dir({ include: File('') })288 })289 )290 withFixture(t, fixture, function (done) {291 t.ok(fileExists('include'), 'toplevel file included')292 t.ok(fileExists('sub/include'), 'nested file included')293 done()294 })295})296test('includes files regardless of emptiness', function (t) {297 var fixture = new Tacks(298 Dir({299 'package.json': File({300 name: 'npm-test-files',301 version: '1.2.5',302 files: [303 'full',304 'empty'305 ]306 }),307 full: File('This file has contents~'),308 empty: File('')309 })310 )311 withFixture(t, fixture, function (done) {312 t.ok(fileExists('full'), 'contentful file included')313 t.ok(fileExists('empty'), 'empty file included')314 done()315 })316})317test('.npmignore itself gets included', function (t) {318 var fixture = new Tacks(319 Dir({320 'package.json': File({321 name: 'npm-test-files',322 version: '1.2.5',323 files: [324 '.npmignore'325 ]326 }),327 '.npmignore': File('')328 })329 )330 withFixture(t, fixture, function (done) {331 t.ok(fileExists('.npmignore'), '.npmignore included')332 done()333 })334})335test('include default files when missing files spec', function (t) {336 var fixture = new Tacks(337 Dir({338 'package.json': File({339 name: 'npm-test-files',340 version: '1.2.5'341 }),342 'index.js': File(''),343 foo: File(''),344 node_modules: Dir({foo: Dir({bar: File('')})})345 })346 )347 withFixture(t, fixture, function (done) {348 t.ok(fileExists('index.js'), 'index.js included')349 t.ok(fileExists('foo'), 'foo included')350 t.notOk(fileExists('node_modules'), 'node_modules not included')351 done()352 })353})354test('include main file', function (t) {355 var fixture = new Tacks(356 Dir({357 'package.json': File({358 name: 'npm-test-files',359 version: '1.2.5',360 main: 'foo.js',361 files: []362 }),363 'index.js': File(''),364 'foo.js': File('')365 })366 )367 withFixture(t, fixture, function (done) {368 t.ok(fileExists('foo.js'), 'foo.js included because of main')369 t.notOk(fileExists('index.js'), 'index.js not included')370 done()371 })372})373test('certain files ignored unconditionally', function (t) {374 var fixture = new Tacks(375 Dir({376 'package.json': File({377 name: 'npm-test-files',378 version: '1.2.5',379 files: [380 '.git',381 '.svn',382 'CVS',383 '.hg',384 '.lock-wscript',385 '.wafpickle-0',386 '.wafpickle-5',387 '.wafpickle-50',388 'build/config.gypi',389 'npm-debug.log',390 '.npmrc',391 '.foo.swp',392 '.DS_Store',393 '._ohno'394 ]395 }),396 '.git': Dir({foo: File('')}),397 '.svn': Dir({foo: File('')}),398 'CVS': Dir({foo: File('')}),399 '.hg': Dir({foo: File('')}),400 '.lock-wscript': File(''),401 '.wafpickle-0': File(''),402 '.wafpickle-5': File(''),403 '.wafpickle-50': File(''),404 'build': Dir({'config.gypi': File('')}),405 'npm-debug.log': File(''),406 '.npmrc': File(''),407 '.foo.swp': File(''),408 '.DS_Store': Dir({foo: File('')}),409 '._ohno': File(''),410 '._ohnoes': Dir({noes: File('')})411 })412 )413 withFixture(t, fixture, function (done) {414 t.notOk(fileExists('.git'), '.git not included')415 t.notOk(fileExists('.svn'), '.svn not included')416 t.notOk(fileExists('CVS'), 'CVS not included')417 t.notOk(fileExists('.hg'), '.hg not included')418 t.notOk(fileExists('.lock-wscript'), '.lock-wscript not included')419 t.notOk(fileExists('.wafpickle-0'), '.wafpickle-0 not included')420 t.notOk(fileExists('.wafpickle-5'), '.wafpickle-5 not included')421 t.notOk(fileExists('.wafpickle-50'), '.wafpickle-50 not included')422 t.notOk(fileExists('build/config.gypi'), 'build/config.gypi not included')423 t.notOk(fileExists('npm-debug.log'), 'npm-debug.log not included')424 t.notOk(fileExists('.npmrc'), '.npmrc not included')425 t.notOk(fileExists('.foo.swp'), '.foo.swp not included')426 t.notOk(fileExists('.DS_Store'), '.DS_Store not included')427 t.notOk(fileExists('._ohno'), '._ohno not included')428 t.notOk(fileExists('._ohnoes'), '._ohnoes not included')429 done()430 })431})432test('certain files included unconditionally', function (t) {433 var fixture = new Tacks(434 Dir({435 'package.json': File({436 name: 'npm-test-files',437 version: '1.2.5'438 }),439 '.npmignore': File(440 'package.json',441 'README',442 'Readme',443 'readme.md',444 'readme.randomext',445 'changelog',446 'CHAngelog',447 'ChangeLOG.txt',448 'history',449 'HistorY',450 'HistorY.md',451 'license',452 'licence',453 'LICENSE',454 'LICENCE'455 ),456 'README': File(''),457 'Readme': File(''),458 'readme.md': File(''),459 'readme.randomext': File(''),460 'changelog': File(''),461 'CHAngelog': File(''),462 'ChangeLOG.txt': File(''),463 'history': File(''),464 'HistorY': File(''),465 'HistorY.md': File(''),466 'license': File(''),467 'licence': File(''),468 'LICENSE': File(''),469 'LICENCE': File('')470 })471 )472 withFixture(t, fixture, function (done) {473 t.ok(fileExists('package.json'), 'package.json included')474 t.ok(fileExists('README'), 'README included')475 t.ok(fileExists('Readme'), 'Readme included')476 t.ok(fileExists('readme.md'), 'readme.md included')477 t.ok(fileExists('readme.randomext'), 'readme.randomext included')478 t.ok(fileExists('changelog'), 'changelog included')479 t.ok(fileExists('CHAngelog'), 'CHAngelog included')480 t.ok(fileExists('ChangeLOG.txt'), 'ChangeLOG.txt included')481 t.ok(fileExists('license'), 'license included')482 t.ok(fileExists('licence'), 'licence included')483 t.ok(fileExists('LICENSE'), 'LICENSE included')484 t.ok(fileExists('LICENCE'), 'LICENCE included')485 done()486 })487})488test('unconditional inclusion does not capture modules', function (t) {489 var fixture = new Tacks(490 Dir({491 'package.json': File({492 name: 'npm-test-files',493 version: '1.2.5'494 }),495 'node_modules': Dir({496 'readme': Dir({ 'file': File('') }),497 'README': Dir({ 'file': File('') }),498 'licence': Dir({ 'file': File('') }),499 'license': Dir({ 'file': File('') }),500 'history': Dir({ 'file': File('') }),501 'History': Dir({ 'file': File('') }),502 'changelog': Dir({ 'file': File('') }),503 'ChangeLOG': Dir({ 'file': File('') })504 })505 })506 )507 withFixture(t, fixture, function (done) {508 t.notOk(fileExists('node_modules/readme/file'), 'readme module not included')509 t.notOk(fileExists('node_modules/README/file'), 'README module not included')510 t.notOk(fileExists('node_modules/licence/file'), 'licence module not included')511 t.notOk(fileExists('node_modules/license/file'), 'license module not included')512 t.notOk(fileExists('node_modules/history/file'), 'history module not included')513 t.notOk(fileExists('node_modules/History/file'), 'History module not included')514 t.notOk(fileExists('node_modules/changelog/file'), 'changelog module not included')515 t.notOk(fileExists('node_modules/ChangeLOG/file'), 'ChangeLOG module not included')516 done()517 })518})519test('folder-based inclusion works', function (t) {520 var fixture = new Tacks(521 Dir({522 'package.json': File({523 name: 'npm-test-files',524 version: '1.2.5',525 files: [526 'sub1/sub',527 'sub2'528 ]529 }),530 sub1: Dir({531 sub: Dir({532 include1: File(''),533 include2: File('')534 }),535 ignored: File('')536 }),537 sub2: Dir({538 include1: File(''),539 include2: File(''),540 empty: Dir({})541 })542 })543 )544 withFixture(t, fixture, function (done) {545 t.ok(fileExists('sub1/sub/include1'), 'nested dir included')546 t.ok(fileExists('sub1/sub/include2'), 'nested dir included')547 t.notOk(fileExists('sub1/ignored'), 'unspecified file not included')548 t.ok(fileExists('sub2/include1'), 'dir contents included')549 t.ok(fileExists('sub2/include2'), 'dir contents included')550 t.notOk(fileExists('sub2/empty'), 'empty dir not included')551 done()552 })553})554function fileExists (file) {555 try {556 return !!fs.statSync(path.resolve(targetpath, 'package', file))557 } catch (_) {558 return false559 }560}561function withFixture (t, fixture, tester) {562 fixture.create(fixturepath)563 mkdirp.sync(targetpath)564 common.npm(['pack', fixturepath], {cwd: basepath}, extractAndCheck)565 function extractAndCheck (err, code) {566 if (err) throw err567 t.is(code, 0, 'pack went ok')568 extractTarball(checkTests)569 }570 function checkTests (err) {571 if (err) throw err572 tester(removeAndDone)573 }574 function removeAndDone (err) {575 if (err) throw err576 fixture.remove(fixturepath)577 rimraf.sync(basepath)578 t.done()579 }580}581function extractTarball (cb) {582 // Unpack to disk so case-insensitive filesystems are consistent583 fs.createReadStream(path.join(basepath, 'npm-test-files-1.2.5.tgz'))584 .pipe(zlib.Unzip())585 .on('error', cb)586 .pipe(tar.Extract(targetpath))587 .on('error', cb)588 .on('end', function () { cb() })...

Full Screen

Full Screen

test_ofc_manager.py

Source:test_ofc_manager.py Github

copy

Full Screen

1# vim: tabstop=4 shiftwidth=4 softtabstop=42# Copyright 2012 NEC Corporation. All rights reserved.3#4# Licensed under the Apache License, Version 2.0 (the "License"); you may5# not use this file except in compliance with the License. You may obtain6# a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing, software11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the13# License for the specific language governing permissions and limitations14# under the License.15# @author: Ryota MIBU16from quantum import context17from quantum.openstack.common import uuidutils18from quantum.plugins.nec.common import config19from quantum.plugins.nec.db import api as ndb20from quantum.plugins.nec.db import models as nmodels # noqa21from quantum.plugins.nec import ofc_manager22from quantum.tests import base23class OFCManagerTestBase(base.BaseTestCase):24 """Class conisting of OFCManager unit tests."""25 def setUp(self):26 super(OFCManagerTestBase, self).setUp()27 driver = "quantum.tests.unit.nec.stub_ofc_driver.StubOFCDriver"28 config.CONF.set_override('driver', driver, 'OFC')29 ndb.initialize()30 self.addCleanup(ndb.clear_db)31 self.ofc = ofc_manager.OFCManager()32 self.ctx = context.get_admin_context()33 def get_random_params(self):34 """create random parameters for portinfo test."""35 tenant = uuidutils.generate_uuid()36 network = uuidutils.generate_uuid()37 port = uuidutils.generate_uuid()38 _filter = uuidutils.generate_uuid()39 none = uuidutils.generate_uuid()40 return tenant, network, port, _filter, none41class OFCManagerTest(OFCManagerTestBase):42 def testa_create_ofc_tenant(self):43 """test create ofc_tenant."""44 t, n, p, f, none = self.get_random_params()45 self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_tenant', t))46 self.ofc.create_ofc_tenant(self.ctx, t)47 self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_tenant', t))48 tenant = ndb.get_ofc_item(self.ctx.session, 'ofc_tenant', t)49 self.assertEqual(tenant.ofc_id, "ofc-" + t[:-4])50 def testb_exists_ofc_tenant(self):51 """test exists_ofc_tenant."""52 t, n, p, f, none = self.get_random_params()53 self.assertFalse(self.ofc.exists_ofc_tenant(self.ctx, t))54 self.ofc.create_ofc_tenant(self.ctx, t)55 self.assertTrue(self.ofc.exists_ofc_tenant(self.ctx, t))56 def testc_delete_ofc_tenant(self):57 """test delete ofc_tenant."""58 t, n, p, f, none = self.get_random_params()59 self.ofc.create_ofc_tenant(self.ctx, t)60 self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_tenant', t))61 self.ofc.delete_ofc_tenant(self.ctx, t)62 self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_tenant', t))63 def testd_create_ofc_network(self):64 """test create ofc_network."""65 t, n, p, f, none = self.get_random_params()66 self.ofc.create_ofc_tenant(self.ctx, t)67 self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_network', n))68 self.ofc.create_ofc_network(self.ctx, t, n)69 self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_network', n))70 network = ndb.get_ofc_item(self.ctx.session, 'ofc_network', n)71 self.assertEqual(network.ofc_id, "ofc-" + n[:-4])72 def teste_exists_ofc_network(self):73 """test exists_ofc_network."""74 t, n, p, f, none = self.get_random_params()75 self.ofc.create_ofc_tenant(self.ctx, t)76 self.assertFalse(self.ofc.exists_ofc_network(self.ctx, n))77 self.ofc.create_ofc_network(self.ctx, t, n)78 self.assertTrue(self.ofc.exists_ofc_network(self.ctx, n))79 def testf_delete_ofc_network(self):80 """test delete ofc_network."""81 t, n, p, f, none = self.get_random_params()82 self.ofc.create_ofc_tenant(self.ctx, t)83 self.ofc.create_ofc_network(self.ctx, t, n)84 self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_network', n))85 self.ofc.delete_ofc_network(self.ctx, n, {'tenant_id': t})86 self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_network', n))87 def testg_create_ofc_port(self):88 """test create ofc_port."""89 t, n, p, f, none = self.get_random_params()90 self.ofc.create_ofc_tenant(self.ctx, t)91 self.ofc.create_ofc_network(self.ctx, t, n)92 ndb.add_portinfo(self.ctx.session, p, "0xabc", 1, 65535,93 "00:11:22:33:44:55")94 self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_port', p))95 port = {'tenant_id': t, 'network_id': n}96 self.ofc.create_ofc_port(self.ctx, p, port)97 self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_port', p))98 port = ndb.get_ofc_item(self.ctx.session, 'ofc_port', p)99 self.assertEqual(port.ofc_id, "ofc-" + p[:-4])100 def testh_exists_ofc_port(self):101 """test exists_ofc_port."""102 t, n, p, f, none = self.get_random_params()103 self.ofc.create_ofc_tenant(self.ctx, t)104 self.ofc.create_ofc_network(self.ctx, t, n)105 ndb.add_portinfo(self.ctx.session, p, "0xabc", 2, 65535,106 "00:12:22:33:44:55")107 self.assertFalse(self.ofc.exists_ofc_port(self.ctx, p))108 port = {'tenant_id': t, 'network_id': n}109 self.ofc.create_ofc_port(self.ctx, p, port)110 self.assertTrue(self.ofc.exists_ofc_port(self.ctx, p))111 def testi_delete_ofc_port(self):112 """test delete ofc_port."""113 t, n, p, f, none = self.get_random_params()114 self.ofc.create_ofc_tenant(self.ctx, t)115 self.ofc.create_ofc_network(self.ctx, t, n)116 ndb.add_portinfo(self.ctx.session, p, "0xabc", 3, 65535,117 "00:13:22:33:44:55")118 port = {'tenant_id': t, 'network_id': n}119 self.ofc.create_ofc_port(self.ctx, p, port)120 self.assertTrue(ndb.get_ofc_item(self.ctx.session, 'ofc_port', p))121 self.ofc.delete_ofc_port(self.ctx, p, port)122 self.assertFalse(ndb.get_ofc_item(self.ctx.session, 'ofc_port', p))123 def testj_create_ofc_packet_filter(self):124 """test create ofc_filter."""125 t, n, p, f, none = self.get_random_params()126 self.ofc.create_ofc_tenant(self.ctx, t)127 self.ofc.create_ofc_network(self.ctx, t, n)128 self.assertFalse(ndb.get_ofc_item(self.ctx.session,129 'ofc_packet_filter', f))130 pf = {'tenant_id': t, 'network_id': n}131 self.ofc.create_ofc_packet_filter(self.ctx, f, pf)132 self.assertTrue(ndb.get_ofc_item(self.ctx.session,133 'ofc_packet_filter', f))134 _filter = ndb.get_ofc_item(self.ctx.session, 'ofc_packet_filter', f)135 self.assertEqual(_filter.ofc_id, "ofc-" + f[:-4])136 def testk_exists_ofc_packet_filter(self):137 """test exists_ofc_packet_filter."""138 t, n, p, f, none = self.get_random_params()139 self.ofc.create_ofc_tenant(self.ctx, t)140 self.ofc.create_ofc_network(self.ctx, t, n)141 self.assertFalse(self.ofc.exists_ofc_packet_filter(self.ctx, f))142 pf = {'tenant_id': t, 'network_id': n}143 self.ofc.create_ofc_packet_filter(self.ctx, f, pf)144 self.assertTrue(self.ofc.exists_ofc_packet_filter(self.ctx, f))145 def testl_delete_ofc_packet_filter(self):146 """test delete ofc_filter."""147 t, n, p, f, none = self.get_random_params()148 self.ofc.create_ofc_tenant(self.ctx, t)149 self.ofc.create_ofc_network(self.ctx, t, n)150 pf = {'tenant_id': t, 'network_id': n}151 self.ofc.create_ofc_packet_filter(self.ctx, f, pf)152 self.assertTrue(ndb.get_ofc_item(self.ctx.session,153 'ofc_packet_filter', f))154 self.ofc.delete_ofc_packet_filter(self.ctx, f)155 self.assertFalse(ndb.get_ofc_item(self.ctx.session,156 'ofc_packet_filter', f))157class OFCManagerTestWithOldMapping(OFCManagerTestBase):158 def test_exists_ofc_tenant(self):159 t, n, p, f, none = self.get_random_params()160 ofc_t, ofc_n, ofc_p, ofc_f, ofc_none = self.get_random_params()161 self.assertFalse(self.ofc.exists_ofc_tenant(self.ctx, t))162 session = self.ctx.session163 ndb.add_ofc_item(session, 'ofc_tenant', t, ofc_t, old_style=True)164 self.assertTrue(self.ofc.exists_ofc_tenant(self.ctx, t))165 def test_delete_ofc_tenant(self):166 t, n, p, f, none = self.get_random_params()167 ofc_t, ofc_n, ofc_p, ofc_f, ofc_none = self.get_random_params()168 self.assertFalse(self.ofc.exists_ofc_tenant(self.ctx, t))169 session = self.ctx.session170 ndb.add_ofc_item(session, 'ofc_tenant', t, ofc_t, old_style=True)171 self.assertTrue(self.ofc.exists_ofc_tenant(self.ctx, t))172 self.ofc.delete_ofc_tenant(self.ctx, t)173 self.assertFalse(self.ofc.exists_ofc_tenant(self.ctx, t))174 def test_exists_ofc_network(self):175 t, n, p, f, none = self.get_random_params()176 ofc_t, ofc_n, ofc_p, ofc_f, ofc_none = self.get_random_params()177 self.assertFalse(self.ofc.exists_ofc_network(self.ctx, n))178 session = self.ctx.session179 ndb.add_ofc_item(session, 'ofc_network', n, ofc_n, old_style=True)180 self.assertTrue(self.ofc.exists_ofc_network(self.ctx, n))181 def test_delete_ofc_network(self):182 t, n, p, f, none = self.get_random_params()183 ofc_t, ofc_n, ofc_p, ofc_f, ofc_none = self.get_random_params()184 self.assertFalse(self.ofc.exists_ofc_network(self.ctx, n))185 session = self.ctx.session186 ndb.add_ofc_item(session, 'ofc_network', n, ofc_n, old_style=True)187 self.assertTrue(self.ofc.exists_ofc_network(self.ctx, n))188 net = {'tenant_id': t}189 self.ofc.delete_ofc_network(self.ctx, n, net)190 self.assertFalse(self.ofc.exists_ofc_network(self.ctx, n))191 def test_exists_ofc_port(self):192 t, n, p, f, none = self.get_random_params()193 ofc_t, ofc_n, ofc_p, ofc_f, ofc_none = self.get_random_params()194 self.assertFalse(self.ofc.exists_ofc_port(self.ctx, p))195 session = self.ctx.session196 ndb.add_ofc_item(session, 'ofc_port', p, ofc_p, old_style=True)197 self.assertTrue(self.ofc.exists_ofc_port(self.ctx, p))198 def test_delete_ofc_port(self):199 t, n, p, f, none = self.get_random_params()200 ofc_t, ofc_n, ofc_p, ofc_f, ofc_none = self.get_random_params()201 self.assertFalse(self.ofc.exists_ofc_port(self.ctx, p))202 session = self.ctx.session203 ndb.add_ofc_item(session, 'ofc_port', p, ofc_p, old_style=True)204 self.assertTrue(self.ofc.exists_ofc_port(self.ctx, p))205 port = {'tenant_id': t, 'network_id': n}206 self.ofc.delete_ofc_port(self.ctx, p, port)207 self.assertFalse(self.ofc.exists_ofc_port(self.ctx, p))208 def test_exists_ofc_packet_filter(self):209 t, n, p, f, none = self.get_random_params()210 ofc_t, ofc_n, ofc_p, ofc_f, ofc_none = self.get_random_params()211 self.assertFalse(self.ofc.exists_ofc_packet_filter(self.ctx, f))212 session = self.ctx.session213 ndb.add_ofc_item(session, 'ofc_packet_filter', f, ofc_f,214 old_style=True)215 self.assertTrue(self.ofc.exists_ofc_packet_filter(self.ctx, f))216 def test_delete_ofc_packet_filter(self):217 t, n, p, f, none = self.get_random_params()218 ofc_t, ofc_n, ofc_p, ofc_f, ofc_none = self.get_random_params()219 self.assertFalse(self.ofc.exists_ofc_packet_filter(self.ctx, f))220 session = self.ctx.session221 ndb.add_ofc_item(session, 'ofc_packet_filter', f, ofc_f,222 old_style=True)223 self.assertTrue(self.ofc.exists_ofc_packet_filter(self.ctx, f))224 self.ofc.delete_ofc_packet_filter(self.ctx, f)...

Full Screen

Full Screen

test_volume.py

Source:test_volume.py Github

copy

Full Screen

...42 self.assertEqual(1, self.volumeDevice.unmount.call_count)43 utils.execute = origin_execute44 self.volumeDevice.unmount = origin_unmount45 os.path.exists = origin_os_path_exists46 def test__check_device_exists(self):47 origin_execute = utils.execute48 utils.execute = Mock()49 self.volumeDevice._check_device_exists()50 self.assertEqual(1, utils.execute.call_count)51 utils.execute = origin_execute52 def test__check_format(self):53 fake_spawn = _setUp_fake_spawn()54 self.volumeDevice._check_format()55 self.assertEqual(1, fake_spawn.expect.call_count)56 def test__check_format_2(self):57 fake_spawn = _setUp_fake_spawn(return_val=1)58 self.assertEqual(0, fake_spawn.expect.call_count)59 self.assertRaises(IOError, self.volumeDevice._check_format)60 def test__format(self):61 fake_spawn = _setUp_fake_spawn()62 self.volumeDevice._format()63 self.assertEqual(1, fake_spawn.expect.call_count)...

Full Screen

Full Screen

engines.py

Source:engines.py Github

copy

Full Screen

...28 Method must that delete the value of existing key in local cache.29 :param key: Key to find.30 """31 @abstractmethod32 def exists(self, key: str) -> bool:33 """34 Method to return the existence or not in the local cache of a key.35 :param key: Key to find.36 :return: [bool] Existence or not int the local cache of a key.37 """38 @abstractmethod39 def clear(self) -> None:40 """41 Method that clear all cache.42 """43class MemcachedEngine(BaseCacheEngine):44 def __init__(self):45 ImportUtils.raise_exception_if_module_not_exists('pymemcache')46 from pymemcache.client import base47 self._client = base.Client(('localhost', 11211))48 def get(self, key):49 return self._client.get(key)50 def exists(self, key):51 return self.get(key) is not None52 def set(self, key, value, timeout=None, size=None):53 return self._client.set(key, value) # TODO: falta pasarle la configuracion54 def clear(self):55 return self._client.flush_all()56 def delete(self, key):57 return self._client.delete(key)58 def close(self):59 self._client.close()60class RedisEngine(BaseCacheEngine):61 def __init__(self):62 ImportUtils.raise_exception_if_module_not_exists('redis')63 import redis64 self._redis = redis.Redis()65 def get(self, key):66 return self._redis.get(key)67 def exists(self, key):68 return self.get(key) is not None69 def set(self, key, value, timeout=None, size=None):70 return self._redis.set(key, value, timeout)71 def clear(self):72 return self._redis.flushall()73 def delete(self, key):74 return self._redis.delete(key)75 def close(self):76 self._redis.close()77if __name__ == '__main__':78 # -------------------------------------------------------------------79 # ------------------------- EXAMPLES --------------------------------80 # -------------------------------------------------------------------81 # TODO: falta añadir un memcache real y los test82 # -------------------------------------------------------------------83 # MEMCACHE CACHE84 # -------------------------------------------------------------------85 print("\n\t Memcache Cache Class - Example\n")86 key_1 = "key_1"87 key_2 = "key_2"88 key_3 = "key_3"89 mem_cache = MemcachedEngine()90 print(f"Add new keys: {key_1}, {key_2}, {key_3}")91 mem_cache.set(key_1, "value1")92 mem_cache.set(key_2, "value2")93 mem_cache.set(key_3, "value3")94 print(f"\t\t{key_1} exists: {mem_cache.exists(key_1)}")95 print(f"\t\t{key_2} exists: {mem_cache.exists(key_2)}")96 print(f"\t\t{key_3} exists: {mem_cache.exists(key_3)}")97 print(f"Delete key: {key_1}")98 mem_cache.delete(key_1)99 print(f"\t\t{key_1} exists: {mem_cache.exists(key_1)}")100 print(f"\t\t{key_2} exists: {mem_cache.exists(key_2)}")101 print(f"\t\t{key_3} exists: {mem_cache.exists(key_3)}")102 print("Clear Local Cache")103 mem_cache.clear()104 print(f"\t\t{key_1} exists: {mem_cache.exists(key_1)}")105 print(f"\t\t{key_2} exists: {mem_cache.exists(key_2)}")106 print(f"\t\t{key_3} exists: {mem_cache.exists(key_3)}")107 # TODO: falta añadir un redis real y los test108 # -------------------------------------------------------------------109 # REDIS CACHE110 # -------------------------------------------------------------------111 print("\n\t Redis Cache Class - Example\n")112 key_1 = "key_1"113 key_2 = "key_2"114 key_3 = "key_3"115 redis_cache = RedisEngine()116 print(f"Add new keys: {key_1}, {key_2}, {key_3}")117 redis_cache.set(key_1, "value1")118 redis_cache.set(key_2, "value2")119 redis_cache.set(key_3, "value3")120 print(f"\t\t{key_1} exists: {redis_cache.exists(key_1)}")121 print(f"\t\t{key_2} exists: {redis_cache.exists(key_2)}")122 print(f"\t\t{key_3} exists: {redis_cache.exists(key_3)}")123 print(f"Delete key: {key_1}")124 redis_cache.delete(key_1)125 print(f"\t\t{key_1} exists: {redis_cache.exists(key_1)}")126 print(f"\t\t{key_2} exists: {redis_cache.exists(key_2)}")127 print(f"\t\t{key_3} exists: {redis_cache.exists(key_3)}")128 print("Clear Local Cache")129 redis_cache.clear()130 print(f"\t\t{key_1} exists: {redis_cache.exists(key_1)}")131 print(f"\t\t{key_2} exists: {redis_cache.exists(key_2)}")...

Full Screen

Full Screen

DataReqs.py

Source:DataReqs.py Github

copy

Full Screen

...23# check functions24###############################################################################25log = Logger().get_instance()26def ensureFileExists(fileName):27 if not os.path.exists(fileName):28 log.info("database ", fileName," does not exist")29 #sys.exit(2)30 theFile = open(fileName, 'w')31 theFile.close()32def checkFileExists(fileName):33 if not os.path.exists(fileName):34 log.info("database ", fileName," does not exist")35 return False36 else:37 return True38def checkfamixL1Reqs(DbLoc):39 """ checks information requirements for Famix level 1"""40 ensureFileExists(DbLoc + ".classes")41 ensureFileExists(DbLoc + ".inheritance")42 ensureFileExists(DbLoc + ".methods")43 ensureFileExists(DbLoc + ".methoddefs")44 ensureFileExists(DbLoc + ".functions")45 ensureFileExists(DbLoc + ".functiondefs")46def checkfamixL2Reqs(DbLoc):47 """ checks information requirements for Famix level 2"""...

Full Screen

Full Screen

test_originAttributesUpgrade.js

Source:test_originAttributesUpgrade.js Github

copy

Full Screen

...30 yield undefined;31 installPackage("originAttributesUpgrade_profile");32 info("Checking storage file");33 let storageFile = getRelativeFile(storageFileName);34 let exists = storageFile.exists();35 ok(!exists, "Storage file doesn't exist");36 info("Checking origin directories");37 for (let origin of origins) {38 let originDir = getRelativeFile(origin.path);39 exists = originDir.exists();40 ok(exists, "Origin directory does exist");41 let metadataFile = originDir.clone();42 metadataFile.append(metadataFileName);43 exists = metadataFile.exists();44 ok(exists, "Metadata file does exist");45 let metadata2File = originDir.clone();46 metadata2File.append(metadata2FileName);47 exists = metadata2File.exists();48 ok(!exists, "Metadata file doesn't exist");49 }50 info("Initializing");51 let request = init(continueToNextStepSync);52 yield undefined;53 ok(request.resultCode == NS_OK, "Initialization succeeded");54 exists = storageFile.exists();55 ok(exists, "Storage file does exist");56 info("Checking origin directories");57 for (let origin of origins) {58 let originDir = getRelativeFile(origin.path);59 exists = originDir.exists();60 if (origin.obsolete) {61 ok(!exists, "Origin directory doesn't exist");62 } else {63 ok(exists, "Origin directory does exist");64 let metadataFile = originDir.clone();65 metadataFile.append(metadataFileName);66 exists = metadataFile.exists();67 ok(exists, "Metadata file does exist");68 let metadata2File = originDir.clone();69 metadata2File.append(metadata2FileName);70 exists = metadata2File.exists();71 ok(exists, "Metadata file does exist");72 info("Initializing origin");73 let principal = getPrincipal(origin.url);74 request =75 initOrigin(principal, origin.persistence, continueToNextStepSync);76 yield undefined;77 ok(request.resultCode == NS_OK, "Initialization succeeded");78 ok(!request.result, "Origin directory wasn't created");79 }80 }81 finishTest();...

Full Screen

Full Screen

web3.eth.methods.js

Source:web3.eth.methods.js Github

copy

Full Screen

1var chai = require('chai');2var assert = chai.assert;3var Web3 = require('../index.js');4var web3 = new Web3();5var u = require('./helpers/test.utils.js');6var FakeHttpProvider = require('./helpers/FakeHttpProvider');7describe('web3.eth', function() {8 describe('methods', function() {9 // set dummy providor, to prevent error10 web3.setProvider(new FakeHttpProvider());11 u.methodExists(web3.eth, 'getBalance');12 u.methodExists(web3.eth, 'getStorageAt');13 u.methodExists(web3.eth, 'getTransactionCount');14 u.methodExists(web3.eth, 'getCode');15 u.methodExists(web3.eth, 'sendTransaction');16 u.methodExists(web3.eth, 'call');17 u.methodExists(web3.eth, 'getBlock');18 u.methodExists(web3.eth, 'getTransaction');19 u.methodExists(web3.eth, 'getUncle');20 u.methodExists(web3.eth, 'getBlockTransactionCount');21 u.methodExists(web3.eth, 'getBlockUncleCount');22 u.methodExists(web3.eth, 'filter');23 u.methodExists(web3.eth, 'contract');24 u.propertyExists(web3.eth, 'coinbase');25 u.propertyExists(web3.eth, 'mining');26 u.propertyExists(web3.eth, 'gasPrice');27 u.propertyExists(web3.eth, 'accounts');28 u.propertyExists(web3.eth, 'defaultBlock');29 u.propertyExists(web3.eth, 'blockNumber');30 u.propertyExists(web3.eth, 'protocolVersion');31 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { exists } from 'fast-check-monorepo'2import { exists } from 'fast-check'3import { exists } from 'fast-check-monorepo'4import { exists } from 'fast-check'5import { exists } from 'fast-check-monorepo'6import { exists } from 'fast-check'7import { exists } from 'fast-check-monorepo'8import { exists } from 'fast-check'9import { exists } from 'fast-check-monorepo'10import { exists } from 'fast-check'11import { exists } from 'fast-check-monorepo'12import { exists } from 'fast-check'13import { exists } from 'fast-check-monorepo'14import { exists } from 'fast-check'15import { exists } from 'fast-check-monorepo'16import { exists } from 'fast-check'17import { exists } from 'fast-check-monorepo'18import { exists } from 'fast-check'19import { exists } from 'fast-check-monorepo'20import { exists } from 'fast-check'

Full Screen

Using AI Code Generation

copy

Full Screen

1const { exists } = require('fast-check-monorepo');2if (exists(1, [1, 2, 3])) {3 console.log('1 exists in [1, 2, 3]');4} else {5 console.log('1 does not exist in [1, 2, 3]');6}7const { exists } = require('fast-check-monorepo');8if (exists(4, [1, 2, 3])) {9 console.log('4 exists in [1, 2, 3]');10} else {11 console.log('4 does not exist in [1, 2, 3]');12}13const { exists } = require('fast-check-monorepo');14if (exists(1, [1, 2, 3, 1])) {15 console.log('1 exists in [1, 2, 3, 1]');16} else {17 console.log('1 does not exist in [1, 2, 3, 1]');18}19const { exists } = require('fast-check-monorepo');20if (exists(1, [1, 2, 3, 1], 2)) {21 console.log('1 exists in [1, 2, 3, 1] from index 2');22} else {23 console.log('1 does not exist in [1, 2, 3, 1] from index 2');24}25const { exists } = require('fast-check-monorepo');26if (exists(1, [1, 2, 3, 1], 3)) {27 console.log('1 exists in [1,

Full Screen

Using AI Code Generation

copy

Full Screen

1const { exists } = require('fast-check-monorepo');2const { exists } = require('fast-check');3const { exists } = require('fast-check/lib/check/arbitrary/ExistsArbitrary');4const { exists } = require('fast-check/lib/check/arbitrary/ExistsArbitrary.js');5const { exists } = require('fast-check/lib/check/arbitrary/ExistsArbitrary.mjs');6const { exists } = require('fast-check/lib/check/arbitrary/ExistsArbitrary.cjs');7const { exists } = require('fast-check/lib/check/arbitrary/ExistsArbitrary.d.ts');8const { exists } = require('fast-check/lib/check/arbitrary/ExistsArbitrary.ts');9const { exists } = require('fast-check/lib/check/arbitrary/ExistsArbitrary.json');10const { exists } = require('fast-check/lib/check/arbitrary/ExistsArbitrary.json5');11const { exists } = require('fast-check/lib/check/arbitrary/ExistsArbitrary.yaml');

Full Screen

Using AI Code Generation

copy

Full Screen

1const exists = require('fast-check-monorepo').exists;2const assert = require('assert');3assert.ok(exists([1, 2, 3], 1));4const exists = require('fast-check-monorepo').exists;5const assert = require('assert');6assert.ok(exists([1, 2, 3], 1));7const exists = require('fast-check-monorepo').exists;8const assert = require('assert');9assert.ok(exists([1, 2, 3], 1));10const exists = require('fast-check-monorepo').exists;11const assert = require('assert');12assert.ok(exists([1, 2, 3], 1));13const exists = require('fast-check-monorepo').exists;14const assert = require('assert');15assert.ok(exists([1, 2, 3], 1));16const exists = require('fast-check-monorepo').exists;17const assert = require('assert');18assert.ok(exists([1, 2, 3], 1));19const exists = require('fast-check-monorepo').exists;20const assert = require('assert');21assert.ok(exists([1, 2, 3], 1));22const exists = require('fast-check-monorepo').exists;23const assert = require('assert');24assert.ok(exists([1, 2, 3], 1));25const exists = require('fast-check-monorepo').exists;26const assert = require('assert');27assert.ok(exists([1, 2, 3], 1));

Full Screen

Using AI Code Generation

copy

Full Screen

1import { exists } from 'fast-check';2if (exists({})) {3 console.log('exists');4} else {5 console.log('does not exist');6}7import { exists } from 'fast-check/lib/check/arbitrary/definition/ExistsArbitrary';8if (exists({})) {9 console.log('exists');10} else {11 console.log('does not exist');12}13The fast-check-monorepo package.json contains a dependency on fast-check. When you import from fast-check-monorepo, it will use the fast-check dependency. When

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check')2const exists = require('fast-check-monorepo/exists')3test('exists should work', () => {4 fc.assert(fc.property(fc.integer(), (n) => exists(n)))5})6{7 "dependencies": {8 },9 "devDependencies": {10 },11 "scripts": {12 },13}14{15 "packages": {16 "": {17 "dependencies": {18 "fast-check": {19 "requires": {20 }21 },22 "fast-check-monorepo": {

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fast-check-monorepo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful