Exemplo n.º 1
0
Arquivo: tests.py Projeto: slok/dwarf
    def test_click_link(self):

        data = {
            "LANG": "en_US",
            "REMOTE_ADDR": "72.14.207.99",
            "HTTP_USER_AGENT": "Mozilla/5.0 (X11; Linux x86_64; rv:17.0)" + " Gecko/17.0 Firefox/17.0",
        }

        # Prepare the database
        counter = random.randrange(0, 100000)
        url = "http://xlarrakoetxea.org"
        sl = ShortLink(counter=counter, url=url)
        sl.save()

        # Call teh task
        result = tasks.click_link.delay(sl.token, data)
        # Wait (for testing only)
        result.get()

        # Check the stored information
        c = Click.find(sl.token, 1)

        self.assertEquals("en_US", c.language)
        self.assertEquals("linux x86_64", c.os)
        self.assertEquals("firefox", c.browser)
        self.assertEquals("72.14.207.99", c.ip)
        self.assertEquals("US", c.location)
Exemplo n.º 2
0
Arquivo: tests.py Projeto: slok/dwarf
    def test_click_find(self):
        token = utils.counter_to_token(random.randrange(0, 100000))
        OS = "linux"
        ip = "111.222.333.444"
        browser = "firefox"
        click_date = dateutils.unix_now_utc()
        language = "EN_us"
        location = "US"
        url = "http://xlarrakoetxea.org"

        sl = ShortLink(token=token, url=url)
        sl.save()

        c = Click(
            token=token, os=OS, ip=ip, browser=browser, click_date=click_date, language=language, location=location
        )
        c.save()

        c2 = Click.find(token, c.click_id)
        self.assertEquals(c, c2)