示例#1
0
class TestPayload(unittest.TestCase):

    def setUp(self):
        self.payload = Payload()
        self.payload.add({'red': 'special'})

    def test_add_payload(self):
        self.payload.add({'lazing': 'sunday'})
        assert_true('lazing' in self.payload.data)
        assert_equal(self.payload.data['lazing'], 'sunday')

    def test_add_by_key(self):
        self.payload.add({'lazing': 'sunday'}, 'afternoon')
        assert_false('lazing' in self.payload.data)
        assert_true('afternoon' in self.payload.options)
        assert_true('lazing' in self.payload.options['afternoon'])
        assert_equal(
            self.payload.options['afternoon']['lazing'],
            'sunday'
        )

    def test_requests_get(self):
        out = self.payload.to_requests('get')
        assert_true('params' in out)
        assert_equal(list(out['params']), [('red', 'special')])

    def test_requests_post(self):
        out = self.payload.to_requests('post')
        assert_true('data' in out)
        assert_equal(list(out['data']), [('red', 'special')])
示例#2
0
class TestPayload(unittest.TestCase):
    def setUp(self):
        self.payload = Payload()
        self.payload.add({'red': 'special'})

    def test_add_payload(self):
        self.payload.add({'lazing': 'sunday'})
        assert_true('lazing' in self.payload.data)
        assert_equal(self.payload.data['lazing'], 'sunday')

    def test_add_by_key(self):
        self.payload.add({'lazing': 'sunday'}, 'afternoon')
        assert_false('lazing' in self.payload.data)
        assert_true('afternoon' in self.payload.options)
        assert_true('lazing' in self.payload.options['afternoon'])
        assert_equal(self.payload.options['afternoon']['lazing'], 'sunday')

    def test_requests_get(self):
        out = self.payload.to_requests('get')
        assert_true('params' in out)
        assert_equal(list(out['params']), [('red', 'special')])

    def test_requests_post(self):
        out = self.payload.to_requests('post')
        assert_true('data' in out)
        assert_equal(list(out['data']), [('red', 'special')])
示例#3
0
 def setUp(self):
     self.payload = Payload()
     self.payload.add({'red': 'special'})
示例#4
0
 def setUp(self):
     self.payload = Payload()
     self.payload.add({'red': 'special'})