Exemple #1
0
 def test_create_myurl(self):
     """Test creation of myurl"""
     # create a MyURL
     m = MyUrl(to_url=self.test_url,
               user_id='1',
               utm_campaign='1',
               utm_term='narf',
               utm_medium='test',
               utm_source='clouds',
               utm_content='stringsandstrings',
               append_text='gianttrex')
     # save it
     m.save()
     # check that it worked
     self.assertEqual(m.to_url, self.test_url)
     # calculate basex for pk
     s = BaseX(m.pk)
     url = Site.objects.get(pk=1).domain
     url = u'%s%s/%s' % (settings.MYURLS_DEFAULT_SCHEME, url, s.encoded)
     # Test short URL
     self.assertEqual(m.short_url, url)
     # Test appended stuff
     self.assertEqual(
         m.redirect_url,
         u'http://directemployersfoundation.org?utm_campaign=1&utm_term=narf&utm_content=stringsandstrings&utm_medium=test&utm_source=clouds&gianttrex'
     )
 def test_create_myurl(self):
     """Test creation of myurl"""        
     # create a MyURL
     m = MyUrl(to_url=self.test_url,
               user_id = '1',
               utm_campaign='1',
               utm_term='narf', 
               utm_medium='test',
               utm_source='clouds',
               utm_content='stringsandstrings',
               append_text='gianttrex')
     # save it
     m.save()
     # check that it worked
     self.assertEqual(m.to_url, self.test_url)
     # calculate basex for pk
     s = BaseX(m.pk)
     url = Site.objects.get(pk=1).domain
     url = u'%s%s/%s' % (settings.MYURLS_DEFAULT_SCHEME, url, s.encoded)
     # Test short URL
     self.assertEqual(m.short_url, url)
     # Test appended stuff
     self.assertEqual(m.redirect_url, u'http://directemployersfoundation.org?utm_campaign=1&utm_term=narf&utm_content=stringsandstrings&utm_medium=test&utm_source=clouds&gianttrex')
 def test_create_click(self):
     """Test that clicks are created"""
     myurl = MyUrl(to_url="http://example.com",
               user_id = '1',
               utm_campaign='1',
               utm_term='narf', 
               utm_medium='test',
               utm_source='clouds',
               utm_content='stringsandstrings',
               append_text='gianttrex')
     myurl.save()
     click = Click (myurl=myurl,
                   to_url=myurl.to_url,
                   redirect_url=myurl.redirect_url,
                   referrer_domain='referrerhost.com',
                   referrer_url='referrerhost.com/url',
                   site=Site.objects.get_current(),
                   user_id='1',
                   user_ip='192.168.1.1',
                   user_language='language',
                   user_agent='awesome')
     click.save()
     self.assertEqual(click, Click.objects.get(pk=click.pk))
Exemple #4
0
 def test_create_click(self):
     """Test that clicks are created"""
     myurl = MyUrl(to_url="http://example.com",
                   user_id='1',
                   utm_campaign='1',
                   utm_term='narf',
                   utm_medium='test',
                   utm_source='clouds',
                   utm_content='stringsandstrings',
                   append_text='gianttrex')
     myurl.save()
     click = Click(myurl=myurl,
                   to_url=myurl.to_url,
                   redirect_url=myurl.redirect_url,
                   referrer_domain='referrerhost.com',
                   referrer_url='referrerhost.com/url',
                   site=Site.objects.get_current(),
                   user_id='1',
                   user_ip='192.168.1.1',
                   user_language='language',
                   user_agent='awesome')
     click.save()
     self.assertEqual(click, Click.objects.get(pk=click.pk))
Exemple #5
0
 def test_change_myurl(self):
     """Test saving change in myurl"""
     # create a MyURL with different site
     m = MyUrl(to_url=self.test_url,
               user_id='1',
               utm_campaign='1',
               utm_term='narf',
               utm_medium='test',
               utm_source='clouds',
               utm_content='stringsandstrings',
               append_text='gianttrex')
     # Save it
     m.save()
     # change the site
     m.to_url = u'http://schmuckatelli.com'
     m.save()
     # make sure save updates redirect_url
     self.assertEqual(m.to_url, u'http://schmuckatelli.com')
     self.assertEqual(
         m.redirect_url,
         u'http://schmuckatelli.com?utm_campaign=1&utm_term=narf&utm_content=stringsandstrings&utm_medium=test&utm_source=clouds&gianttrex'
     )
 def test_change_myurl(self):
     """Test saving change in myurl"""
     # create a MyURL with different site
     m = MyUrl(to_url=self.test_url,
               user_id = '1',
               utm_campaign='1',
               utm_term='narf', 
               utm_medium='test',
               utm_source='clouds',
               utm_content='stringsandstrings',
               append_text='gianttrex')
     # Save it
     m.save()
     # change the site
     m.to_url = u'http://schmuckatelli.com'
     m.save()
     # make sure save updates redirect_url
     self.assertEqual(m.to_url, u'http://schmuckatelli.com')
     self.assertEqual(m.redirect_url, 
         u'http://schmuckatelli.com?utm_campaign=1&utm_term=narf&utm_content=stringsandstrings&utm_medium=test&utm_source=clouds&gianttrex')