Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
0
gaia/tests/python/gaia-ui-tests/gaiatest/mocks/__init__.py
Executable file
0
gaia/tests/python/gaia-ui-tests/gaiatest/mocks/__init__.py
Executable file
31
gaia/tests/python/gaia-ui-tests/gaiatest/mocks/mock_call.py
Executable file
31
gaia/tests/python/gaia-ui-tests/gaiatest/mocks/mock_call.py
Executable file
|
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import time, datetime
|
||||
|
||||
|
||||
class MockCall(dict):
|
||||
|
||||
def __init__(self, phone_number=None, call_type='incoming', date=datetime.date.today(), duration=1,
|
||||
status='cancelled', serviceId=0, emergency=False, voicemail=False, **kwargs):
|
||||
super(MockCall, self).__init__(self, **kwargs)
|
||||
|
||||
current_time = repr(time.time()).replace('.', '')
|
||||
self['number'] = phone_number if phone_number is not None else '555%s' % current_time[-7:]
|
||||
self['type'] = call_type
|
||||
self['date'] = time.mktime(date.timetuple())*1000
|
||||
self['duration'] = duration
|
||||
self['serviceId'] = serviceId
|
||||
self['status'] = status
|
||||
self['emergency'] = emergency
|
||||
self['voicemail'] = voicemail
|
||||
|
||||
# update with any keyword arguments passed
|
||||
self.update(**kwargs)
|
||||
|
||||
# allow getting items as if they were attributes
|
||||
def __getattr__(self, attr):
|
||||
return self[attr]
|
||||
121
gaia/tests/python/gaia-ui-tests/gaiatest/mocks/mock_contact.py
Executable file
121
gaia/tests/python/gaia-ui-tests/gaiatest/mocks/mock_contact.py
Executable file
|
|
@ -0,0 +1,121 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import time
|
||||
|
||||
|
||||
class MockContact(dict):
|
||||
'''
|
||||
Mocks a contact conforming to the Mozilla contacts API as a dictionary
|
||||
of contact properties.
|
||||
|
||||
Object properties containing sub-properties are themselves dictionaries.
|
||||
|
||||
Properties containing multiple values should be lists, but single instances
|
||||
of a property are not required to be lists for convenience.
|
||||
|
||||
The properites created by default are: givenName, familyName, name, email,
|
||||
tel, adr, note.
|
||||
'''
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super(MockContact, self).__init__(self, **kwargs)
|
||||
|
||||
# Set default values
|
||||
curr_time = repr(time.time()).replace('.', '')
|
||||
self['givenName'] = 'gaia%s' % curr_time[10:]
|
||||
self['familyName'] = 'test'
|
||||
self['name'] = '%s %s' % (self['givenName'], self['familyName'])
|
||||
self['email'] = {
|
||||
'type': 'Personal',
|
||||
'value': '%s@restmail.net' % self['givenName']}
|
||||
self['tel'] = {
|
||||
'type': 'Mobile',
|
||||
'value': '555%s' % curr_time[8:]}
|
||||
self['adr'] = {
|
||||
'type': 'Home',
|
||||
'streetAddress': '101 Testing street',
|
||||
'postalCode': '90210',
|
||||
'locality': 'London',
|
||||
'countryName': 'UK'}
|
||||
self['note'] = 'Gaia automated test'
|
||||
|
||||
# Update with any keyword arguments passed. Note that the __init__ call
|
||||
# above does not call update and so it must be done seperately
|
||||
self.update(**kwargs)
|
||||
|
||||
# Allow getting items as if they were attributes
|
||||
def __getattr__(self, attr):
|
||||
return self[attr]
|
||||
|
||||
# Remove key when passing None values
|
||||
def update(self, *args, **kwargs):
|
||||
dict.update(self, *args, **kwargs)
|
||||
d = self.copy()
|
||||
for k,v in d.iteritems():
|
||||
if v is None:
|
||||
del self[k]
|
||||
|
||||
def create_mozcontact(self):
|
||||
"""
|
||||
Returns the MockContact dictionary in a format compatible with the
|
||||
MozContact API.
|
||||
|
||||
To be compatible with the MozContact API all properties are converted
|
||||
to arrays (lists in Python) where required. Note that for object
|
||||
properties with sub-properties (ex: the 'tel' property), only the
|
||||
'type' sub-property must be an array.
|
||||
"""
|
||||
mozcontact = {}
|
||||
for key in self.iterkeys():
|
||||
# Handle a MockContact property already in mozcontact format
|
||||
if self.is_mozcontact_api_format(self[key]):
|
||||
mozcontact[key] = self[key]
|
||||
else:
|
||||
# All mozcontact properties must be arrays (lists in Python)
|
||||
if not isinstance(self[key], list):
|
||||
mozcontact[key] = [self[key]]
|
||||
else:
|
||||
mozcontact[key] = self[key]
|
||||
# A property that is a dictionary represents an object with
|
||||
# sub-properties. Create mozcontact compliant objects.
|
||||
if isinstance(mozcontact[key][0], dict):
|
||||
mozcontact[key] = [self._create_mozcontact_object(obj)
|
||||
for obj in mozcontact[key]]
|
||||
return mozcontact
|
||||
|
||||
@staticmethod
|
||||
def is_mozcontact_api_format(prop):
|
||||
"""
|
||||
Determines if a property is compliant with the MozContact API.
|
||||
"""
|
||||
# All mozcontact properties must be arrays (lists in Python)
|
||||
if not isinstance(prop, list):
|
||||
return False
|
||||
# Search for any object properties with sub-properties to verify
|
||||
for obj in prop:
|
||||
# A property that is a dictionary represents an object with
|
||||
# sub-properties.
|
||||
if isinstance(obj, dict):
|
||||
for key in obj.iterkeys():
|
||||
# Only an object's type property should be a list
|
||||
if key == 'type' and not isinstance(obj[key], list):
|
||||
return False
|
||||
elif key != 'type' and isinstance(obj[key], list):
|
||||
return False
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def _create_mozcontact_object(obj):
|
||||
"""
|
||||
Returns a MockContact object property (dictionary) compatible with the
|
||||
MozContact API.
|
||||
"""
|
||||
mozobj = obj.copy()
|
||||
# Only an object's type property needs to be a list
|
||||
if 'type' in mozobj.keys() and not isinstance(mozobj['type'], list):
|
||||
mozobj['type'] = [mozobj['type']]
|
||||
return mozobj
|
||||
22
gaia/tests/python/gaia-ui-tests/gaiatest/mocks/mock_email.py
Executable file
22
gaia/tests/python/gaia-ui-tests/gaiatest/mocks/mock_email.py
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import time
|
||||
|
||||
|
||||
class MockEmail(dict):
|
||||
|
||||
def __init__(self, sender, recipient, **kwargs):
|
||||
current_time = time.time()
|
||||
self['from'] = sender
|
||||
self['to'] = recipient
|
||||
self['subject'] = 'Test email subject %s' % current_time
|
||||
self['message'] = 'Test email message %s' % current_time
|
||||
self.update(**kwargs)
|
||||
|
||||
# allow getting items as if they were attributes
|
||||
def __getattr__(self, attr):
|
||||
return self[attr]
|
||||
22
gaia/tests/python/gaia-ui-tests/gaiatest/mocks/mock_user.py
Executable file
22
gaia/tests/python/gaia-ui-tests/gaiatest/mocks/mock_user.py
Executable file
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
|
||||
class MockUser(dict):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
# set your default values
|
||||
import time
|
||||
self['name'] = 'marketplace_%s' % repr(time.time()).replace('.', '')
|
||||
self['email'] = '%s@restmail.net' % self['name']
|
||||
self['password'] = 'Password12345'
|
||||
|
||||
# update with any keyword arguments passed
|
||||
self.update(**kwargs)
|
||||
|
||||
# allow getting items as if they were attributes
|
||||
def __getattr__(self, attr):
|
||||
return self[attr]
|
||||
60
gaia/tests/python/gaia-ui-tests/gaiatest/mocks/persona_test_user.py
Executable file
60
gaia/tests/python/gaia-ui-tests/gaiatest/mocks/persona_test_user.py
Executable file
|
|
@ -0,0 +1,60 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import urllib2
|
||||
import json
|
||||
from gaiatest.mocks.mock_user import MockUser
|
||||
|
||||
|
||||
class PersonaTestUser:
|
||||
"""
|
||||
A base test class that can be extended by other tests to include utility methods.
|
||||
API docs: https://github.com/mozilla/personatestuser.org#api
|
||||
|
||||
Usage:
|
||||
verified = bool:
|
||||
Verified refers to the user's account and password already approved and set up
|
||||
|
||||
env = str:
|
||||
Strings "dev", "stage" or "prod" will return users for the respective environments
|
||||
If "None" a production Persona user will be returned.
|
||||
|
||||
env = dict:
|
||||
For custom browserid databases and verifiers
|
||||
self.user = PersonaTestUser().create_user(verified=True,
|
||||
env={"browserid":"firefoxos.persona.org", "verifier":"firefoxos.123done.org"})
|
||||
|
||||
"""
|
||||
|
||||
def create_user(self, verified=False, env=None):
|
||||
|
||||
if verified:
|
||||
url = "http://personatestuser.org/email/"
|
||||
else:
|
||||
url = "http://personatestuser.org/unverified_email/"
|
||||
|
||||
if type(env) is str:
|
||||
url += env
|
||||
|
||||
elif type(env) is dict:
|
||||
url += "custom?"
|
||||
for index, i in enumerate(env):
|
||||
if index > 0:
|
||||
url += "&"
|
||||
url += "%s=%s" % (i, env[i])
|
||||
|
||||
try:
|
||||
# ptu.org will fail with a 400 if the parameters are invalid
|
||||
response = urllib2.urlopen(url)
|
||||
except urllib2.URLError as e:
|
||||
raise Exception("Could not get Persona user from personatestuser.org: %s" % e.reason)
|
||||
|
||||
decode = json.loads(response.read())
|
||||
|
||||
try:
|
||||
return MockUser(email=decode['email'], password=decode['pass'], name=decode['email'].split('@')[0])
|
||||
except KeyError:
|
||||
raise Exception("Could not get Persona user from personatestuser.org: %s" % decode)
|
||||
Loading…
Reference in a new issue