def test_tenders_utility_output(self): data = { "procurementMethodType": "aboveThresholdUA", "procuringEntity": { "kind": "general" }, "contracts": [ { "status": "active", "date": '2017-04-22T13:32:25.774673+02:00', } ], } doc = copy(self.test_data) doc.update(data) self.utility.db.save(doc) self.utility.run() with open(prepare_result_file_name(self.utility), 'rb') as file: file_data = list(csv.reader(file.readlines())) self.assertEqual( file_data, [ ['tender', 'tenderID', 'lot', 'status', 'lot_status', 'currency', 'kind', 'value', 'rate', 'bill'], ['after 2017-08-16'], ['tender_id', 'UA-2017-11-30', '', '', '', 'UAH', 'general', '1000', '-', '3.0'], ] )
def test_tenders_utility_output_pq(self): data = deepcopy(test_pq_data) doc = copy(self.test_data) doc.update(data) self.utility.db.save(doc) self.utility.run() with open(prepare_result_file_name(self.utility), 'rb') as file_fd: file_data = list(csv.reader(file_fd.readlines())) self.assertEqual( file_data, [[ 'tender_id', 'tenderID', 'contract_date', 'procuringEntity_name', 'procuringEntity_identifier_id', 'contract_supplier_name', 'contract_supplier_identifier_id', 'contracts_value_amount', 'tender_owner', 'bid_owner', 'profile_owner', 'tariff_group', 'method' ], [ 'tender_id_1', 'UA-2017-11-30', '2017-12-18T22:00:00', 'test_procuringEntity_name', '42751893', 'test_supplier_name', '32490244', '1000', 'test', 'test_bid_owner', 'access_owner_of_profile_502503-15220000-815175-40996564', 'under 50k UAH', 'priceQuotation' ]])
def test_tenders_utility_output_reporting(self): data = deepcopy(test_reporting_data) doc = copy(self.test_data) doc.update(data) self.utility.db.save(doc) self.utility.run() with open(prepare_result_file_name(self.utility), 'rb') as file_fd: file_data = list(csv.reader(file_fd.readlines())) print(file_data) sys.stdout.flush() self.assertEqual(file_data, [ [ 'tender_id', 'tenderID', 'contract_date', 'procuringEntity_name', 'procuringEntity_identifier_id', 'contract_supplier_name', 'contract_supplier_identifier_id', 'contracts_value_amount', 'tender_owner', 'bid_owner', 'profile_owner', 'tariff_group', 'method' ], [ 'tender_id_2', 'UA-2017-11-30', '2017-12-18T22:00:00', 'test_procuringEntity_name', '42751893', 'test_supplier_name', '32490244', '1000', 'test', 'access_owner_of_offer_df1ab52df383f6c220d5025fbc61a144, access_owner_of_offer_df1ab52df383f6c220d5025fbc61a145', 'access_owner_of_profile_relatedProfile_of_product_, access_owner_of_profile_relatedProfile_of_product_', 'under 50k UAH', 'reporting' ] ])
def write_csv(self): is_added = False second_version = [] new_version = [] splitter_before = [u'before_2017'] splitter_after = [u'after_2017-01-01'] splitter_new = [u'after {}'.format(NEW_ALG_DATE)] destination = prepare_result_file_name(self) if not self.headers: raise ValueError if not os.path.exists(os.path.dirname(destination)): os.makedirs(os.path.dirname(destination)) with open(destination, 'w') as out_file: writer = csv.writer(out_file) writer.writerow(self.headers) for row, ver in self.rows(): if ver == 1: if not is_added: writer.writerow(splitter_before) is_added = True writer.writerow(row) elif ver == 2: second_version.append(row) else: new_version.append(row) if second_version: writer.writerow(splitter_after) for row in second_version: writer.writerow(row) if new_version: writer.writerow(splitter_new) for row in new_version: writer.writerow(row)
def test_tenders_utility_output(self): data = { "owner": "test", "procurementMethod": "open", "enquiryPeriod": { "startDate": '2016-04-17T13:32:25.774673+02:00', }, "contracts": [ { "status": "active", "date": '2016-04-22T13:32:25.774673+02:00', "dateSigned": '2016-05-22T13:32:25.774673+02:00', "documents": [{ 'datePublished': "2016-06-22T13:32:25.774673+02:00", }] } ], } doc = copy(self.test_data) doc.update(data) self.utility.db.save(doc) self.utility.run() with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual(file.read(), ','.join(self.utility.headers) + '\r\n')
def test_tenders_utility_output(self): data = { "owner": "test", "procurementMethod": "open", "enquiryPeriod": { "startDate": '2016-04-17T13:32:25.774673+02:00', }, "contracts": [{ "status": "active", "date": '2016-04-22T13:32:25.774673+02:00', "dateSigned": '2016-05-22T13:32:25.774673+02:00', "documents": [{ 'datePublished': "2016-06-22T13:32:25.774673+02:00", }] }], } doc = copy(self.test_data) doc.update(data) self.utility.db.save(doc) self.utility.run() with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual(file.read(), ','.join(self.utility.headers) + '\r\n')
def write_csv(self): if not self.headers: raise ValueError destination = prepare_result_file_name(self) if not os.path.exists(os.path.dirname(destination)): os.makedirs(os.path.dirname(destination)) with open(destination, 'w') as out_file: writer = csv.writer(out_file) writer.writerow(self.headers) for row in self.rows(): writer.writerow(row)
def test_2019_4m1(self): data = { "procurementMethodType": "belowThreshold", "enquiryPeriod": { "startDate": "2019-08-22T00:01:50+02:00" }, "value": { "currency": "UAH", "amount": 4000001, "valueAddedTaxIncluded": False }, "awardPeriod": { "startDate": test_award_period, }, 'owner': 'test', "bids": [{ "id": "bid_1", "status": "active", "date": "2019-08-25T00:01:50+02:00", "owner": "test" }], "awards": [{ "bid_id": "bid_1", "status": "active", "date": "2019-08-25T00:01:50+02:00" }] } doc = copy(self.test_data) doc.update(data) self.utility.db.save(doc) self.utility.run() with open(prepare_result_file_name(self.utility), 'rb') as file: file_data = list(csv.reader(file.readlines())) self.assertEqual(file_data, [ [ 'tender', 'tenderID', 'lot', 'value', 'currency', 'bid', 'rate', 'bill', 'state' ], ['after 2019-08-22'], [ 'tender_id', 'UA-2017-11-30', '', '4000001', 'UAH', 'bid_1', '-', '1100.0', '1' ], [ 'tender_id', 'UA-2017-11-30', '', '4000001', 'UAH', 'bid_1', '-', '1100.0', '4' ], ])
def test_2019_4m1(self): data = { "enquiryPeriod": { "startDate": "2019-08-22T00:01:50+02:00" }, "value": { "currency": "UAH", "amount": 4000001, "valueAddedTaxIncluded": False }, "procurementMethodType": "aboveThresholdUA", "contracts": [{ "status": "active", "date": "2017-12-18T22:00:00" }], "procuringEntity": { "kind": "general" } } doc = copy(self.test_data) doc.update(data) self.utility.db.save(doc) self.utility.run() with open(prepare_result_file_name(self.utility), 'rb') as file: file_data = list(csv.reader(file.readlines())) self.assertEqual(file_data, [ [ '<= 20.0', '>20.0<=50.0', '>50.0<=200.0', '>200.0<=1000.0', '>1000.0<=4000.0', '>4000.0' ], ['before 2017'], ['5.0', '20.0', '50.0', '75.0', '350.0'], ['0', '0', '0', '0', '0', '0'], ['0.0', '0.0', '0.0', '0.0', '0.0'], ['after 2017-01-01'], ['3.0', '15.0', '40.0', '60.0', '300.0'], ['0', '0', '0', '0', '0', '0'], ['0.0', '0.0', '0.0', '0.0', '0.0'], ['after 2017-08-16'], ['3.0', '15.0', '40.0', '60.0', '300.0'], ['0', '0', '0', '0', '0', '0'], ['0.0', '0.0', '0.0', '0.0', '0.0'], ['after 2019-08-22'], ['3.0', '15.0', '40.0', '60.0', '300.0', '600.0'], ['0', '0', '0', '0', '0', '1'], ['0.0', '0.0', '0.0', '0.0', '0.0', '600.0'], ])
def test_bids_utility_output(self): data = { "awardPeriod": { "startDate": test_award_period, }, 'owner': 'test', 'bids': test_bids_valid[0], } doc = copy(self.test_data) doc.update(data) self.utility.db.save(doc) self.utility.run() with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual(file.read(), ','.join(self.utility.headers) + '\r\nafter_2017-01-01\r\n')
def test_bids_utility_output(self): data = { "awardPeriod": { "startDate": test_award_period, }, 'owner': 'test', 'bids': test_bids_valid[0], } doc = copy(self.test_data) doc.update(data) self.utility.db.save(doc) self.utility.run() with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual( file.read(), ','.join(self.utility.headers) + '\r\nafter_2017-01-01\r\n')
def test_bids_utility_output_with_lots(self): data = { "enquiryPeriod": { "startDate": '2016-04-17T13:32:25.774673+02:00', }, "awardPeriod": { "startDate": test_award_period, }, "lots": [ { "status": "active", "id": "324d7b2dd7a54df29bad6d0b7c91b2e9", "value": { "currency": "UAH", "amount": 2000, "valueAddedTaxIncluded": False, }, } ], "bids": [ { "date": "2016-04-07T16:36:58.983102+03:00", "owner": "test", "id": "a22ef2b1374b43ddb886821c0582bc7dk", "lotValues": [ { "relatedLot": "324d7b2dd7a54df29bad6d0b7c91b2e9", "date": "2016-04-07T16:36:58.983062+03:00", } ], } ], } doc = copy(self.test_data) doc.update(data) self.utility.db.save(doc) self.utility.run() with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual(file.read(), ','.join(self.utility.headers) + '\r\nafter_2017-01-01\r\n')
def write_csv(self): second_version = [] splitter = [u'after {}'.format(NEW_ALG_DATE)] destination = prepare_result_file_name(self) if not self.headers: raise ValueError if not os.path.exists(os.path.dirname(destination)): os.makedirs(os.path.dirname(destination)) with open(destination, 'w') as out_file: writer = csv.writer(out_file) writer.writerow(self.headers) writer.writerow(['after_2017-01-01']) for row, ver in self.rows(): if ver == 1: writer.writerow(row) else: second_version.append(row) if second_version: writer.writerow(splitter) for row in second_version: writer.writerow(row)
def test_bids_utility_output_with_lots(self): data = { "procurementMethodType": "belowThreshold", "enquiryPeriod": { "startDate": '2016-04-17T13:32:25.774673+02:00', }, "awardPeriod": { "startDate": test_award_period, }, "lots": [{ "status": "active", "id": "324d7b2dd7a54df29bad6d0b7c91b2e9", "value": { "currency": "UAH", "amount": 2000, "valueAddedTaxIncluded": False, }, }], "bids": [{ "date": "2016-04-07T16:36:58.983102+03:00", "owner": "test", "id": "a22ef2b1374b43ddb886821c0582bc7dk", "lotValues": [{ "relatedLot": "324d7b2dd7a54df29bad6d0b7c91b2e9", "date": "2016-04-07T16:36:58.983062+03:00", }], }], } doc = copy(self.test_data) doc.update(data) self.utility.db.save(doc) self.utility.run() with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual(file.read(), ','.join(self.utility.headers) + '\r\n')
def test_2019(self): data = { "procurementMethodType": "aboveThresholdUA", "enquiryPeriod": { "startDate": "2019-08-22T00:01:50+02:00" }, "procuringEntity": { "kind": "general" }, "contracts": [ { "status": "active", "date": '2017-04-22T13:32:25.774673+02:00', } ], "value": { "currency": "UAH", "amount": 4000001, "valueAddedTaxIncluded": False }, } doc = copy(self.test_data) doc.update(data) self.utility.db.save(doc) self.utility.run() with open(prepare_result_file_name(self.utility), 'rb') as file: file_data = list(csv.reader(file.readlines())) self.assertEqual( file_data, [ ['tender', 'tenderID', 'lot', 'status', 'lot_status', 'currency', 'kind', 'value', 'rate', 'bill'], ['after 2019-08-22'], ['tender_id', 'UA-2017-11-30', '', '', '', 'UAH', 'general', '4000001', '-', '600.0'], ] )
def test_invoices_utility_output(self): data = { "date": "2017-12-15T00:01:50+02:00", "procurementMethodType": "belowThreshold", "status": "cancelled", "bids": [{ "id": "bid_id", "status": "active", "date": "2017-12-01T00:00:00Z", "owner": "test" }], "awards": [{ "bid_id": "bid_id", "status": "active", "date": "2017-12-01T00:00:00Z", }] } doc = copy(self.test_data) doc.update(data) self.utility.db.save(doc) self.utility.counters = { index: [0 for _ in range(0, 5)] for index in range(0, 5) } self.utility.run() self.assertEqual( self.utility.counters[3], [1, 0, 0, 0, 0] ) def expected_output(): return '{}\r\n'.format(','.join(self.utility.headers)) +\ 'after_2017-01-01\r\n' +\ '{}\r\n'.format(','.join((str(i) for i in self.utility.counters[0]))) +\ '{}\r\n'.format(','.join((str(i) for i in self.utility.config.payments(grid=2017)))) +\ '{}\r\n'.format(','.join( (str(c * v) for c, v in zip(self.utility.counters[0], self.utility.config.payments())))) +\ 'after_2017-08-16\r\n' +\ '{}\r\n'.format(','.join( (str(i) for i in self.utility.counters[1]))) +\ '{}\r\n'.format(','.join( (str(i) for i in self.utility.counters[2]))) +\ '{}\r\n'.format(','.join( (str(i) for i in self.utility.counters[3]))) +\ '{}\r\n'.format(','.join( (str(a - b - c) for a, b, c in zip( self.utility.counters[1], self.utility.counters[2], self.utility.counters[3] ))), '\r\n') +\ '{}\r\n'.format(','.join( (str(i) for i in self.utility.config.payments()))) +\ '{}\r\n'.format(','.join( (str(c * v) for c, v in zip((a - b - c for a, b, c in zip( self.utility.counters[1], self.utility.counters[2], self.utility.counters[3] )), self.utility.config.payments()))) ) with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual(file.read(), expected_output()) doc = self.utility.db[doc['_id']] doc.update({'value': {'amount': 25000, 'currency': 'UAH'}}) self.utility.db.save(doc) self.utility.counters = { index: [0 for _ in range(0, 5)] for index in range(0, 5) } self.utility.run() self.utility.counter = self.utility.counters[3] self.assertEqual( self.utility.counters[3], [0, 1, 0, 0, 0] ) with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual(file.read(), expected_output()) doc = self.utility.db[doc['_id']] doc.update({'value': {'amount': 55000, 'currency': 'UAH'}}) self.utility.db.save(doc) self.utility.counters = { index: [0 for _ in range(0, 5)] for index in range(0, 5) } self.utility.run() self.assertEqual( self.utility.counters[3], [0, 0, 1, 0, 0] ) with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual(file.read(), expected_output()) self.utility.counter = [0 for _ in self.utility.config.payments()] doc = self.utility.db[doc['_id']] doc.update({'value': {'amount': 255000, 'currency': 'UAH'}}) self.utility.db.save(doc) self.utility.counters = { index: [0 for _ in range(0, 5)] for index in range(0, 5) } self.utility.run() self.assertEqual( self.utility.counters[3], [0, 0, 0, 1, 0] ) with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual(file.read(), expected_output()) self.utility.counter = [0 for _ in self.utility.config.payments()] doc = self.utility.db[doc['_id']] doc.update({'value': {'amount': 1255000, 'currency': 'UAH'}}) self.utility.db.save(doc) self.utility.counters = { index: [0 for _ in range(0, 5)] for index in range(0, 5) } self.utility.run() self.assertEqual( self.utility.counters[3], [0, 0, 0, 0, 1] ) with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual(file.read(), expected_output()) del self.utility.db[doc['_id']]
def test_invoices_utility_output(self): data = { "procurementMethodType": "aboveThresholdUA", "contracts": [{ "status": "active", "date": "2017-12-18T22:00:00" }], "procuringEntity": { "kind": "general" } } doc = copy(self.test_data) doc.update(data) self.utility.db.save(doc) self.utility.run() self.assertEqual( self.utility.new_counter, [1, 0, 0, 0, 0] ) def expected_output(): return '{}{}'.format(','.join(self.utility.headers), '\r\n') +\ 'before_2017\r\n' +\ '{}\r\n'.format(','.join((str(i) for i in self.utility.config.payments(2016)))) +\ '{}\r\n'.format( ','.join((str(i) for i in self.utility.counter_before)) ) +\ '{}\r\n'.format( ','.join((str(i) for i in (c * v for c, v in zip(self.utility.counter_before, self.utility.config.payments(2016))) )) ) +\ 'after 2017-01-01\r\n' + \ '{}\r\n'.format( ','.join((str(i) for i in self.utility.config.payments(2017))) ) +\ '{}\r\n'.format( ','.join((str(i) for i in self.utility.counter)) ) +\ '{}\r\n'.format( ','.join((str(i) for i in (c * v for c, v in zip(self.utility.counter, self.utility.config.payments(2017))) )) ) +\ 'after {}\r\n'.format(NEW_ALG_DATE) +\ '{}\r\n'.format( ','.join((str(i) for i in self.utility.config.payments(2017))) ) +\ '{}\r\n'.format( ','.join((str(i) for i in self.utility.new_counter)) ) +\ '{}\r\n'.format( ','.join((str(i) for i in (c * v for c, v in zip(self.utility.new_counter, self.utility.config.payments(2017))) )) ) with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual(file.read(), expected_output()) self.utility.new_counter = [0 for _ in self.utility.new_counter] doc = self.utility.db[doc['_id']] doc.update({'value': {'amount': 25000, 'currency': 'UAH'}}) self.utility.db.save(doc) self.utility.run() self.assertEqual( self.utility.new_counter, [0, 1, 0, 0, 0] ) with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual(file.read(), expected_output()) self.utility.new_counter = [0 for _ in self.utility.new_counter] doc = self.utility.db[doc['_id']] doc.update({'value': {'amount': 55000, 'currency': 'UAH'}}) self.utility.db.save(doc) self.utility.run() self.assertEqual( self.utility.new_counter, [0, 0, 1, 0, 0] ) with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual(file.read(), expected_output()) self.utility.new_counter = [0 for _ in self.utility.new_counter] doc = self.utility.db[doc['_id']] doc.update({'value': {'amount': 255000, 'currency': 'UAH'}}) self.utility.db.save(doc) self.utility.run() self.assertEqual( self.utility.new_counter, [0, 0, 0, 1, 0] ) with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual(file.read(), expected_output()) self.utility.new_counter = [0 for _ in self.utility.new_counter] doc = self.utility.db[doc['_id']] doc.update({'value': {'amount': 1255000, 'currency': 'UAH'}}) self.utility.db.save(doc) self.utility.run() self.assertEqual( self.utility.new_counter, [0, 0, 0, 0, 1] ) with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual(file.read(), expected_output()) del self.utility.db[doc['_id']]
def test_invoices_utility_output(self): data = { "date": "2017-12-15T00:01:50+02:00", "procurementMethodType": "belowThreshold", "status": "cancelled", "bids": [{ "id": "bid_id", "status": "active", "date": "2017-12-01T00:00:00Z", "owner": "test" }], "awards": [{ "bid_id": "bid_id", "status": "active", "date": "2017-12-01T00:00:00Z", }] } doc = copy(self.test_data) doc.update(data) self.utility.db.save(doc) self.utility.counters = { index: [0 for _ in range(0, 5)] for index in range(0, 5) } self.utility.run() self.assertEqual(self.utility.counters[3], [1, 0, 0, 0, 0]) def expected_output(): return '{}\r\n'.format(','.join(self.utility.headers)) +\ 'after_2017-01-01\r\n' +\ '{}\r\n'.format(','.join((str(i) for i in self.utility.counters[0]))) +\ '{}\r\n'.format(','.join((str(i) for i in self.utility.config.payments(grid=2017)))) +\ '{}\r\n'.format(','.join( (str(c * v) for c, v in zip(self.utility.counters[0], self.utility.config.payments())))) +\ 'after_2017-08-16\r\n' +\ '{}\r\n'.format(','.join( (str(i) for i in self.utility.counters[1]))) +\ '{}\r\n'.format(','.join( (str(i) for i in self.utility.counters[2]))) +\ '{}\r\n'.format(','.join( (str(i) for i in self.utility.counters[3]))) +\ '{}\r\n'.format(','.join( (str(a - b - c) for a, b, c in zip( self.utility.counters[1], self.utility.counters[2], self.utility.counters[3] ))), '\r\n') +\ '{}\r\n'.format(','.join( (str(i) for i in self.utility.config.payments()))) +\ '{}\r\n'.format(','.join( (str(c * v) for c, v in zip((a - b - c for a, b, c in zip( self.utility.counters[1], self.utility.counters[2], self.utility.counters[3] )), self.utility.config.payments()))) ) with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual(file.read(), expected_output()) doc = self.utility.db[doc['_id']] doc.update({'value': {'amount': 25000, 'currency': 'UAH'}}) self.utility.db.save(doc) self.utility.counters = { index: [0 for _ in range(0, 5)] for index in range(0, 5) } self.utility.run() self.utility.counter = self.utility.counters[3] self.assertEqual(self.utility.counters[3], [0, 1, 0, 0, 0]) with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual(file.read(), expected_output()) doc = self.utility.db[doc['_id']] doc.update({'value': {'amount': 55000, 'currency': 'UAH'}}) self.utility.db.save(doc) self.utility.counters = { index: [0 for _ in range(0, 5)] for index in range(0, 5) } self.utility.run() self.assertEqual(self.utility.counters[3], [0, 0, 1, 0, 0]) with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual(file.read(), expected_output()) self.utility.counter = [0 for _ in self.utility.config.payments()] doc = self.utility.db[doc['_id']] doc.update({'value': {'amount': 255000, 'currency': 'UAH'}}) self.utility.db.save(doc) self.utility.counters = { index: [0 for _ in range(0, 5)] for index in range(0, 5) } self.utility.run() self.assertEqual(self.utility.counters[3], [0, 0, 0, 1, 0]) with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual(file.read(), expected_output()) self.utility.counter = [0 for _ in self.utility.config.payments()] doc = self.utility.db[doc['_id']] doc.update({'value': {'amount': 1255000, 'currency': 'UAH'}}) self.utility.db.save(doc) self.utility.counters = { index: [0 for _ in range(0, 5)] for index in range(0, 5) } self.utility.run() self.assertEqual(self.utility.counters[3], [0, 0, 0, 0, 1]) with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual(file.read(), expected_output()) del self.utility.db[doc['_id']]
def test_invoices_utility_output(self): data = { "procurementMethodType": "aboveThresholdUA", "contracts": [{ "status": "active", "date": "2017-12-18T22:00:00" }], "procuringEntity": { "kind": "general" } } doc = copy(self.test_data) doc.update(data) self.utility.db.save(doc) self.utility.run() self.assertEqual(self.utility.counters[2], [1, 0, 0, 0, 0, 0]) def expected_output(): return '{}{}'.format(','.join(self.utility.headers), '\r\n') +\ 'before 2017\r\n' +\ '{}\r\n'.format(','.join((str(i) for i in self.utility.config.payments(2016)))) +\ '{}\r\n'.format( ','.join((str(i) for i in self.utility.counters[0])) ) +\ '{}\r\n'.format( ','.join((str(i) for i in (c * v for c, v in zip(self.utility.counters[0], self.utility.config.payments(2016))) )) ) +\ 'after 2017-01-01\r\n' + \ '{}\r\n'.format( ','.join((str(i) for i in self.utility.config.payments(2017))) ) +\ '{}\r\n'.format( ','.join((str(i) for i in self.utility.counters[1])) ) +\ '{}\r\n'.format( ','.join((str(i) for i in (c * v for c, v in zip(self.utility.counters[1], self.utility.config.payments(2017))) )) ) +\ 'after {}\r\n'.format(NEW_ALG_DATE) +\ '{}\r\n'.format( ','.join((str(i) for i in self.utility.config.payments(2017))) ) +\ '{}\r\n'.format( ','.join((str(i) for i in self.utility.counters[2])) ) +\ '{}\r\n'.format( ','.join((str(i) for i in (c * v for c, v in zip(self.utility.counters[2], self.utility.config.payments(2017))) )) ) + \ 'after {}\r\n'.format(CHANGE_2019_DATE) + \ '{}\r\n'.format( ','.join((str(i) for i in self.utility.config.payments(2019))) ) + \ '{}\r\n'.format( ','.join((str(i) for i in self.utility.counters[3])) ) + \ '{}\r\n'.format( ','.join((str(i) for i in (c * v for c, v in zip(self.utility.counters[3], self.utility.config.payments(2019))) )) ) with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual(file.read(), expected_output()) self.utility.init_counters() doc = self.utility.db[doc['_id']] doc.update({'value': {'amount': 25000, 'currency': 'UAH'}}) self.utility.db.save(doc) self.utility.run() self.assertEqual(self.utility.counters[2], [0, 1, 0, 0, 0, 0]) with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual(file.read(), expected_output()) self.utility.init_counters() doc = self.utility.db[doc['_id']] doc.update({'value': {'amount': 55000, 'currency': 'UAH'}}) self.utility.db.save(doc) self.utility.run() self.assertEqual(self.utility.counters[2], [0, 0, 1, 0, 0, 0]) with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual(file.read(), expected_output()) self.utility.init_counters() doc = self.utility.db[doc['_id']] doc.update({'value': {'amount': 255000, 'currency': 'UAH'}}) self.utility.db.save(doc) self.utility.run() self.assertEqual(self.utility.counters[2], [0, 0, 0, 1, 0, 0]) with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual(file.read(), expected_output()) self.utility.init_counters() doc = self.utility.db[doc['_id']] doc.update({'value': {'amount': 1255000, 'currency': 'UAH'}}) self.utility.db.save(doc) self.utility.run() self.assertEqual(self.utility.counters[2], [0, 0, 0, 0, 1, 0]) with open(prepare_result_file_name(self.utility), 'rb') as file: self.assertEqual(file.read(), expected_output()) del self.utility.db[doc['_id']]