def test_checkNewRowNeededFail(): """Verify and exception is thrown because both rows have all the same values except for the Deal Registration Group""" oldRow = DealRegRow({ 'PART_NUM': 'SAPT000796', 'DEAL_REG_GROUP': 'IBM Brand', 'START_DATE': datetime(2018, 10, 9, 0, 0), 'END_DATE': datetime(9999, 12, 31, 0, 0), 'ACTIVE_FLAG': 'Y', 'ADD_DATE': datetime(2018, 12, 27, 21, 30, 21), 'MODIFIED_DATE': datetime(2018, 12, 27, 21, 30, 21) }) newRow = DealRegRow({ 'PART_NUM': 'SAPT000796', 'DEAL_REG_GROUP': 'Service Action', 'START_DATE': datetime(2018, 10, 9, 0, 0), 'END_DATE': datetime(9999, 12, 31, 0, 0), 'ACTIVE_FLAG': 'Y', 'ADD_DATE': datetime(2018, 12, 27, 21, 30, 21), 'MODIFIED_DATE': datetime(2018, 12, 27, 21, 30, 21) }) with pytest.raises(ValueError): process_deal_reg_data.checkNewRowNeeded(oldRow, newRow)
def test_checkNewRowNeededPass_useActiveFlag(): """Verify that the function returns true because both rows have the same end date and add date but the new row has an active flag of Y while the old one has N.""" oldRow = DealRegRow({ 'PART_NUM': 'SAPT000796', 'DEAL_REG_GROUP': 'Service Action', 'START_DATE': datetime(2018, 10, 9, 0, 0), 'END_DATE': datetime(9999, 12, 31, 0, 0), 'ACTIVE_FLAG': 'N', 'ADD_DATE': datetime(2018, 12, 27, 21, 30, 21), 'MODIFIED_DATE': datetime(2018, 12, 27, 21, 30, 21) }) newRow = DealRegRow({ 'PART_NUM': 'SAPT000796', 'DEAL_REG_GROUP': 'Service Action', 'START_DATE': datetime(2018, 10, 9, 0, 0), 'END_DATE': datetime(9999, 12, 31, 0, 0), 'ACTIVE_FLAG': 'Y', 'ADD_DATE': datetime(2018, 12, 27, 21, 30, 21), 'MODIFIED_DATE': datetime(2018, 12, 27, 21, 30, 21) }) assert process_deal_reg_data.checkNewRowNeeded(oldRow, newRow) == True
def test_checkNewRowNeededPass_useEndDate(): """Verify that the function returns false because the old row has and end date that comes after the new row.""" oldRow = DealRegRow({ 'PART_NUM': 'SAPT000796', 'DEAL_REG_GROUP': 'Service Action', 'START_DATE': datetime(2018, 10, 9, 0, 0), 'END_DATE': datetime(9999, 12, 31, 0, 0), 'ADD_DATE': datetime(2018, 12, 27, 21, 30, 21), 'MODIFIED_DATE': datetime(2018, 12, 27, 21, 30, 21) }) newRow = DealRegRow({ 'PART_NUM': 'SAPT000796', 'DEAL_REG_GROUP': 'Service Action', 'START_DATE': datetime(2018, 10, 9, 0, 0), 'END_DATE': datetime(2019, 10, 31, 0, 0), 'ADD_DATE': datetime(2018, 12, 27, 21, 30, 21), 'MODIFIED_DATE': datetime(2019, 10, 27, 21, 30, 21) }) assert process_deal_reg_data.checkNewRowNeeded(oldRow, newRow) == False