How to use failure method in Playwright Python

Best Python code snippet using playwright-python

Run Playwright Python automation tests on LambdaTest cloud grid

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

test_failures.py

Source: test_failures.py Github

copy
1# Copyright (C) 2010 Google Inc. All rights reserved.
2#
3# Redistribution and use in source and binary forms, with or without
4# modification, are permitted provided that the following conditions are
5# met:
6#
7#     * Redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer.
9#     * Redistributions in binary form must reproduce the above
10# copyright notice, this list of conditions and the following disclaimer
11# in the documentation and/or other materials provided with the
12# distribution.
13#     * Neither the name of Google Inc. nor the names of its
14# contributors may be used to endorse or promote products derived from
15# this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
29import cPickle
30
31from webkitpy.layout_tests.models import test_expectations
32
33
34def is_reftest_failure(failure_list):
35    failure_types = [type(f) for f in failure_list]
36    return set((FailureReftestMismatch, FailureReftestMismatchDidNotOccur, FailureReftestNoImagesGenerated)).intersection(failure_types)
37
38# FIXME: This is backwards.  Each TestFailure subclass should know what
39# test_expectation type it corresponds too.  Then this method just
40# collects them all from the failure list and returns the worst one.
41def determine_result_type(failure_list):
42    """Takes a set of test_failures and returns which result type best fits
43    the list of failures. "Best fits" means we use the worst type of failure.
44
45    Returns:
46      one of the test_expectations result types - PASS, FAIL, CRASH, etc."""
47
48    if not failure_list or len(failure_list) == 0:
49        return test_expectations.PASS
50
51    failure_types = [type(f) for f in failure_list]
52    if FailureCrash in failure_types:
53        return test_expectations.CRASH
54    elif FailureLeak in failure_types:
55        return test_expectations.LEAK
56    elif FailureTimeout in failure_types:
57        return test_expectations.TIMEOUT
58    elif FailureEarlyExit in failure_types:
59        return test_expectations.SKIP
60    elif (FailureMissingResult in failure_types or
61          FailureMissingImage in failure_types or
62          FailureMissingImageHash in failure_types or
63          FailureMissingAudio in failure_types):
64        return test_expectations.MISSING
65    else:
66        is_text_failure = (FailureTextMismatch in failure_types or
67                           FailureTestHarnessAssertion in failure_types)
68        is_image_failure = (FailureImageHashIncorrect in failure_types or
69                            FailureImageHashMismatch in failure_types)
70        is_audio_failure = (FailureAudioMismatch in failure_types)
71        if is_text_failure and is_image_failure:
72            return test_expectations.IMAGE_PLUS_TEXT
73        elif is_text_failure:
74            return test_expectations.TEXT
75        elif is_image_failure or is_reftest_failure(failure_list):
76            return test_expectations.IMAGE
77        elif is_audio_failure:
78            return test_expectations.AUDIO
79        else:
80            raise ValueError("unclassifiable set of failures: "
81                             + str(failure_types))
82
83
84class TestFailure(object):
85    """Abstract base class that defines the failure interface."""
86
87    @staticmethod
88    def loads(s):
89        """Creates a TestFailure object from the specified string."""
90        return cPickle.loads(s)
91
92    def message(self):
93        """Returns a string describing the failure in more detail."""
94        raise NotImplementedError
95
96    def __eq__(self, other):
97        return self.__class__.__name__ == other.__class__.__name__
98
99    def __ne__(self, other):
100        return self.__class__.__name__ != other.__class__.__name__
101
102    def __hash__(self):
103        return hash(self.__class__.__name__)
104
105    def dumps(self):
106        """Returns the string/JSON representation of a TestFailure."""
107        return cPickle.dumps(self)
108
109    def driver_needs_restart(self):
110        """Returns True if we should kill the driver before the next test."""
111        return False
112
113
114class FailureTimeout(TestFailure):
115    def __init__(self, is_reftest=False):
116        super(FailureTimeout, self).__init__()
117        self.is_reftest = is_reftest
118
119    def message(self):
120        return "test timed out"
121
122    def driver_needs_restart(self):
123        return True
124
125
126class FailureCrash(TestFailure):
127    def __init__(self, is_reftest=False, process_name='content_shell', pid=None):
128        super(FailureCrash, self).__init__()
129        self.process_name = process_name
130        self.pid = pid
131        self.is_reftest = is_reftest
132
133    def message(self):
134        if self.pid:
135            return "%s crashed [pid=%d]" % (self.process_name, self.pid)
136        return self.process_name + " crashed"
137
138    def driver_needs_restart(self):
139        return True
140
141
142class FailureLeak(TestFailure):
143    def __init__(self, is_reftest=False, log=''):
144        super(FailureLeak, self).__init__()
145        self.is_reftest = is_reftest
146        self.log = log
147
148    def message(self):
149        return "leak detected: %s" % (self.log)
150
151
152class FailureMissingResult(TestFailure):
153    def message(self):
154        return "-expected.txt was missing"
155
156
157class FailureTestHarnessAssertion(TestFailure):
158    def message(self):
159        return "asserts failed"
160
161
162class FailureTextMismatch(TestFailure):
163    def message(self):
164        return "text diff"
165
166
167class FailureMissingImageHash(TestFailure):
168    def message(self):
169        return "-expected.png was missing an embedded checksum"
170
171
172class FailureMissingImage(TestFailure):
173    def message(self):
174        return "-expected.png was missing"
175
176
177class FailureImageHashMismatch(TestFailure):
178    def message(self):
179        return "image diff"
180
181
182class FailureImageHashIncorrect(TestFailure):
183    def message(self):
184        return "-expected.png embedded checksum is incorrect"
185
186
187class FailureReftestMismatch(TestFailure):
188    def __init__(self, reference_filename=None):
189        super(FailureReftestMismatch, self).__init__()
190        self.reference_filename = reference_filename
191
192    def message(self):
193        return "reference mismatch"
194
195
196class FailureReftestMismatchDidNotOccur(TestFailure):
197    def __init__(self, reference_filename=None):
198        super(FailureReftestMismatchDidNotOccur, self).__init__()
199        self.reference_filename = reference_filename
200
201    def message(self):
202        return "reference mismatch didn't happen"
203
204
205class FailureReftestNoImagesGenerated(TestFailure):
206    def __init__(self, reference_filename=None):
207        super(FailureReftestNoImagesGenerated, self).__init__()
208        self.reference_filename = reference_filename
209
210    def message(self):
211        return "reference didn't generate pixel results."
212
213
214class FailureMissingAudio(TestFailure):
215    def message(self):
216        return "expected audio result was missing"
217
218
219class FailureAudioMismatch(TestFailure):
220    def message(self):
221        return "audio mismatch"
222
223
224class FailureEarlyExit(TestFailure):
225    def message(self):
226        return "skipped due to early exit"
227
228
229# Convenient collection of all failure classes for anything that might
230# need to enumerate over them all.
231ALL_FAILURE_CLASSES = (FailureTimeout, FailureCrash, FailureMissingResult,
232                       FailureTestHarnessAssertion,
233                       FailureTextMismatch, FailureMissingImageHash,
234                       FailureMissingImage, FailureImageHashMismatch,
235                       FailureImageHashIncorrect, FailureReftestMismatch,
236                       FailureReftestMismatchDidNotOccur, FailureReftestNoImagesGenerated,
237                       FailureMissingAudio, FailureAudioMismatch,
238                       FailureEarlyExit)
239
Full Screen

failurereason.py

Source: failurereason.py Github

copy
1# -*- coding: utf-8 -*-
2# $Id: failurereason.py $
3
4"""
5Test Manager - Failure Reasons.
6"""
7
8__copyright__ = \
9"""
10Copyright (C) 2012-2015 Oracle Corporation
11
12This file is part of VirtualBox Open Source Edition (OSE), as
13available from http://www.virtualbox.org. This file is free software;
14you can redistribute it and/or modify it under the terms of the GNU
15General Public License (GPL) as published by the Free Software
16Foundation, in version 2 as it comes in the "COPYING" file of the
17VirtualBox OSE distribution. VirtualBox OSE is distributed in the
18hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
19
20The contents of this file may alternatively be used under the terms
21of the Common Development and Distribution License Version 1.0
22(CDDL) only, as it comes in the "COPYING.CDDL" file of the
23VirtualBox OSE distribution, in which case the provisions of the
24CDDL are applicable instead of those of the GPL.
25
26You may elect to license modified versions of this file under the
27terms and conditions of either the GPL or the CDDL or both.
28"""
29__version__ = "$Revision: 100880 $"
30
31
32# Validation Kit imports.
33from testmanager.core.base          import ModelDataBase, ModelLogicBase, TMExceptionBase
34
35
36class FailureReasonData(ModelDataBase):
37    """
38    Failure Reason Data.
39    """
40
41    ksIdAttr = 'idFailureReason';
42
43    ksParam_idFailureReason   = 'FailureReasonData_idFailureReason'
44    ksParam_tsEffective       = 'FailureReasonData_tsEffective'
45    ksParam_tsExpire          = 'FailureReasonData_tsExpire'
46    ksParam_uidAuthor         = 'FailureReasonData_uidAuthor'
47    ksParam_idFailureCategory = 'FailureReasonData_idFailureCategory'
48    ksParam_sShort            = 'FailureReasonData_sShort'
49    ksParam_sFull             = 'FailureReasonData_sFull'
50    ksParam_iTicket           = 'FailureReasonData_iTicket'
51    ksParam_asUrls            = 'FailureReasonData_asUrls'
52
53    kasAllowNullAttributes    = [ 'idFailureReason', 'tsEffective', 'tsExpire',
54                                  'uidAuthor',       'iTicket',      'asUrls' ]
55
56    def __init__(self):
57        ModelDataBase.__init__(self);
58
59        #
60        # Initialize with defaults.
61        # See the database for explanations of each of these fields.
62        #
63
64        self.idFailureReason   = None
65        self.tsEffective       = None
66        self.tsExpire          = None
67        self.uidAuthor         = None
68        self.idFailureCategory = None
69        self.sShort            = None
70        self.sFull             = None
71        self.iTicket           = None
72        self.asUrls            = None
73
74    def initFromDbRow(self, aoRow):
75        """
76        Re-initializes the data with a row from a SELECT * FROM FailureReasons.
77
78        Returns self. Raises exception if the row is None or otherwise invalid.
79        """
80
81        if aoRow is None:
82            raise TMExceptionBase('Failure Reason not found.');
83
84        self.idFailureReason   = aoRow[0]
85        self.tsEffective       = aoRow[1]
86        self.tsExpire          = aoRow[2]
87        self.uidAuthor         = aoRow[3]
88        self.idFailureCategory = aoRow[4]
89        self.sShort            = aoRow[5]
90        self.sFull             = aoRow[6]
91        self.iTicket           = aoRow[7]
92        self.asUrls            = aoRow[8]
93
94        return self
95
96
97class FailureReasonLogic(ModelLogicBase): # pylint: disable=R0903
98    """
99    Failure Reason logic.
100    """
101
102    def fetchForListing(self, iStart, cMaxRows, tsNow):
103        """
104        Fetches Failure Category records.
105
106        Returns an array (list) of FailureReasonData items, empty list if none.
107        Raises exception on error.
108        """
109
110        if tsNow is None:
111            self._oDb.execute('SELECT   *\n'
112                              'FROM     FailureReasons\n'
113                              'WHERE    tsExpire = \'infinity\'::TIMESTAMP\n'
114                              'ORDER BY idFailureReason DESC\n'
115                              'LIMIT %s OFFSET %s\n'
116                              , (cMaxRows, iStart,));
117        else:
118            self._oDb.execute('SELECT   *\n'
119                              'FROM     FailureReasons\n'
120                              'WHERE    tsExpire     > %s\n'
121                              '     AND tsEffective <= %s\n'
122                              'ORDER BY idFailureReason DESC\n'
123                              'LIMIT %s OFFSET %s\n'
124                              , (tsNow, tsNow, cMaxRows, iStart,));
125
126        aoRows = []
127        for aoRow in self._oDb.fetchAll():
128            aoRows.append(FailureReasonData().initFromDbRow(aoRow))
129        return aoRows
130
131    def fetchForCombo(self, tsEffective = None):
132        """
133        Gets the list of Failure Reasons for a combo box.
134        Returns an array of (value [idFailureReason], drop-down-name [sShort],
135        hover-text [sFull]) tuples.
136        """
137        if tsEffective is None:
138            self._oDb.execute('SELECT   idFailureReason, sShort, sFull\n'
139                              'FROM     FailureReasons\n'
140                              'WHERE    tsExpire = \'infinity\'::TIMESTAMP\n'
141                              'ORDER BY sShort')
142        else:
143            self._oDb.execute('SELECT   idFailureReason, sShort, sFull\n'
144                              'FROM     FailureReasons\n'
145                              'WHERE    tsExpire     > %s\n'
146                              '     AND tsEffective <= %s\n'
147                              'ORDER BY sShort'
148                              , (tsEffective, tsEffective))
149        return self._oDb.fetchAll()
150
151    def getById(self, idFailureReason):
152        """Get Failure Reason data by idFailureReason"""
153
154        self._oDb.execute('SELECT   *\n'
155                          'FROM     FailureReasons\n'
156                          'WHERE    tsExpire   = \'infinity\'::timestamp\n'
157                          '  AND    idFailureReason = %s;', (idFailureReason,))
158        aRows = self._oDb.fetchAll()
159        if len(aRows) not in (0, 1):
160            raise self._oDb.integrityException(
161                'Found more than one failure reasons with the same credentials. Database structure is corrupted.')
162        try:
163            return FailureReasonData().initFromDbRow(aRows[0])
164        except IndexError:
165            return None
166
167    def getIdsByCategory(self, idFailureCategory, tsEffective=None):
168        """
169        Gets the list of Failure Ressons IDs,
170        all the items belong to @param idFailureCategory
171        """
172        if tsEffective is None:
173            self._oDb.execute('SELECT   idFailureReason\n'
174                              'FROM     FailureReasons\n'
175                              'WHERE    tsExpire = \'infinity\'::TIMESTAMP\n'
176                              '     AND idFailureCategory = %s\n'
177                              'ORDER BY idFailureReason DESC'
178                              , (idFailureCategory,))
179        else:
180            self._oDb.execute('SELECT   idFailureReason\n'
181                              'FROM     FailureReasons\n'
182                              'WHERE    tsExpire     > %s\n'
183                              '     AND tsEffective <= %s\n'
184                              '     AND idFailureCategory = %s\n'
185                              'ORDER BY idFailureReason DESC'
186                              , (tsEffective, tsEffective, idFailureCategory))
187        return self._oDb.fetchAll()
188
189    def getAll(self, tsEffective=None):
190        """
191        Gets the list of all Failure Reasons.
192        Returns an array of FailureReasonData instances.
193        """
194        if tsEffective is None:
195            self._oDb.execute('SELECT   *\n'
196                              'FROM     FailureReasons\n'
197                              'WHERE    tsExpire = \'infinity\'::TIMESTAMP\n'
198                              'ORDER BY idFailureReason DESC')
199        else:
200            self._oDb.execute('SELECT   *\n'
201                              'FROM     FailureReasons\n'
202                              'WHERE    tsExpire     > %s\n'
203                              '     AND tsEffective <= %s\n'
204                              'ORDER BY idFailureReason DESC'
205                              , (tsEffective, tsEffective))
206        aoRet = []
207        for aoRow in self._oDb.fetchAll():
208            aoRet.append(FailureReasonData().initFromDbRow(aoRow))
209        return aoRet
210
211    def addEntry(self, oFailureReasonData, uidAuthor, fCommit=True):
212        """Add record to database"""
213
214        # Check if record with the same sShort fiels is already exists
215        self._oDb.execute('SELECT *\n'
216                          'FROM   FailureReasons\n'
217                          'WHERE  tsExpire   = \'infinity\'::TIMESTAMP\n'
218                          '   AND sShort = %s\n',
219                          (oFailureReasonData.sShort,))
220        if len(self._oDb.fetchAll()) != 0:
221            raise Exception('Record already exist')
222
223        # Add record
224        self._oDb.execute('INSERT INTO FailureReasons (\n'
225                          '  uidAuthor, idFailureCategory,'
226                          '  sShort, sFull, iTicket, asUrls'
227                          ')\n'
228                          'VALUES (%s, %s, %s, %s, %s, %s)',
229                          (uidAuthor,
230                           oFailureReasonData.idFailureCategory,
231                           oFailureReasonData.sShort,
232                           oFailureReasonData.sFull,
233                           oFailureReasonData.iTicket,
234                           oFailureReasonData.asUrls))
235        if fCommit:
236            self._oDb.commit()
237
238        return True
239
240    def remove(self, uidAuthor, idFailureReason, fNeedCommit=True):
241        """
242        Historize record
243        """
244        self._oDb.execute('UPDATE FailureReasons\n'
245                          'SET    tsExpire    = CURRENT_TIMESTAMP,\n'
246                          '       uidAuthor   = %s\n'
247                          'WHERE  idFailureReason = %s\n'
248                          '   AND tsExpire    = \'infinity\'::TIMESTAMP\n',
249                          (uidAuthor, idFailureReason))
250
251        # Also historize Black List records
252        self._oDb.execute('UPDATE BuildBlackList\n'
253                          'SET    tsExpire    = CURRENT_TIMESTAMP,\n'
254                          '       uidAuthor   = %s\n'
255                          'WHERE  idFailureReason = %s\n'
256                          '   AND tsExpire    = \'infinity\'::TIMESTAMP\n',
257                          (uidAuthor, idFailureReason))
258
259        if fNeedCommit:
260            self._oDb.commit()
261
262        return True
263
264    def editEntry(self, oFailureReasonData, uidAuthor, fCommit=True):
265        """Modify database record"""
266
267        # Check if record exists
268        oFailureReasonDataOld = self.getById(oFailureReasonData.idFailureReason)
269        if oFailureReasonDataOld is None:
270            raise TMExceptionBase(
271                'Failure Reason (id: %d) does not exist'
272                % oFailureReasonData.idFailureReason)
273
274        # Check if anything has been changed
275        if oFailureReasonData.isEqual(oFailureReasonDataOld):
276            return True
277
278        # Historize record
279        self.remove(
280            uidAuthor, oFailureReasonData.idFailureReason, fNeedCommit=False)
281
282
283        # Add new record (keeping its ID)
284        self._oDb.execute('INSERT INTO FailureReasons (\n'
285                          '  idFailureReason,'
286                          '  uidAuthor,'
287                          '  idFailureCategory,'
288                          '  sShort,'
289                          '  sFull,'
290                          '  iTicket,'
291                          '  asUrls'
292                          ')\n'
293                          'VALUES (%s, %s, %s, %s, %s, %s, %s)',
294                          (oFailureReasonData.idFailureReason,
295                           uidAuthor,
296                           oFailureReasonData.idFailureCategory,
297                           oFailureReasonData.sShort,
298                           oFailureReasonData.sFull,
299                           oFailureReasonData.iTicket,
300                           oFailureReasonData.asUrls
301                           ))
302
303        if fCommit:
304            self._oDb.commit()
305
306        return True
307
Full Screen

passport-providers.js

Source: passport-providers.js Github

copy
1var successRedirect = '/';
2var failureRedirect = '/signin';
3var linkFailureRedirect = '/account';
4module.exports = {
5  local: {
6    provider: 'local',
7    module: 'passport-local',
8    usernameField: 'email',
9    passwordField: 'password',
10    authPath: '/auth/local',
11    successRedirect: successRedirect,
12    failureRedirect: '/email-signin',
13    session: true,
14    failureFlash: true
15  },
16  'facebook-login': {
17    provider: 'facebook',
18    module: 'passport-facebook',
19    clientID: process.env.FACEBOOK_ID,
20    clientSecret: process.env.FACEBOOK_SECRET,
21    authPath: '/auth/facebook',
22    callbackURL: '/auth/facebook/callback',
23    callbackPath: '/auth/facebook/callback',
24    successRedirect: successRedirect,
25    failureRedirect: failureRedirect,
26    scope: ['email'],
27    failureFlash: true
28  },
29  'facebook-link': {
30    provider: 'facebook',
31    module: 'passport-facebook',
32    clientID: process.env.FACEBOOK_ID,
33    clientSecret: process.env.FACEBOOK_SECRET,
34    authPath: '/link/facebook',
35    callbackURL: '/link/facebook/callback',
36    callbackPath: '/link/facebook/callback',
37    successRedirect: successRedirect,
38    failureRedirect: linkFailureRedirect,
39    scope: ['email', 'user_likes'],
40    link: true,
41    failureFlash: true
42  },
43  'google-login': {
44    provider: 'google',
45    authScheme: 'oauth2',
46    module: 'passport-google-oauth2',
47    clientID: process.env.GOOGLE_ID,
48    clientSecret: process.env.GOOGLE_SECRET,
49    authPath: '/auth/google',
50    callbackURL: '/auth/google/callback',
51    callbackPath: '/auth/google/callback',
52    successRedirect: successRedirect,
53    failureRedirect: failureRedirect,
54    scope: ['email', 'profile'],
55    failureFlash: true
56  },
57  'google-link': {
58    provider: 'google',
59    authScheme: 'oauth2',
60    module: 'passport-google-oauth2',
61    clientID: process.env.GOOGLE_ID,
62    clientSecret: process.env.GOOGLE_SECRET,
63    authPath: '/link/google',
64    callbackURL: '/link/google/callback',
65    callbackPath: '/link/google/callback',
66    successRedirect: successRedirect,
67    failureRedirect: linkFailureRedirect,
68    scope: ['email', 'profile'],
69    link: true,
70    failureFlash: true
71  },
72  'twitter-login': {
73    provider: 'twitter',
74    authScheme: 'oauth',
75    module: 'passport-twitter',
76    authPath: '/auth/twitter',
77    callbackURL: '/auth/twitter/callback',
78    callbackPath: '/auth/twitter/callback',
79    successRedirect: successRedirect,
80    failureRedirect: failureRedirect,
81    consumerKey: process.env.TWITTER_KEY,
82    consumerSecret: process.env.TWITTER_SECRET,
83    failureFlash: true
84  },
85  'twitter-link': {
86    provider: 'twitter',
87    authScheme: 'oauth',
88    module: 'passport-twitter',
89    authPath: '/link/twitter',
90    callbackURL: '/link/twitter/callback',
91    callbackPath: '/link/twitter/callback',
92    successRedirect: successRedirect,
93    failureRedirect: linkFailureRedirect,
94    consumerKey: process.env.TWITTER_KEY,
95    consumerSecret: process.env.TWITTER_SECRET,
96    link: true,
97    failureFlash: true
98  },
99  'linkedin-login': {
100    provider: 'linkedin',
101    authScheme: 'oauth2',
102    module: 'passport-linkedin-oauth2',
103    authPath: '/auth/linkedin',
104    callbackURL: '/auth/linkedin/callback',
105    callbackPath: '/auth/linkedin/callback',
106    successRedirect: successRedirect,
107    failureRedirect: failureRedirect,
108    clientID: process.env.LINKEDIN_ID,
109    clientSecret: process.env.LINKEDIN_SECRET,
110    scope: ['r_basicprofile', 'r_emailaddress'],
111    authOptions: {
112      state: process.env.LINKEDIN_STATE
113    },
114    failureFlash: true
115  },
116  'linkedin-link': {
117    provider: 'linkedin',
118    authScheme: 'oauth2',
119    module: 'passport-linkedin-oauth2',
120    authPath: '/link/linkedin',
121    callbackURL: '/link/linkedin/callback',
122    callbackPath: '/link/linkedin/callback',
123    successRedirect: successRedirect,
124    failureRedirect: linkFailureRedirect,
125    clientID: process.env.LINKEDIN_ID,
126    clientSecret: process.env.LINKEDIN_SECRET,
127    scope: ['r_basicprofile', 'r_emailaddress'],
128    authOptions: {
129      state: process.env.LINKEDIN_STATE
130    },
131    link: true,
132    failureFlash: true
133  },
134  'github-login': {
135    provider: 'github',
136    authScheme: 'oauth2',
137    module: 'passport-github',
138    authPath: '/auth/github',
139    callbackURL: '/auth/github/callback',
140    callbackPath: '/auth/github/callback',
141    successRedirect: successRedirect,
142    failureRedirect: failureRedirect,
143    clientID: process.env.GITHUB_ID,
144    clientSecret: process.env.GITHUB_SECRET,
145    scope: ['email'],
146    failureFlash: true
147  },
148  'github-link': {
149    provider: 'github',
150    authScheme: 'oauth2',
151    module: 'passport-github',
152    authPath: '/link/github',
153    callbackURL: '/auth/github/callback/link',
154    callbackPath: '/auth/github/callback/link',
155    successRedirect: successRedirect,
156    failureRedirect: linkFailureRedirect,
157    clientID: process.env.GITHUB_ID,
158    clientSecret: process.env.GITHUB_SECRET,
159    scope: ['email'],
160    link: true,
161    failureFlash: true
162  }
163};
164
Full Screen

bluetoothSerial.js

Source: bluetoothSerial.js Github

copy
1/*global cordova*/
2module.exports = {
3
4    connect: function (macAddress, success, failure) {
5        cordova.exec(success, failure, "BluetoothSerial", "connect", [macAddress]);
6    },
7
8    // Android only - see http://goo.gl/1mFjZY
9    connectInsecure: function (macAddress, success, failure) {
10        cordova.exec(success, failure, "BluetoothSerial", "connectInsecure", [macAddress]);
11    },
12
13    disconnect: function (success, failure) {
14        cordova.exec(success, failure, "BluetoothSerial", "disconnect", []);
15    },
16
17    // list bound devices
18    list: function (success, failure) {
19        cordova.exec(success, failure, "BluetoothSerial", "list", []);
20    },
21
22    isEnabled: function (success, failure) {
23        cordova.exec(success, failure, "BluetoothSerial", "isEnabled", []);
24    },
25
26    isConnected: function (success, failure) {
27        cordova.exec(success, failure, "BluetoothSerial", "isConnected", []);
28    },
29
30    // the number of bytes of data available to read is passed to the success function
31    available: function (success, failure) {
32        cordova.exec(success, failure, "BluetoothSerial", "available", []);
33    },
34
35    // read all the data in the buffer
36    read: function (success, failure) {
37        cordova.exec(success, failure, "BluetoothSerial", "read", []);
38    },
39
40    // reads the data in the buffer up to and including the delimiter
41    readUntil: function (delimiter, success, failure) {
42        cordova.exec(success, failure, "BluetoothSerial", "readUntil", [delimiter]);
43    },
44
45    // writes data to the bluetooth serial port - data must be a string
46    write: function (data, success, failure) {
47        cordova.exec(success, failure, "BluetoothSerial", "write", [data]);
48    },
49
50    // calls the success callback when new data is available
51    subscribe: function (delimiter, success, failure) {
52        cordova.exec(success, failure, "BluetoothSerial", "subscribe", [delimiter]);
53    },
54    
55    // removes data subscription
56    unsubscribe: function (success, failure) {
57        cordova.exec(success, failure, "BluetoothSerial", "unsubscribe", []);
58    },
59
60    // clears the data buffer
61    clear: function (success, failure) {
62        cordova.exec(success, failure, "BluetoothSerial", "clear", []);
63    },
64    
65    // reads the RSSI of the *connected* peripherial
66    readRSSI: function (success, failure) {
67        cordova.exec(success, failure, "BluetoothSerial", "readRSSI", []);        
68    }
69
70};
71
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run Python Tests on LambdaTest Cloud Grid

Execute automation tests with Playwright Python on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)