コード例 #1
0
    def test_delete(self):
        factory = RequestFactory()
        request = mock()
        requestResponse = Bunch(status_code = 200, content="testContent") 
        when(request).delete(any()).thenReturn(requestResponse)
        factory.getRequests = lambda: request

        factory.delete({'id' : 22})
        self.assertEqual(u"http://api/22", factory.delete_url)
        verify(request).delete(u"http://api/22")
コード例 #2
0
    def test_save(self):
        factory = RequestFactory()
        request = mock()
        requestResponse = Bunch(status_code = 200, content="testContent") 
        when(request).post(any(), any()).thenReturn(requestResponse)
        factory.getRequests = lambda: request
        factory.save({'id' : 22})
#        verifyZeroInteractions(request)

        verify(request).post(u"http://api/add", '{"id": 22}')