コード例 #1
0
    def test_urlencode(self):
        assert "name=name1&url=http%3A%2F%2Ffoo.com" == util.urlencode(name="name1", url="http://foo.com")

        now = datetime.datetime.now()

        expected = "day=%s&hour=%s&minute=%s&month=%s&name=name1&second=%s&url=http%%3A%%2F%%2Ffoo.com&year=%s" % (now.day, now.hour, now.minute, now.month, now.second, now.year)

        assert expected == util.urlencode(util.to_tuplelist(now), name="name1", url="http://foo.com")
コード例 #2
0
    def test_to_tuplelist(self):
        now = datetime.datetime.now()

        now_tuple = util.to_tuplelist(now)

        assert [
                ("year", now.year),
                ("month", now.month),
                ("day", now.day),
                ("hour", now.hour),
                ("minute", now.minute),
                ("second", now.second)
                ] == now_tuple