def test_check_state_waiting(self, mock): """ Tests check_state raises BackendError because the state field is "waiting" """ mock.get(drupal.CHECK_TASKS_URL.format(id="1"), json=CLEAR_CACHE_RESPONSE_WAITING) with self.assertRaises(BackendError): drupal.check_state(task_id="1", username=TEST_USERNAME, password=TEST_PASSWORD)
def test_check_state_waiting(self): """ Tests check_state raises BackendError because the state field is "waiting" """ httpretty.register_uri( httpretty.GET, drupal.CHECK_TASKS_URL.format(id="1"), body=CLEAR_CACHE_RESPONSE_WAITING, content_type="application/json", ) with self.assertRaises(BackendError): drupal.check_state(task_id="1", username=TEST_USERNAME, password=TEST_PASSWORD)
def test_check_state_waiting(self, mock_get_request): """ Tests check_state raises BackendError because the status field is "In Progress" """ mock_get_request.return_value = Mock() mock_get_request.return_value.status_code = 200 mock_get_request.return_value.json.return_value = { 'status': 'In Progress' } with self.assertRaises(BackendError): drupal.check_state(TEST_NOTIFICATION_URL, token=TEST_TOKEN)
def test_check_state_done(self, mock): """ Tests check_state returns True because the state field is "done" """ mock.get(drupal.CHECK_TASKS_URL.format(id="1"), json=CLEAR_CACHE_RESPONSE_DONE) self.assertTrue( drupal.check_state(task_id="1", username=TEST_USERNAME, password=TEST_PASSWORD))
def test_check_state_done(self): """ Tests check_state returns True because the state field is "done" """ httpretty.register_uri( httpretty.GET, drupal.CHECK_TASKS_URL.format(id="1"), body=CLEAR_CACHE_RESPONSE_DONE, content_type="application/json", ) self.assertTrue(drupal.check_state(task_id="1", username=TEST_USERNAME, password=TEST_PASSWORD))
def test_check_state_done(self, mock_get_request): """ Tests check_state returns True because the status field is "completed" """ mock_get_request.return_value = Mock() mock_get_request.return_value.status_code = 200 mock_get_request.return_value.json.return_value = { 'status': 'completed' } self.assertTrue( drupal.check_state(TEST_NOTIFICATION_URL, token=TEST_TOKEN))