def test_calcSaskOilRegulationSubsection3(self): """ subsection (3) """ pr = ProcessRoyalties() self.assertEqual(pr.calc_sask_oil_iogr_subsection3(70), 7) self.assertEqual(pr.calc_sask_oil_iogr_subsection3(90), 10) self.assertEqual(pr.calc_sask_oil_iogr_subsection3(200), (24 + .26 * (200 - 160))) self.assertEqual(pr.calc_sask_oil_iogr_subsection3(2000), (189 + .4 * (2000 - 795))) return
def test_process_monthly(self): self.dbu = DatabaseUtilities() self.dbu.delete_all_tables() self.dbu.create_some_test_well_royalty_masters() self.dbu.create_some_test_lease_royalty_masters() self.dbu.create_some_test_leases() self.dbu.create_some_test_monthly() self.dbu.create_some_test_econdata() self.dbu.create_calc() pr = ProcessRoyalties() pr.process_one(4, 201501, 'Oil')
def run_royalties_and_worksheet(): pr = ProcessRoyalties() # pr.process_all() pr.process_one(6, 201501, 'Oil') # pr.process(config.get_file_dir() + 'database.xlsx') # pr.process('d:/$temp/sample.xlsx') print('os name is:',os.name) if os.name != "posix": subprocess.call(['notepad.exe', config.get_temp_dir() + 'log.txt']) subprocess.call(['notepad.exe', config.get_temp_dir() + 'Royalty Worksheet.txt'])
def run_royalties_and_worksheet(): pr = ProcessRoyalties() # pr.process_all() pr.process_one(6, 201501, 'Oil') # pr.process(config.get_file_dir() + 'database.xlsx') # pr.process('d:/$temp/sample.xlsx') print('os name is:', os.name) if os.name != "posix": subprocess.call(['notepad.exe', config.get_temp_dir() + 'log.txt']) subprocess.call( ['notepad.exe', config.get_temp_dir() + 'Royalty Worksheet.txt'])
def test_determineRoyaltyPrice(self): m = DataStructure() m.WellHeadPrice = 221.123456 m.TransRate = 2.123455 m.ProcessingRate = 0.123455 pr = ProcessRoyalties() self.assertAlmostEqual(pr.determine_royalty_price('ActSales', m), 223.370366) m.WellHeadPrice = 225 m.TransRate = 3 m.ProcessingRate = 1 self.assertAlmostEqual(pr.determine_royalty_price('ActSales', m), 229)
def test_determineCommencementPeriod(self): pr = ProcessRoyalties() self.assertEqual(pr.determine_commencement_period(201501, date(2014, 12, 1)), .08) self.assertEqual(pr.determine_commencement_period(201501, date(2014, 12, 31)), 0) self.assertEqual(pr.determine_commencement_period(201501, date(2014, 1, 1)), 1) self.assertEqual(pr.determine_commencement_period(201501, date(2010, 11, 30)), 4.09) self.assertEqual(pr.determine_commencement_period(201501, date(2010, 1, 1)), 5) self.assertEqual(pr.determine_commencement_period(201501, date(2010, 1, 31)), 4.92) self.assertEqual(pr.determine_commencement_period(201501, date(2010, 1, 1)), 5.0) self.assertRaises(AppError, pr.determine_commencement_period, None, None) self.assertEqual(pr.determine_commencement_period(201501, datetime(2003, 1, 1)), 12.01) return
def test_determineCommencementPeriod(self): pr = ProcessRoyalties() self.assertEqual(pr.determine_commencement_period(201501, datetime(2015, 1, 1)), 0) self.assertEqual(pr.determine_commencement_period(201501, datetime(2014, 12, 1)), 0.08) self.assertEqual(pr.determine_commencement_period(201501, datetime(2014, 11, 15)), 0.13) self.assertEqual(pr.determine_commencement_period(201501, datetime(2014, 1, 1)), 1) self.assertEqual(pr.determine_commencement_period(201501, datetime(2014, 1, 1)), 1) self.assertEqual(pr.determine_commencement_period(201501, datetime(2010, 1, 1)), 5) self.assertEqual(pr.determine_commencement_period(201501, datetime(2009, 12, 1)), 5.09) self.assertEqual(pr.determine_commencement_period(201501, None), 5)
def test_calcSupplementaryRoyaltiesIOGR1995(self): reference_price = {'Pigeon Lake Indian': 24.04, 'Reserve no.138A': 25.37, 'Sawridge Indian': 25.13, 'Stony Plain Indian': 24.64} pr = ProcessRoyalties() calc = DataStructure() self.assertEqual(pr.calc_supplementary_royalties_iogr1995(3.5, 228, 80, 60, reference_price['Pigeon Lake Indian']), 2039.6) self.assertEqual(pr.calc_supplementary_royalties_iogr1995(5, 200, 90, 40, reference_price['Reserve no.138A']), 4365.75) self.assertEqual(pr.calc_supplementary_royalties_iogr1995(4, 221.123456, 100, 50, reference_price['Sawridge Indian']), 4899.84) self.assertEqual(pr.calc_supplementary_royalties_iogr1995(.2, 180, 80, 35, reference_price['Stony Plain Indian']), 3495.6) self.assertEqual(pr.calc_supplementary_royalties_iogr1995(6, 228, 80, 60, reference_price['Pigeon Lake Indian']), 2996.5) self.assertEqual(pr.calc_supplementary_royalties_iogr1995(5.5, 200, 90, 40, reference_price['Reserve no.138A']), 6391.38) self.assertEqual(pr.calc_supplementary_royalties_iogr1995(8, 221.123456, 100, 50, reference_price['Sawridge Indian']), 7192.5) self.assertEqual(pr.calc_supplementary_royalties_iogr1995(15, 180, 80, 35, reference_price['Stony Plain Indian']), 5101.88)
def test_determineCommencementPeriod(self): pr = ProcessRoyalties() self.assertEqual( pr.determine_commencement_period(201501, datetime(2015, 1, 1)), 0) self.assertEqual( pr.determine_commencement_period(201501, datetime(2014, 12, 1)), 0.08) self.assertEqual( pr.determine_commencement_period(201501, datetime(2014, 11, 15)), 0.13) self.assertEqual( pr.determine_commencement_period(201501, datetime(2014, 1, 1)), 1) self.assertEqual( pr.determine_commencement_period(201501, datetime(2014, 1, 1)), 1) self.assertEqual( pr.determine_commencement_period(201501, datetime(2010, 1, 1)), 5) self.assertEqual( pr.determine_commencement_period(201501, datetime(2009, 12, 1)), 5.09) self.assertEqual(pr.determine_commencement_period(201501, None), 5)
def test_calcSupplementaryRoyaltiesIOGR1995(self): reference_price = { 'Pigeon Lake Indian': 24.04, 'Reserve no.138A': 25.37, 'Sawridge Indian': 25.13, 'Stony Plain Indian': 24.64 } pr = ProcessRoyalties() calc = DataStructure() self.assertEqual( pr.calc_supplementary_royalties_iogr1995( 3.5, 228, 80, 60, reference_price['Pigeon Lake Indian']), 2039.6) self.assertEqual( pr.calc_supplementary_royalties_iogr1995( 5, 200, 90, 40, reference_price['Reserve no.138A']), 4365.75) self.assertEqual( pr.calc_supplementary_royalties_iogr1995( 4, 221.123456, 100, 50, reference_price['Sawridge Indian']), 4899.84) self.assertEqual( pr.calc_supplementary_royalties_iogr1995( .2, 180, 80, 35, reference_price['Stony Plain Indian']), 3495.6) self.assertEqual( pr.calc_supplementary_royalties_iogr1995( 6, 228, 80, 60, reference_price['Pigeon Lake Indian']), 2996.5) self.assertEqual( pr.calc_supplementary_royalties_iogr1995( 5.5, 200, 90, 40, reference_price['Reserve no.138A']), 6391.38) self.assertEqual( pr.calc_supplementary_royalties_iogr1995( 8, 221.123456, 100, 50, reference_price['Sawridge Indian']), 7192.5) self.assertEqual( pr.calc_supplementary_royalties_iogr1995( 15, 180, 80, 35, reference_price['Stony Plain Indian']), 5101.88)
def test_determineCommencementPeriod(self): pr = ProcessRoyalties() self.assertEqual( pr.determine_commencement_period(201501, date(2014, 12, 1)), .08) self.assertEqual( pr.determine_commencement_period(201501, date(2014, 12, 31)), 0) self.assertEqual( pr.determine_commencement_period(201501, date(2014, 1, 1)), 1) self.assertEqual( pr.determine_commencement_period(201501, date(2010, 11, 30)), 4.09) self.assertEqual( pr.determine_commencement_period(201501, date(2010, 1, 1)), 5) self.assertEqual( pr.determine_commencement_period(201501, date(2010, 1, 31)), 4.92) self.assertEqual( pr.determine_commencement_period(201501, date(2010, 1, 1)), 5.0) self.assertRaises(AppError, pr.determine_commencement_period, None, None) self.assertEqual( pr.determine_commencement_period(201501, datetime(2003, 1, 1)), 12.01) return
def test_calcSaskOilProvCrownRoyaltyVolumeValue(self): pr = ProcessRoyalties() self.assertEqual(pr.calc_sask_oil_prov_crown_royalty_volume_value(2, 100, 1, 20, 1, 100), (20.0, 2000.0)) self.assertEqual(pr.calc_sask_oil_prov_crown_royalty_volume_value(-1, 100, 1, 20, 1, 100), (20.0, 2000.0)) self.assertEqual(pr.calc_sask_oil_prov_crown_royalty_volume_value(2, 100, 1, 5, 1, 100), (5, 500.0)) self.assertEqual(pr.calc_sask_oil_prov_crown_royalty_volume_value(2, 100, 1, None, 1, 100), (2.0, 200.0)) self.assertEqual(pr.calc_sask_oil_prov_crown_royalty_volume_value(10, 120, 1, 2, 1, 120), (12, 1440.0)) return
def test_calcSaskOilProvCrownRoyaltyVolumeValue(self): pr = ProcessRoyalties() self.assertEqual( pr.calc_sask_oil_prov_crown_royalty_volume_value( 2, 100, 1, 20, 1, 100), (20.0, 2000.0)) self.assertEqual( pr.calc_sask_oil_prov_crown_royalty_volume_value( -1, 100, 1, 20, 1, 100), (20.0, 2000.0)) self.assertEqual( pr.calc_sask_oil_prov_crown_royalty_volume_value( 2, 100, 1, 5, 1, 100), (5, 500.0)) self.assertEqual( pr.calc_sask_oil_prov_crown_royalty_volume_value( 2, 100, 1, None, 1, 100), (2.0, 200.0)) self.assertEqual( pr.calc_sask_oil_prov_crown_royalty_volume_value( 10, 120, 1, 2, 1, 120), (12, 1440.0)) return
def test_calcSaskOilProvCrownRoyaltyRate(self): econStringData = \ """ CharMonth,ProdMonth,HOP,SOP,NOP,H4T_C,H4T_D,H4T_K,H4T_X,H3T_K,H3T_X,HNEW_K,HNEW_X,SW4T_C,SW4T_D,SW4T_K,SW4T_X,SW3T_K,SW3T_X,SWNEW_K,SWNEW_X,O4T_C,O4T_D,O4T_K,O4T_X,O3T_K,O3T_X,ONEW_K,ONEW_X,OOLD_K,OOLD_X Sept.,201509,162,210,276,0.0841,2.1,20.81,1561,20.46,472,26.48,611,0.1045,2.61,25.85,1939,31.57,729,38.54,890,0.1209,3.02,29.91,2243,36.08,833,40.79,941,52.61,1214 """ # All this work so we don't need to read from the database. It's a way better test. econOilData = DataStructure() th = TestHelper() royaltyCalc = DataStructure() th.load_object_csv_style(econOilData, econStringData) pr = ProcessRoyalties() self.assertEqual( pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Fourth Tier Oil', 'Heavy', 24, 0), 0) self.assertEqual( pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Fourth Tier Oil', 'Heavy', 100, 0), 6.31) self.assertEqual( pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Fourth Tier Oil', 'Southwest', 100, 0), 7.84) self.assertEqual( pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Fourth Tier Oil', 'Other', 130, 0), 12.697) self.assertEqual( pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Fourth Tier Oil', 'Heavy', 140, 0), 9.66) self.assertEqual( pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Fourth Tier Oil', 'Southwest', 136.3, 0), 11.624028) self.assertEqual( pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Fourth Tier Oil', 'Other', 150, 0), 14.956667) self.assertEqual( pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Fourth Tier Oil', 'Other', 0, 0), 0) self.assertRaises(AppError, pr.calc_sask_oil_prov_crown_royalty_rate, royaltyCalc, econOilData, 'Fourth Tier Oil', 'BadString', 120, 0) self.assertRaises(AppError, pr.calc_sask_oil_prov_crown_royalty_rate, royaltyCalc, econOilData, 'Fourth Tier Oil', 'BadString', 140, 0) self.assertRaises(AppError, pr.calc_sask_oil_prov_crown_royalty_rate, royaltyCalc, econOilData, 'Bad String', 'Heavy', 120, 0) self.assertRaises(AppError, pr.calc_sask_oil_prov_crown_royalty_rate, royaltyCalc, econOilData, 'Bad String', 'Southwest', 120, 0) self.assertRaises(AppError, pr.calc_sask_oil_prov_crown_royalty_rate, royaltyCalc, econOilData, 'Bad String', 'Other', 120, 0) self.assertEqual( pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Third Tier Oil', 'Heavy', 100, 0.75), 14.99) self.assertAlmostEqual( pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'New Oil', 'Heavy', 100, 0.75), 19.620000) self.assertEqual( pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'New Oil', 'Heavy', 0, 0), 0) self.assertRaises(AppError, pr.calc_sask_oil_prov_crown_royalty_rate, royaltyCalc, econOilData, 'Third Tier Oil', 'Bad String', 120, 0) self.assertEqual( pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Third Tier Oil', 'Southwest', 120, 0), 25.495000) self.assertEqual( pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'New Oil', 'Southwest', 130, 0.75), 30.943846) self.assertEqual( pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'New Oil', 'Southwest', 0, 0), 0) self.assertRaises(AppError, pr.calc_sask_oil_prov_crown_royalty_rate, royaltyCalc, econOilData, 'New Oil', 'Bad String', 120, 0) self.assertEqual( pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Third Tier Oil', 'Other', 120, 2.25), 26.888333) self.assertEqual( pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'New Oil', 'Other', 110, 0), 32.235455) self.assertEqual( pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Old Oil', 'Other', 100, 0.75), 39.720000) self.assertEqual( pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Old Oil', 'Other', 0, 0), 0) self.assertRaises(AppError, pr.calc_sask_oil_prov_crown_royalty_rate, royaltyCalc, econOilData, 'Old Oil', 'Bad String', 120, 0) self.assertRaises(AppError, pr.calc_sask_oil_prov_crown_royalty_rate, royaltyCalc, econOilData, 'Old Oil', 'Heavy', 120, 0) self.assertRaises(AppError, pr.calc_sask_oil_prov_crown_royalty_rate, royaltyCalc, econOilData, 'Old Oil', 'Southwest', 120, 0) return
def test_calcSaskOilRegulationSubsection3(self): pr = ProcessRoyalties() self.assertAlmostEqual(pr.calc_sask_oil_iogr_subsection3(79.9), 7.99) self.assertEqual(pr.calc_sask_oil_iogr_subsection3(150), 22) self.assertEqual(pr.calc_sask_oil_iogr_subsection3(500), 112.4) self.assertEqual(pr.calc_sask_oil_iogr_subsection3(800), 191)
def test_calcSaskOilRegulationSubsection2(self): pr = ProcessRoyalties() self.assertEqual(pr.calc_sask_oil_iogr_subsection2(70), 7) self.assertEqual(pr.calc_sask_oil_iogr_subsection2(100), 12) self.assertEqual(pr.calc_sask_oil_iogr_subsection2(170), 26.6)
def test_calcSaskOilProvCrownRoyaltyRate(self): econStringData = \ """ CharMonth,ProdMonth,HOP,SOP,NOP,H4T_C,H4T_D,H4T_K,H4T_X,H3T_K,H3T_X,HNEW_K,HNEW_X,SW4T_C,SW4T_D,SW4T_K,SW4T_X,SW3T_K,SW3T_X,SWNEW_K,SWNEW_X,O4T_C,O4T_D,O4T_K,O4T_X,O3T_K,O3T_X,ONEW_K,ONEW_X,OOLD_K,OOLD_X Sept.,201509,162,210,276,0.0841,2.1,20.81,1561,20.46,472,26.48,611,0.1045,2.61,25.85,1939,31.57,729,38.54,890,0.1209,3.02,29.91,2243,36.08,833,40.79,941,52.61,1214 """ # All this work so we don't need to read from the database. It's a way better test. econOilData = DataStructure() th = TestHelper() royaltyCalc = DataStructure() th.load_object_csv_style(econOilData, econStringData) pr = ProcessRoyalties() self.assertEqual(pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Fourth Tier Oil', 'Heavy', 24, 0), 0) self.assertEqual(pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Fourth Tier Oil', 'Heavy', 100, 0), 6.31) self.assertEqual(pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Fourth Tier Oil', 'Southwest', 100, 0), 7.84) self.assertEqual(pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Fourth Tier Oil', 'Other', 130, 0), 12.697) self.assertEqual(pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Fourth Tier Oil', 'Heavy', 140, 0), 9.66) self.assertEqual(pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Fourth Tier Oil', 'Southwest', 136.3, 0), 11.624028) self.assertEqual(pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Fourth Tier Oil', 'Other', 150, 0), 14.956667) self.assertEqual(pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Fourth Tier Oil', 'Other', 0, 0), 0) self.assertRaises(AppError, pr.calc_sask_oil_prov_crown_royalty_rate, royaltyCalc, econOilData, 'Fourth Tier Oil', 'BadString', 120, 0) self.assertRaises(AppError, pr.calc_sask_oil_prov_crown_royalty_rate, royaltyCalc, econOilData, 'Fourth Tier Oil', 'BadString', 140, 0) self.assertRaises(AppError, pr.calc_sask_oil_prov_crown_royalty_rate, royaltyCalc, econOilData, 'Bad String', 'Heavy', 120, 0) self.assertRaises(AppError, pr.calc_sask_oil_prov_crown_royalty_rate, royaltyCalc, econOilData, 'Bad String', 'Southwest', 120, 0) self.assertRaises(AppError, pr.calc_sask_oil_prov_crown_royalty_rate, royaltyCalc, econOilData, 'Bad String', 'Other', 120, 0) self.assertEqual(pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Third Tier Oil', 'Heavy', 100, 0.75), 14.99) self.assertAlmostEqual(pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'New Oil', 'Heavy', 100, 0.75), 19.620000) self.assertEqual(pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'New Oil', 'Heavy', 0, 0), 0) self.assertRaises(AppError, pr.calc_sask_oil_prov_crown_royalty_rate, royaltyCalc, econOilData, 'Third Tier Oil', 'Bad String', 120, 0) self.assertEqual(pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Third Tier Oil', 'Southwest', 120, 0), 25.495000) self.assertEqual(pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'New Oil', 'Southwest', 130, 0.75), 30.943846) self.assertEqual(pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'New Oil', 'Southwest', 0, 0), 0) self.assertRaises(AppError, pr.calc_sask_oil_prov_crown_royalty_rate, royaltyCalc, econOilData, 'New Oil', 'Bad String', 120, 0) self.assertEqual(pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Third Tier Oil', 'Other', 120, 2.25), 26.888333) self.assertEqual(pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'New Oil', 'Other', 110, 0), 32.235455) self.assertEqual(pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Old Oil', 'Other', 100, 0.75), 39.720000) self.assertEqual(pr.calc_sask_oil_prov_crown_royalty_rate(royaltyCalc, econOilData, 'Old Oil', 'Other', 0, 0), 0) self.assertRaises(AppError, pr.calc_sask_oil_prov_crown_royalty_rate, royaltyCalc, econOilData, 'Old Oil', 'Bad String', 120, 0) self.assertRaises(AppError, pr.calc_sask_oil_prov_crown_royalty_rate, royaltyCalc, econOilData, 'Old Oil', 'Heavy', 120, 0) self.assertRaises(AppError, pr.calc_sask_oil_prov_crown_royalty_rate, royaltyCalc, econOilData, 'Old Oil', 'Southwest', 120, 0) return
def test_calcGorrPercent(self): pr = ProcessRoyalties() gorr = "bad string,0,2" self.assertRaises(AppError, pr.calc_gorr_percent, 400, 10, gorr) self.assertRaises(AppError, pr.calc_gorr_percent, None, 10, gorr) gorr = None,"0,2" self.assertRaises(AttributeError, pr.calc_gorr_percent, 400, 10, gorr) gorr = "dprod,250,2,300,3,400,4,500,5,0,6" self.assertEqual(pr.calc_gorr_percent(600, 10, gorr), (2.0, 'dprod = 60.000000 = 600 / 10 is greater than 0.0 and less than or equal to 250.0 for an RR of 2.0%')) self.assertEqual(pr.calc_gorr_percent(1008, 4, gorr), (3.0, 'dprod = 252.000000 = 1008 / 4 is greater than 250.0 and less than or equal to 300.0 for an RR of 3.0%')) self.assertEqual(pr.calc_gorr_percent(400, 1, gorr), (4.0, 'dprod = 400.000000 = 400 / 1 is greater than 300.0 and less than or equal to 400.0 for an RR of 4.0%')) self.assertEqual(pr.calc_gorr_percent(990, 2, gorr), (5.0, 'dprod = 495.000000 = 990 / 2 is greater than 400.0 and less than or equal to 500.0 for an RR of 5.0%')) self.assertEqual(pr.calc_gorr_percent(10000, 17, gorr), (6.0, 'dprod = 588.235294 = 10000 / 17 is greater than 500.0 for an RR of 6.0%')) self.assertRaises(TypeError, pr.calc_gorr_percent, None, 10, gorr) gorr = "mprod,250,2,300,3,400,4,500,5,0,6" self.assertEqual(pr.calc_gorr_percent(200, 10, gorr), (2.0, 'mprod = 200 is greater than 0.0 and less than or equal to 250.0 for an RR of 2.0%')) self.assertEqual(pr.calc_gorr_percent(300, 4, gorr), (3.0, 'mprod = 300 is greater than 250.0 and less than or equal to 300.0 for an RR of 3.0%')) self.assertEqual(pr.calc_gorr_percent(350.6, 1, gorr), (4.0, 'mprod = 350.6 is greater than 300.0 and less than or equal to 400.0 for an RR of 4.0%')) self.assertEqual(pr.calc_gorr_percent(410, 2, gorr), (5.0, 'mprod = 410 is greater than 400.0 and less than or equal to 500.0 for an RR of 5.0%')) self.assertEqual(pr.calc_gorr_percent(10000, 17, gorr), (6.0, 'mprod = 10000 is greater than 500.0 for an RR of 6.0%')) gorr = "fixed,0,2" self.assertEqual(pr.calc_gorr_percent(200, 10, gorr), (2.0, 'fixed for an RR of 2.0%')) self.assertEqual(pr.calc_gorr_percent(10000, 4, gorr), (2.0, 'fixed for an RR of 2.0%')) #In future make this raise an error: self.assertEqual(pr.calc_gorr_percent(None, 10, gorr), (2.0, 'fixed for an RR of 2.0%'))
def test_calcGorrPercent(self): pr = ProcessRoyalties() gorr = "bad string,0,2" self.assertRaises(AppError, pr.calc_gorr_percent, 400, 10, gorr) self.assertRaises(AppError, pr.calc_gorr_percent, None, 10, gorr) gorr = None, "0,2" self.assertRaises(AttributeError, pr.calc_gorr_percent, 400, 10, gorr) gorr = "dprod,250,2,300,3,400,4,500,5,0,6" self.assertEqual(pr.calc_gorr_percent(600, 10, gorr), ( 2.0, 'dprod = 60.000000 = 600 / 10 is greater than 0.0 and less than or equal to 250.0 for an RR of 2.0%' )) self.assertEqual(pr.calc_gorr_percent(1008, 4, gorr), ( 3.0, 'dprod = 252.000000 = 1008 / 4 is greater than 250.0 and less than or equal to 300.0 for an RR of 3.0%' )) self.assertEqual(pr.calc_gorr_percent(400, 1, gorr), ( 4.0, 'dprod = 400.000000 = 400 / 1 is greater than 300.0 and less than or equal to 400.0 for an RR of 4.0%' )) self.assertEqual(pr.calc_gorr_percent(990, 2, gorr), ( 5.0, 'dprod = 495.000000 = 990 / 2 is greater than 400.0 and less than or equal to 500.0 for an RR of 5.0%' )) self.assertEqual(pr.calc_gorr_percent(10000, 17, gorr), ( 6.0, 'dprod = 588.235294 = 10000 / 17 is greater than 500.0 for an RR of 6.0%' )) self.assertRaises(TypeError, pr.calc_gorr_percent, None, 10, gorr) gorr = "mprod,250,2,300,3,400,4,500,5,0,6" self.assertEqual(pr.calc_gorr_percent(200, 10, gorr), ( 2.0, 'mprod = 200 is greater than 0.0 and less than or equal to 250.0 for an RR of 2.0%' )) self.assertEqual(pr.calc_gorr_percent(300, 4, gorr), ( 3.0, 'mprod = 300 is greater than 250.0 and less than or equal to 300.0 for an RR of 3.0%' )) self.assertEqual(pr.calc_gorr_percent(350.6, 1, gorr), ( 4.0, 'mprod = 350.6 is greater than 300.0 and less than or equal to 400.0 for an RR of 4.0%' )) self.assertEqual(pr.calc_gorr_percent(410, 2, gorr), ( 5.0, 'mprod = 410 is greater than 400.0 and less than or equal to 500.0 for an RR of 5.0%' )) self.assertEqual( pr.calc_gorr_percent(10000, 17, gorr), (6.0, 'mprod = 10000 is greater than 500.0 for an RR of 6.0%')) gorr = "fixed,0,2" self.assertEqual(pr.calc_gorr_percent(200, 10, gorr), (2.0, 'fixed for an RR of 2.0%')) self.assertEqual(pr.calc_gorr_percent(10000, 4, gorr), (2.0, 'fixed for an RR of 2.0%')) #In future make this raise an error: self.assertEqual(pr.calc_gorr_percent(None, 10, gorr), (2.0, 'fixed for an RR of 2.0%'))
def test_calcSaskOilIOGR1995(self): m = DataStructure() m.WellHeadPrice = 221.123456 m.TransRate = 2.123455 m.ProcessingRate = 0.123455 m.ProdVol = 70 m.ProdMonth = 201501 calc = DataStructure() pr = ProcessRoyalties() #all tests for SaskWellHead pr.calc_sask_oil_iogr1995(datetime(2015, 1, 1), "SaskWellHead", 1.2, 0.25, m, calc) self.assertEqual(calc.IOGR1995RoyaltyValue,464.36) self.assertEqual(calc.CommencementPeriod,0) self.assertEqual(calc.IOGR1995RoyaltyVolume,7) self.assertEqual(calc.RoyaltyPrice,221.123456) m.ProdVol = 100 pr.calc_sask_oil_iogr1995(datetime(2015, 4, 2), "SaskWellHead", 0.25, 3, m, calc) self.assertEqual(calc.IOGR1995RoyaltyValue,1990.11) m.ProdVol = 170 pr.calc_sask_oil_iogr1995(datetime(2015, 5, 1), "SaskWellHead", 1, 1, m, calc) self.assertEqual(calc.IOGR1995RoyaltyValue, 5881.88) m.ProdVol = 79.9 pr.calc_sask_oil_iogr1995(datetime(2010, 1, 1), "SaskWellHead", 3, 2, m, calc) self.assertEqual(calc.IOGR1995RoyaltyValue,10600.66) m.ProdVol = 150 pr.calc_sask_oil_iogr1995(datetime(2009, 7, 3), "SaskWellHead", 2, 4, m, calc) self.assertEqual(calc.IOGR1995RoyaltyValue, 38917.73) m.ProdVol = 500 pr.calc_sask_oil_iogr1995(datetime(2007, 8, 2), "SaskWellHead", 1, 5, m, calc) self.assertEqual(calc.IOGR1995RoyaltyValue, 124271.38) m.ProdVol = 800 pr.calc_sask_oil_iogr1995(datetime(2008, 9, 9), "SaskWellHead", 5, 0.1, m, calc) self.assertEqual(calc.IOGR1995RoyaltyValue, 21117.29)
def test_calcSaskOilIOGR1995(self): m = DataStructure() m.WellHeadPrice = 221.123456 m.TransRate = 2.123455 m.ProcessingRate = 0.123455 m.ProdVol = 70 m.ProdMonth = 201501 calc = DataStructure() pr = ProcessRoyalties() #all tests for SaskWellHead pr.calc_sask_oil_iogr1995(datetime(2015, 1, 1), "SaskWellHead", 1.2, 0.25, m, calc) self.assertEqual(calc.IOGR1995RoyaltyValue, 464.36) self.assertEqual(calc.CommencementPeriod, 0) self.assertEqual(calc.IOGR1995RoyaltyVolume, 7) self.assertEqual(calc.RoyaltyPrice, 221.123456) m.ProdVol = 100 pr.calc_sask_oil_iogr1995(datetime(2015, 4, 2), "SaskWellHead", 0.25, 3, m, calc) self.assertEqual(calc.IOGR1995RoyaltyValue, 1990.11) m.ProdVol = 170 pr.calc_sask_oil_iogr1995(datetime(2015, 5, 1), "SaskWellHead", 1, 1, m, calc) self.assertEqual(calc.IOGR1995RoyaltyValue, 5881.88) m.ProdVol = 79.9 pr.calc_sask_oil_iogr1995(datetime(2010, 1, 1), "SaskWellHead", 3, 2, m, calc) self.assertEqual(calc.IOGR1995RoyaltyValue, 10600.66) m.ProdVol = 150 pr.calc_sask_oil_iogr1995(datetime(2009, 7, 3), "SaskWellHead", 2, 4, m, calc) self.assertEqual(calc.IOGR1995RoyaltyValue, 38917.73) m.ProdVol = 500 pr.calc_sask_oil_iogr1995(datetime(2007, 8, 2), "SaskWellHead", 1, 5, m, calc) self.assertEqual(calc.IOGR1995RoyaltyValue, 124271.38) m.ProdVol = 800 pr.calc_sask_oil_iogr1995(datetime(2008, 9, 9), "SaskWellHead", 5, 0.1, m, calc) self.assertEqual(calc.IOGR1995RoyaltyValue, 21117.29)