Add datapackages for data exports
Showing 2 of 7 files from the diff.
Other files ignored by Codecov
@@ -419,7 +419,7 @@
Loading
419 | 419 | member_info = self.cmd.member_info(event) |
|
420 | 420 | assert member_info['sort_names'][0] == person.sort_name |
|
421 | 421 | assert member_info['names'][0] == person.name |
|
422 | - | assert member_info['URIs'][0] == \ |
|
422 | + | assert member_info['uris'][0] == \ |
|
423 | 423 | absolutize_url(person.get_absolute_url()) |
|
424 | 424 | ||
425 | 425 | # event with two members; fixture includes Edel joint account |
@@ -428,7 +428,7 @@
Loading
428 | 428 | ||
429 | 429 | member_info = self.cmd.member_info(event) |
|
430 | 430 | # each field should have two values |
|
431 | - | for field in ('sort_names', 'names', 'URIs'): |
|
431 | + | for field in ('sort_names', 'names', 'uris'): |
|
432 | 432 | assert len(member_info[field]) == 2 |
|
433 | 433 | ||
434 | 434 | # test event with account but no person |
@@ -444,10 +444,9 @@
Loading
444 | 444 | .first() |
|
445 | 445 | subs = event.subscription |
|
446 | 446 | info = self.cmd.subscription_info(event) |
|
447 | - | assert info['price_paid'] == '%s%.2f' % (subs.currency_symbol(), |
|
448 | - | subs.price_paid) |
|
447 | + | assert info['price_paid'] == '%.2f' % subs.price_paid |
|
449 | 448 | # test event has no deposit amount |
|
450 | - | assert info['deposit'] == '%s0.00' % subs.currency_symbol() |
|
449 | + | assert 'deposit' not in info |
|
451 | 450 | assert info['duration'] == subs.readable_duration() |
|
452 | 451 | assert info['duration_days'] == subs.duration |
|
453 | 452 | assert info['volumes'] == subs.volumes |
@@ -529,6 +528,19 @@
Loading
529 | 528 | assert info['manifest'] == footnote.bibliography.manifest.uri |
|
530 | 529 | assert info['image'] == str(footnote.image.image) |
|
531 | 530 | ||
531 | + | def test_get_object_data(self): |
|
532 | + | # get a subscription with no subcategory and both dates |
|
533 | + | event = Event.objects.filter( |
|
534 | + | subscription__isnull=False, |
|
535 | + | start_date__isnull=False, end_date__isnull=False, |
|
536 | + | subscription__category__isnull=True) \ |
|
537 | + | .first() |
|
538 | + | data = self.cmd.get_object_data(event) |
|
539 | + | assert data['event_type'] == event.event_label |
|
540 | + | assert data['currency'] == 'FRF' |
|
541 | + | assert 'member' in data |
|
542 | + | assert 'subscription' in data |
|
543 | + | ||
532 | 544 | def test_command_line(self): |
|
533 | 545 | # test calling via command line with args |
|
534 | 546 | tempdir = TemporaryDirectory() |
@@ -26,7 +26,7 @@
Loading
26 | 26 | csv_fields = [ |
|
27 | 27 | 'event_type', |
|
28 | 28 | 'start_date', 'end_date', |
|
29 | - | 'member_URIs', 'member_names', 'member_sort_names', |
|
29 | + | 'member_uris', 'member_names', 'member_sort_names', |
|
30 | 30 | # subscription specific |
|
31 | 31 | 'subscription_price_paid', 'subscription_deposit', |
|
32 | 32 | 'subscription_duration', 'subscription_duration_days', |
@@ -38,6 +38,8 @@
Loading
38 | 38 | 'borrow_status', |
|
39 | 39 | # purchase specific |
|
40 | 40 | 'purchase_price', |
|
41 | + | # currency applies to purchase, borrow, and subscription |
|
42 | + | 'currency', |
|
41 | 43 | # related book/item |
|
42 | 44 | 'item_uri', 'item_title', 'item_volume', 'item_authors', |
|
43 | 45 | 'item_year', 'item_notes', |
@@ -70,18 +72,19 @@
Loading
70 | 72 | ||
71 | 73 | # variable to store footnote reference, if any |
|
72 | 74 | footnote = None |
|
75 | + | currency = None |
|
73 | 76 | ||
74 | 77 | # subscription-specific data |
|
75 | 78 | if event_type in ['Subscription', 'Supplement', 'Renewal']: |
|
76 | 79 | data['subscription'] = self.subscription_info(obj) |
|
80 | + | currency = obj.subscription.currency |
|
77 | 81 | ||
78 | 82 | # reimbursement data |
|
79 | 83 | elif event_type in 'Reimbursement' and obj.reimbursement.refund: |
|
80 | 84 | data['reimbursement'] = { |
|
81 | - | 'refund': '%s%.2f' % |
|
82 | - | (obj.reimbursement.currency_symbol(), |
|
83 | - | obj.reimbursement.refund) |
|
85 | + | 'refund': '%.2f' % obj.reimbursement.refund |
|
84 | 86 | } |
|
87 | + | currency = obj.reimbursement.currency |
|
85 | 88 | ||
86 | 89 | # borrow data |
|
87 | 90 | elif event_type == 'Borrow': |
@@ -92,9 +95,12 @@
Loading
92 | 95 | # purchase data |
|
93 | 96 | elif event_type == 'Purchase' and obj.purchase.price: |
|
94 | 97 | data['purchase'] = { |
|
95 | - | 'price': '%s%.2f' % |
|
96 | - | (obj.purchase.currency_symbol(), obj.purchase.price) |
|
98 | + | 'price': '%.2f' % obj.purchase.price |
|
97 | 99 | } |
|
100 | + | currency = obj.purchase.currency |
|
101 | + | ||
102 | + | if currency: |
|
103 | + | data['currency'] = currency |
|
98 | 104 | ||
99 | 105 | # footnote should always be attached to the base event |
|
100 | 106 | footnote = obj.footnotes.first() |
@@ -114,7 +120,7 @@
Loading
114 | 120 | return |
|
115 | 121 | ||
116 | 122 | return OrderedDict([ |
|
117 | - | ('URIs', [absolutize_url(m.get_absolute_url()) for m in members]), |
|
123 | + | ('uris', [absolutize_url(m.get_absolute_url()) for m in members]), |
|
118 | 124 | ('names', [m.name for m in members]), |
|
119 | 125 | ('sort_names', [m.sort_name for m in members]) |
|
120 | 126 | ]) |
@@ -127,12 +133,12 @@
Loading
127 | 133 | except ObjectDoesNotExist: |
|
128 | 134 | return |
|
129 | 135 | ||
130 | - | info = OrderedDict([ |
|
131 | - | ('price_paid', '%s%.2f' % (subs.currency_symbol(), |
|
132 | - | subs.price_paid or 0)), |
|
133 | - | ('deposit', '%s%.2f' % (subs.currency_symbol(), |
|
134 | - | subs.deposit or 0)) |
|
135 | - | ]) |
|
136 | + | info = OrderedDict() |
|
137 | + | if subs.price_paid: |
|
138 | + | info['price_paid'] = '%.2f' % subs.price_paid |
|
139 | + | if subs.deposit: |
|
140 | + | info['deposit'] = '%.2f' % subs.deposit |
|
141 | + | ||
136 | 142 | if subs.duration: |
|
137 | 143 | info['duration'] = subs.readable_duration() |
|
138 | 144 | info['duration_days'] = subs.duration |
Files | Coverage |
---|---|
mep | 98.44% |
srcmedia/ts | 86.55% |
Project Totals (223 files) | 98.00% |
2449.1
TRAVIS_PYTHON_VERSION=3.5 TRAVIS_OS_NAME=linux
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file.
The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files.
The size and color of each slice is representing the number of statements and the coverage, respectively.