Skip to content
This repository has been archived by the owner on Jul 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #18 from AusDTO/supplier-id
Browse files Browse the repository at this point in the history
Supplier ID -> Supplier Code
  • Loading branch information
sarneaud authored Aug 16, 2016
2 parents a72e1f0 + 0223206 commit b6a3c97
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
8 changes: 4 additions & 4 deletions dmutils/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def upload_document(uploader, documents_url, service, field, file_contents, publ
:param uploader: S3 uploader object
:param documents_url: base assets URL used as root for creating the full
document URL.
:param service: service object used to look up service and supplier id
:param service: service object used to look up service and supplier code
for the generated document name
:param field: name of the service field that the document URL is saved to,
used to generate the document name
Expand All @@ -78,7 +78,7 @@ def upload_document(uploader, documents_url, service, field, file_contents, publ
file_path = generate_file_name(
service['frameworkSlug'],
uploader.bucket_short_name,
service['supplierId'],
service['supplierCode'],
service['id'],
field,
file_contents.filename
Expand Down Expand Up @@ -174,7 +174,7 @@ def file_is_image(file_object):
]


def generate_file_name(framework_slug, bucket_short_name, supplier_id, service_id, field, filename, suffix=None):
def generate_file_name(framework_slug, bucket_short_name, supplier_code, service_id, field, filename, suffix=None):
if suffix is None:
suffix = default_file_suffix()

Expand All @@ -188,7 +188,7 @@ def generate_file_name(framework_slug, bucket_short_name, supplier_id, service_i
return '{}/{}/{}/{}-{}-{}{}'.format(
framework_slug,
bucket_short_name,
supplier_id,
supplier_code,
service_id,
ID_TO_FILE_NAME_SUFFIX[field],
suffix,
Expand Down
12 changes: 6 additions & 6 deletions dmutils/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ def user_has_role(user, role):


class User():
def __init__(self, user_id, email_address, supplier_id, supplier_name,
def __init__(self, user_id, email_address, supplier_code, supplier_name,
locked, active, name, role):
self.id = user_id
self.email_address = email_address
self.name = name
self.role = role
self.supplier_id = supplier_id
self.supplier_code = supplier_code
self.supplier_name = supplier_name
self.locked = locked
self.active = active
Expand Down Expand Up @@ -67,23 +67,23 @@ def serialize(self):
'id': self.id,
'name': self.name,
'emailAddress': self.email_address,
'supplierId': self.supplier_id,
'supplierCode': self.supplier_code,
'supplierName': self.supplier_name,
'locked': self.locked,
}

@staticmethod
def from_json(user_json):
user = user_json["users"]
supplier_id = None
supplier_code = None
supplier_name = None
if "supplier" in user:
supplier_id = user["supplier"]["supplierId"]
supplier_code = user["supplier"]["supplierCode"]
supplier_name = user["supplier"]["name"]
return User(
user_id=user["id"],
email_address=user['emailAddress'],
supplier_id=supplier_id,
supplier_code=supplier_code,
supplier_name=supplier_name,
locked=user.get('locked', False),
active=user.get('active', True),
Expand Down
12 changes: 6 additions & 6 deletions tests/test_documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def test_document_upload(self):
upload_document(
uploader,
'http://assets',
{'id': "123", 'supplierId': 5, 'frameworkSlug': 'g-cloud-6'},
{'id': "123", 'supplierCode': 5, 'frameworkSlug': 'g-cloud-6'},
"pricingDocumentURL",
mock_file('file.pdf', 1)
),
Expand All @@ -165,7 +165,7 @@ def test_document_private_upload(self):
upload_document(
uploader,
'http://assets',
{'id': "123", 'supplierId': 5, 'frameworkSlug': 'g-cloud-6'},
{'id': "123", 'supplierCode': 5, 'frameworkSlug': 'g-cloud-6'},
"pricingDocumentURL",
mock_file('file.pdf', 1),
public=False
Expand All @@ -186,7 +186,7 @@ def test_document_upload_s3_error(self):
self.assertFalse(upload_document(
uploader,
'http://assets',
{'id': "123", 'supplierId': 5, 'frameworkSlug': 'g-cloud-6'},
{'id': "123", 'supplierCode': 5, 'frameworkSlug': 'g-cloud-6'},
"pricingDocumentURL",
mock_file('file.pdf', 1)
))
Expand All @@ -198,7 +198,7 @@ def test_document_upload_with_other_bucket_short_name(self):
upload_document(
uploader,
'http://assets',
{'id': "123", 'supplierId': 5, 'frameworkSlug': 'g-cloud-6'},
{'id': "123", 'supplierCode': 5, 'frameworkSlug': 'g-cloud-6'},
"pricingDocumentURL",
mock_file('file.pdf', 1)
),
Expand All @@ -218,7 +218,7 @@ def test_document_upload_with_invalid_short_bucket_name(self):
upload_document(
uploader,
'http://assets',
{'id': "123", 'supplierId': 5, 'frameworkSlug': 'g-cloud-6'},
{'id': "123", 'supplierCode': 5, 'frameworkSlug': 'g-cloud-6'},
"pricingDocumentURL",
mock_file('file.pdf', 1)
),
Expand All @@ -234,7 +234,7 @@ def setup(self):
self.section.get_question_ids.return_value = ['pricingDocumentURL']
self.service = {
'frameworkSlug': 'g-cloud-7',
'supplierId': '12345',
'supplierCode': '12345',
'id': '654321',
}
self.uploader = mock.Mock(bucket_short_name='documents')
Expand Down
6 changes: 3 additions & 3 deletions tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def user_json():
"locked": False,
"active": True,
"supplier": {
"supplierId": 321,
"supplierCode": 321,
"name": "test supplier",
}
}
Expand Down Expand Up @@ -76,15 +76,15 @@ def test_User_from_json_with_supplier():
'locked': False,
'active': True,
'supplier': {
'supplierId': 321,
'supplierCode': 321,
'name': 'test supplier',
}
}})
assert user.id == 123
assert user.name == 'Name'
assert user.role == 'supplier'
assert user.email_address == '[email protected]'
assert user.supplier_id == 321
assert user.supplier_code == 321
assert user.supplier_name == 'test supplier'


Expand Down

0 comments on commit b6a3c97

Please sign in to comment.