Skip to content

Commit

Permalink
fix tests (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
domdinicola authored Jan 30, 2020
1 parent fb30fa6 commit 658f6f6
Show file tree
Hide file tree
Showing 10 changed files with 187 additions and 131 deletions.
2 changes: 1 addition & 1 deletion src/donor_reporting_portal/api/serializers/sharepoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def get_download_url(self, obj):
return f'{settings.HOST}{relative_url}'

def get_is_new(self, obj):
modified = datetime.strptime(obj.properties['Modified'], '%Y-%m-%dT%H:%M:%Sz')
modified = datetime.strptime(obj.properties['Modified'][:19], '%Y-%m-%dT%H:%M:%S')
day_difference = (modified - datetime.now()).days
return True if day_difference <= 7 else False

Expand Down
6 changes: 3 additions & 3 deletions tests/api/_api_checker/test_sharepoint/donor.fixture.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"donor": {
"master": {
"model": "report_metadata.donor",
"pk": 101,
"pk": 67,
"fields": {
"created": "2020-01-28T20:26:18.110Z",
"modified": "2020-01-28T20:26:18.110Z",
"created": "2020-01-30T19:40:45.592Z",
"modified": "2020-01-30T19:40:45.592Z",
"name": "Australia",
"code": "G02701",
"us_gov": false
Expand Down
22 changes: 11 additions & 11 deletions tests/api/_api_checker/test_sharepoint/library.fixture.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@
"library": {
"master": {
"model": "sharepoint.sharepointlibrary",
"pk": 16,
"pk": 2,
"fields": {
"created": "2020-01-28T20:26:18.100Z",
"modified": "2020-01-28T20:26:18.100Z",
"created": "2020-01-30T19:40:45.581Z",
"modified": "2020-01-30T19:40:45.581Z",
"name": "2019 Certified Reports",
"site": 16,
"site": 2,
"active": true,
"require_donor_permission": true
}
},
"deps": [
{
"model": "sharepoint.sharepointsite",
"pk": 16,
"pk": 2,
"fields": {
"created": "2020-01-28T20:26:18.092Z",
"modified": "2020-01-28T20:26:18.092Z",
"tenant": 16,
"created": "2020-01-30T19:40:45.567Z",
"modified": "2020-01-30T19:40:45.567Z",
"tenant": 2,
"name": "GLB-DRP",
"site_type": "sites"
}
},
{
"model": "sharepoint.sharepointtenant",
"pk": 16,
"pk": 2,
"fields": {
"created": "2020-01-28T20:26:18.083Z",
"modified": "2020-01-28T20:26:18.083Z",
"created": "2020-01-30T19:40:45.561Z",
"modified": "2020-01-30T19:40:45.561Z",
"url": "https://unitst.sharepoint.com/",
"username": null,
"password": null
Expand Down
14 changes: 7 additions & 7 deletions tests/api/_api_checker/test_sharepoint/site.fixture.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
"site": {
"master": {
"model": "sharepoint.sharepointsite",
"pk": 16,
"pk": 2,
"fields": {
"created": "2020-01-28T20:26:18.092Z",
"modified": "2020-01-28T20:26:18.092Z",
"tenant": 16,
"created": "2020-01-30T19:40:45.567Z",
"modified": "2020-01-30T19:40:45.567Z",
"tenant": 2,
"name": "GLB-DRP",
"site_type": "sites"
}
},
"deps": [
{
"model": "sharepoint.sharepointtenant",
"pk": 16,
"pk": 2,
"fields": {
"created": "2020-01-28T20:26:18.083Z",
"modified": "2020-01-28T20:26:18.083Z",
"created": "2020-01-30T19:40:45.561Z",
"modified": "2020-01-30T19:40:45.561Z",
"url": "https://unitst.sharepoint.com/",
"username": null,
"password": null
Expand Down
6 changes: 3 additions & 3 deletions tests/api/_api_checker/test_sharepoint/tenant.fixture.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"tenant": {
"master": {
"model": "sharepoint.sharepointtenant",
"pk": 16,
"pk": 2,
"fields": {
"created": "2020-01-28T20:26:18.083Z",
"modified": "2020-01-28T20:26:18.083Z",
"created": "2020-01-30T19:40:45.561Z",
"modified": "2020-01-30T19:40:45.561Z",
"url": "https://unitst.sharepoint.com/",
"username": null,
"password": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
],
"content-length": [
"Content-Length",
"1010"
"2047"
]
},
"data": [
Expand Down Expand Up @@ -49,7 +49,37 @@
"report_status": "New",
"retracted": null,
"resource_url": "https://unitst.sharepoint.com/sites/GLB-DRP/_api/Web/lists/GetByTitle('2019 Certified Reports')/items/getItemById(198)",
"download_url": "http://localhost:8000/api/sharepoint/unitst/GLB-DRP/2019%20Certified%20Reports/files/CertifiedDonorStatement_CSACC_SC170311_31122019__ext__pdf/download/"
"download_url": "http://localhost:8000/api/sharepoint/unitst/GLB-DRP/2019%20Certified%20Reports/files/CertifiedDonorStatement_CSACC_SC170311_31122019__ext__pdf/download/",
"is_new": true
},
{
"id": 351,
"guid": "bbe8ec3b-a833-4706-8d2b-ca156ce63253",
"created": "2020-01-29T20:28:49Z",
"modified": "2020-01-29T20:28:50Z",
"report_generated_by": "aavacaflores",
"title": "CertifiedDonorStatement_CSACC_SC170311_29012019.pdf",
"donor": "Australia",
"donor_code": "G02701",
"grant_number": "SC170311",
"grant_issue_year": "2017",
"grant_expiry_date": "2018-06-30T11:00:00Z",
"external_reference": "72410/05",
"recipient_office": [
"Fiji (Pacific Islands)"
],
"report_type": "Interim",
"report_end_date": "2019-01-29T11:00:00Z",
"theme": null,
"donor_document": "Certified Statement of Account",
"donor_report_category": "Donor Financial Certified",
"report_method": "Auto",
"report_group": "Grant",
"report_status": "New",
"retracted": null,
"resource_url": "https://unitst.sharepoint.com/sites/GLB-DRP/_api/Web/lists/GetByTitle('2019 Certified Reports')/items/getItemById(351)",
"download_url": "http://localhost:8000/api/sharepoint/unitst/GLB-DRP/2019%20Certified%20Reports/files/CertifiedDonorStatement_CSACC_SC170311_29012019__ext__pdf/download/",
"is_new": true
}
],
"content_type": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
],
"content-length": [
"Content-Length",
"1006"
"2039"
]
},
"data": [
Expand Down Expand Up @@ -49,7 +49,37 @@
"report_status": "New",
"retracted": null,
"resource_url": "https://unitst.sharepoint.com/sites/GLB-DRP/_api/Web/lists/GetByTitle('2019 Certified Reports')/items/getItemById(198)",
"download_url": "http://localhost:8000/api/sharepoint/unitst/GLB-DRP/2019%20Certified%20Reports/files/CertifiedDonorStatement_CSACC_SC170311_31122019__ext__pdf/download/"
"download_url": "http://localhost:8000/api/sharepoint/unitst/GLB-DRP/2019%20Certified%20Reports/files/CertifiedDonorStatement_CSACC_SC170311_31122019__ext__pdf/download/",
"is_new": true
},
{
"id": 351,
"guid": "bbe8ec3b-a833-4706-8d2b-ca156ce63253",
"created": "2020-01-29T09:28:49",
"modified": "2020-01-29T09:28:50",
"report_generated_by": "aavacaflores",
"title": "CertifiedDonorStatement_CSACC_SC170311_29012019.pdf",
"donor": "Australia",
"donor_code": "G02701",
"grant_number": "SC170311",
"grant_issue_year": "2017",
"grant_expiry_date": "2018-06-30T00:00:00",
"external_reference": "72410/05",
"recipient_office": [
"Fiji (Pacific Islands)"
],
"report_type": "Interim",
"report_end_date": "2019-01-29T00:00:00",
"theme": null,
"donor_document": "Certified Statement of Account",
"donor_report_category": "Donor Financial Certified",
"report_method": "Auto",
"report_group": "Grant",
"report_status": "New",
"retracted": null,
"resource_url": "https://unitst.sharepoint.com/sites/GLB-DRP/_api/Web/lists/GetByTitle('2019 Certified Reports')/items/getItemById(351)",
"download_url": "http://localhost:8000/api/sharepoint/unitst/GLB-DRP/2019%20Certified%20Reports/files/CertifiedDonorStatement_CSACC_SC170311_29012019__ext__pdf/download/",
"is_new": true
}
],
"content_type": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
],
"content-length": [
"Content-Length",
"151"
"149"
]
},
"data": [
{
"id": 16,
"created": "2020-01-28T14:26:18.092000-06:00",
"modified": "2020-01-28T14:26:18.092000-06:00",
"id": 2,
"created": "2020-01-30T13:40:45.567000-06:00",
"modified": "2020-01-30T13:40:45.567000-06:00",
"name": "GLB-DRP",
"site_type": "sites",
"tenant": 16
"tenant": 2
}
],
"content_type": null
Expand Down
Loading

0 comments on commit 658f6f6

Please sign in to comment.