Example #1
0
 def test_basic(self):
     # A very simple test.  Only tests that the hash function exists and 
     # returns the same hash value when given the same input.
     
     from linkanalytics.models import _create_uuid
     i = _create_uuid()
     s = 'This is some data to be hashed.'
     
     a = urlex.generate_urlhash(i,s)
     b = urlex.generate_urlhash(i,s)
     
     self.assertEquals(a, b)
Example #2
0
 def test_hashValidation(self):        
     t = self.new_tracker(name='Name1')
     v = self.new_visitor(username='******')
     i = t.add_visitor(v)
     
     # This first try will contain a hash calculated for a different url.
     hash = urlex.generate_urlhash(i.uuid, '/linkanalytics/nonexistent_url/')
     urltail = urlex.urltail_redirect_local('linkanalytics/testurl/')
     url = urlex.assemble_hashedurl(hash, i.uuid, urltail)
     # This should not pass the hash checker
     response = self.client.get(url, follow=True)
     self.assertEquals(response.status_code, 404)
     
     url = urlex.hashedurl_redirect_local(i.uuid, 'linkanalytics/testurl/')
     # This now should pass the hash checker
     response = self.client.get(url, follow=True)
     self.assertEquals(response.status_code, 200)
     self.assertEquals(len(response.redirect_chain),1)
Example #3
0
 def generate_hash(self, data):
     """Creates a hash value appropriate for this TrackedInstance.  The 
        data parameter is the value that should appear after the uuid.
     """
     return urlex.generate_urlhash(self.uuid, data)