def test_nil(self): result = CVVResult(nil) self.assert_none(result.code) self.assert_none(result.message) result = CVVResult('') self.assert_none(result.code) self.assert_none(result.message)
def __init__(self, success, message, result={}, **options): self.success = success self.message = message self.result = result self.options = options #TODO pick one self.test = options.setdefault('test', False) self.is_test = self.options['is_test'] #CONSIDER what is the difference between authorization and transaction? self.authorization = self.options.get('authorization') self.transaction = self.options.get('transaction') self.card_store_id = self.options.get('card_store_id') self.fraud_review = self.options.get('fraud_review') self.avs_result = self.options.get('avs_result') self.cvv_result = self.options.get('cvv_result') if self.avs_result: self.avs_result = AVSResult(code=self.avs_result) if self.cvv_result: self.cvv_result = CVVResult(code=self.cvv_result)
def test_lowercase_match(self): result = CVVResult("u") self.assert_equal("U", result.code) self.assert_equal(MESSAGES["U"], result.message) self.assert_equal(result.messages("U"), result.message)
def test_successful_match(self): result = CVVResult("M") self.assert_equal("M", result.code) self.assert_equal(MESSAGES["M"], result.message) self.assert_equal(result.messages("M"), result.message)
def test_to_hash(self): result = CVVResult('M').to_hash() self.assert_equal('M', result['code']) self.assert_equal(MESSAGES['M'], result['message'])
def test_unknown_code(self): result = CVVResult('Confringo') self.assert_equal('Confringo', result.code) self.assert_equal("Unknown code 'Confringo'", result.message)
def test_lowercase_match(self): result = CVVResult('u') self.assert_equal('U', result.code) self.assert_equal(MESSAGES['U'], result.message) self.assert_equal(result.messages('U'), result.message)
def test_failed_match(self): result = CVVResult('N') self.assert_equal('N', result.code) self.assert_equal('No Match', result.message)
def test_successful_match(self): result = CVVResult('M') self.assert_equal('M', result.code) self.assert_equal(MESSAGES['M'], result.message) self.assert_equal(result.messages('M'), result.message)