Esempio n. 1
0
 def test_get_next_number(self):
     """Verify the client can get the next number for a document."""
     mock_response = Mock()
     mock_response.status_code = 200
     mock_response.json = Mock(return_value={'next': 42})
     mock_post = Mock(return_value=mock_response)
     # Act
     with patch('requests.post', mock_post):
         number = client.get_next_number('PREFIX')
     # Assert
     url = 'http://1.2.3.4:8080/documents/PREFIX/numbers'
     headers = {'content-type': 'application/json'}
     mock_post.assert_called_once_with(url, headers=headers)
     self.assertEqual(42, number)
Esempio n. 2
0
 def test_get_next_number(self):
     """Verify the client can get the next number for a document."""
     mock_response = Mock()
     mock_response.status_code = 200
     mock_response.json = Mock(return_value={'next': 42})
     mock_post = Mock(return_value=mock_response)
     # Act
     with patch('requests.post', mock_post):
         number = client.get_next_number('PREFIX')
     # Assert
     url = 'http://1.2.3.4:8080/documents/PREFIX/numbers'
     headers = {'content-type': 'application/json'}
     mock_post.assert_called_once_with(url, headers=headers)
     self.assertEqual(42, number)
Esempio n. 3
0
 def test_get_next_number_no_server(self):
     """Verify the next number for a document is None with no server."""
     self.assertIs(None, client.get_next_number('PREFIX'))
Esempio n. 4
0
 def test_get_next_number_no_server(self):
     """Verify the next number for a document is None with no server."""
     self.assertIs(None, client.get_next_number('PREFIX'))