Merge branch '7-login-error'
This commit is contained in:
commit
5281e9595e
|
@ -34,6 +34,8 @@ class OrchestraModel:
|
|||
Args:
|
||||
data: A JSON dict, as converted from the JSON in the orchestra API.
|
||||
"""
|
||||
if data is None:
|
||||
return cls()
|
||||
|
||||
json_data = data.copy()
|
||||
if kwargs:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from collections import defaultdict
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
|
@ -5,22 +6,28 @@ def getsetting(name):
|
|||
value = getattr(settings, name, None)
|
||||
return value or DEFAULTS.get(name)
|
||||
|
||||
# provide a default value allowing to overwrite it for each type of account
|
||||
def allowed_resources_default_factory():
|
||||
return {'mailbox': 2}
|
||||
|
||||
DEFAULTS = {
|
||||
# allowed resources limit hardcoded because cannot be retrieved from the API.
|
||||
"ALLOWED_RESOURCES": {
|
||||
'INDIVIDUAL':
|
||||
"ALLOWED_RESOURCES": defaultdict(
|
||||
allowed_resources_default_factory,
|
||||
{
|
||||
# 'disk': 1024,
|
||||
# 'traffic': 2048,
|
||||
'mailbox': 2,
|
||||
},
|
||||
'ASSOCIATION': {
|
||||
# 'disk': 5 * 1024,
|
||||
# 'traffic': 20 * 1024,
|
||||
'mailbox': 10,
|
||||
'INDIVIDUAL':
|
||||
{
|
||||
# 'disk': 1024,
|
||||
# 'traffic': 2048,
|
||||
'mailbox': 2,
|
||||
},
|
||||
'ASSOCIATION': {
|
||||
# 'disk': 5 * 1024,
|
||||
# 'traffic': 20 * 1024,
|
||||
'mailbox': 10,
|
||||
}
|
||||
}
|
||||
},
|
||||
),
|
||||
"URL_DB_PHPMYADMIN": "https://phpmyadmin.pangea.org/",
|
||||
"URL_MAILTRAIN": "https://mailtrain.org/",
|
||||
"URL_SAAS_GITLAB": "https://gitlab.pangea.org/",
|
||||
|
|
|
@ -62,6 +62,31 @@ class UserAccountTest(TestCase):
|
|||
account = UserAccount.new_from_json(data)
|
||||
self.assertIsNone(account.last_login)
|
||||
|
||||
def test_user_without_billcontact(self):
|
||||
data = {
|
||||
'billcontact': None,
|
||||
'date_joined': '2020-03-05T09:49:21Z',
|
||||
'full_name': 'David Rock',
|
||||
'id': 2,
|
||||
'is_active': True,
|
||||
'language': 'CA',
|
||||
'last_login': '2020-03-19T10:21:49.504266Z',
|
||||
'resources': [{'allocated': None,
|
||||
'name': 'disk',
|
||||
'unit': 'GiB',
|
||||
'used': '0.000'},
|
||||
{'allocated': None,
|
||||
'name': 'traffic',
|
||||
'unit': 'GiB',
|
||||
'used': '0.000'}],
|
||||
'short_name': '',
|
||||
'type': 'STAFF',
|
||||
'url': 'https://example.org/api/accounts/2/',
|
||||
'username': 'drock'
|
||||
}
|
||||
account = UserAccount.new_from_json(data)
|
||||
self.assertIsNotNone(account.billing)
|
||||
|
||||
|
||||
class GetBootstrapedPercentTest(TestCase):
|
||||
BS_WIDTH = [0, 25, 50, 100]
|
||||
|
|
Loading…
Reference in a new issue