示例#1
0
    def test_str_success(self):
        # If the result is successful, include 'Success' and the email
        # in the string.
        result = base.VerificationResult({'status': 'okay', 'email': '*****@*****.**'})
        eq_(six.text_type(result), '<VerificationResult Success [email protected]>')

        # If the email is missing, don't include it.
        result = base.VerificationResult({'status': 'okay'})
        eq_(six.text_type(result), '<VerificationResult Success>')
 def test_expires_valid_timestamp(self):
     """
     If expires contains a valid millisecond timestamp, return a
     corresponding datetime.
     """
     result = base.VerificationResult({'expires': '1379307128000'})
     self.assertEqual(datetime(2013, 9, 16, 4, 52, 8), result.expires)
 def test_expires_invalid_timestamp(self):
     """
     If the expires attribute cannot be parsed as a timestamp, return
     the raw string instead.
     """
     result = base.VerificationResult({'expires': 'foasdfhas'})
     self.assertEqual(result.expires, 'foasdfhas')
 def test_getattr_attribute_exists(self):
     """
     If a value exists in the response dict, it should be an
     attribute on the result.
     """
     result = base.VerificationResult({'myattr': 'foo'})
     self.assertEqual(result.myattr, 'foo')
示例#5
0
 def test_str_unicode(self):
     # Ensure that __str__ can handle unicode values.
     result = base.VerificationResult({
         'status': 'okay',
         'email': six.u('\[email protected]')
     })
     eq_(six.text_type(result),
         six.u('<VerificationResult Success email=\[email protected]>'))
 def test_expires_no_attribute(self):
     """
     If no expires attribute was in the response, raise an
     AttributeError.
     """
     result = base.VerificationResult({'myattr': 'foo'})
     with self.assertRaises(AttributeError):
         result.expires
 def test_getattr_attribute_doesnt_exist(self):
     """
     If a value doesn't exist in the response dict, accessing it as
     an attribute should raise an AttributeError.
     """
     result = base.VerificationResult({'myattr': 'foo'})
     with self.assertRaises(AttributeError):
         result.bar
示例#8
0
 def test_str_failure(self):
     # If the result is a failure, include 'Failure' in the string.
     result = base.VerificationResult({'status': 'failure'})
     eq_(six.text_type(result), '<VerificationResult Failure>')
示例#9
0
 def test_nonzero_okay(self):
     # If the response status is 'okay', the result should be truthy.
     ok_(base.VerificationResult({'status': 'okay'}))
示例#10
0
 def test_nonzero_failure(self):
     # If the response status is not 'okay', the result should be
     # falsy.
     ok_(not base.VerificationResult({'status': 'failure'}))
示例#11
0
 def test_expires_valid_timestamp(self):
     # If expires contains a valid millisecond timestamp, return a
     # corresponding datetime.
     result = base.VerificationResult({'expires': '1379307128000'})
     eq_(datetime(2013, 9, 16, 4, 52, 8), result.expires)
示例#12
0
 def test_expires_invalid_timestamp(self):
     # If the expires attribute cannot be parsed as a timestamp,
     # return the raw string instead.
     result = base.VerificationResult({'expires': 'foasdfhas'})
     eq_(result.expires, 'foasdfhas')
示例#13
0
 def test_getattr_attribute_exists(self):
     # If a value exists in the response dict, it should be an
     # attribute on the result.
     result = base.VerificationResult({'myattr': 'foo'})
     eq_(result.myattr, 'foo')
示例#14
0
 def test_str_failure(self):
     """
     If the result is a failure, include 'Failure' in the string.
     """
     result = base.VerificationResult({'status': 'failure'})
     self.assertEqual(six.text_type(result), '<VerificationResult Failure>')
示例#15
0
 def test_nonzero_okay(self):
     """
     If the response status is 'okay', the result should be truthy.
     """
     self.assertTrue(base.VerificationResult({'status': 'okay'}))
示例#16
0
 def test_nonzero_failure(self):
     """
     If the response status is not 'okay', the result should be
     falsy.
     """
     self.assertTrue(not base.VerificationResult({'status': 'failure'}))