Esempio n. 1
0
 def test_deploy_invalid_environment(self, _mock):
     """
     Tests KeyError is raised when an invalid environment is attempted.
     """
     with self.assertRaises(KeyError):
         drupal.deploy(env="failure",
                       username=TEST_USERNAME,
                       password=TEST_PASSWORD,
                       branch_or_tag=TEST_TAG)
Esempio n. 2
0
 def test_deploy_invalid_environment(self):
     """
     Tests KeyError is raised when an invalid environment is attempted.
     """
     with self.assertRaises(KeyError):
         drupal.deploy(app_id=ACQUIA_APP_ID,
                       env='failure',
                       client_id=TEST_CLIENT_ID,
                       secret=TEST_SECRET,
                       branch_or_tag=TEST_TAG)
Esempio n. 3
0
def deploy(env, username, password, tag):
    """
    Deploys a given tag to the specified environment.

    Args:
        env (str): The environment to deploy code in (e.g. test or prod)
        username (str): The Acquia username necessary to run the command.
        password (str): The Acquia password necessary to run the command.
        tag (str): The tag to deploy to the specified environment.
    """
    drupal.deploy(env, username, password, tag)
Esempio n. 4
0
def deploy(env, username, password, tag):
    """
    Deploys a given tag to the specified environment.

    Args:
        env (str): The environment to deploy code in (e.g. test or prod)
        username (str): The Acquia username necessary to run the command.
        password (str): The Acquia password necessary to run the command.
        tag (str): The tag to deploy to the specified environment.
    """
    drupal.deploy(env, username, password, tag)
Esempio n. 5
0
def deploy(app_id, env, client_id, secret, branch_or_tag):
    """
    Deploys a given tag to the specified environment.

    Arguments:
        app_id (str): The application id for drupal instance.
        env (str): The environment to deploy code in (e.g. test or prod)
        client_id (str): The Acquia api client id necessary to run the command.
        secret (str): The Acquia api secret key to run the command.
        branch_or_tag (str): The branch or tag to deploy to the specified environment.
    """
    drupal.deploy(app_id, env, client_id, secret, branch_or_tag)
Esempio n. 6
0
 def test_deploy_failure(self, mock):
     """
     Tests deploy raises BackendError when status != 200
     """
     mock.post(drupal.DEPLOY_URL.format(env=ACQUIA_ENV, tag=TEST_TAG),
               json={},
               status_code=501)
     with self.assertRaises(BackendError):
         drupal.deploy(env=ACQUIA_ENV,
                       username=TEST_USERNAME,
                       password=TEST_PASSWORD,
                       tag=TEST_TAG)
Esempio n. 7
0
 def test_deploy_failure(self):
     """
     Tests deploy raises BackendError when status != 200
     """
     httpretty.register_uri(
         httpretty.POST,
         drupal.DEPLOY_URL.format(env=ACQUIA_ENV, tag=TEST_TAG),
         body="{}",
         content_type="application/json",
         status=501,
     )
     with self.assertRaises(BackendError):
         drupal.deploy(env=ACQUIA_ENV, username=TEST_USERNAME, password=TEST_PASSWORD, tag=TEST_TAG)
Esempio n. 8
0
    def test_deploy_success(self, mock_env_id, mock_token, mock_post_request,
                            mock_get_request):
        """
        Tests deploy returns True when there is a valid response.
        """
        mock_env_id.return_value = ACQUIA_ENV_ID
        mock_token.return_value = TEST_TOKEN
        mock_post_request.return_value = Mock()
        mock_post_request.return_value.status_code = 202
        mock_post_request.return_value.json.return_value = {
            '_links': {
                'notification': {
                    'href': TEST_NOTIFICATION_URL
                }
            }
        }
        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.deploy(app_id=ACQUIA_APP_ID,
                          env=ACQUIA_ENV,
                          client_id=TEST_CLIENT_ID,
                          secret=TEST_SECRET,
                          branch_or_tag=TEST_TAG))
Esempio n. 9
0
    def test_deploy_failure(self, mock_env_id, mock_token, mock_post_request):
        """
        Tests deploy raises BackendError when status != 200
        """

        mock_env_id.return_value = ACQUIA_ENV_ID
        mock_token.return_value = TEST_TOKEN
        mock_post_request.return_value = Mock()
        mock_post_request.return_value.status_code = 400

        with self.assertRaises(BackendError):
            drupal.deploy(app_id=ACQUIA_APP_ID,
                          env=ACQUIA_ENV,
                          client_id=TEST_CLIENT_ID,
                          secret=TEST_SECRET,
                          branch_or_tag=TEST_TAG)
Esempio n. 10
0
 def test_deploy_success(self, mock):
     """
     Tests deploy returns True when there is a valid response.
     """
     mock.post(
         drupal.DEPLOY_URL.format(env=ACQUIA_ENV, branch_or_tag=TEST_TAG),
         json=DEPLOY_RESPONSE_WAITING,
     )
     mock.get(drupal.CHECK_TASKS_URL.format(id="2"),
              json=DEPLOY_RESPONSE_DONE)
     self.assertTrue(
         drupal.deploy(env=ACQUIA_ENV,
                       username=TEST_USERNAME,
                       password=TEST_PASSWORD,
                       branch_or_tag=TEST_TAG))
Esempio n. 11
0
 def test_deploy_success(self):
     """
     Tests deploy returns True when there is a valid response.
     """
     httpretty.register_uri(
         httpretty.POST,
         drupal.DEPLOY_URL.format(env=ACQUIA_ENV, tag=TEST_TAG),
         body=DEPLOY_RESPONSE_WAITING,
         content_type="application/json",
     )
     httpretty.register_uri(
         httpretty.GET,
         drupal.CHECK_TASKS_URL.format(id="2"),
         body=DEPLOY_RESPONSE_DONE,
         content_type="application/json",
     )
     self.assertTrue(drupal.deploy(env=ACQUIA_ENV, username=TEST_USERNAME, password=TEST_PASSWORD, tag=TEST_TAG))
Esempio n. 12
0
 def test_deploy_invalid_environment(self):
     """
     Tests KeyError is raised when an invalid environment is attempted.
     """
     with self.assertRaises(KeyError):
         drupal.deploy(env="failure", username=TEST_USERNAME, password=TEST_PASSWORD, tag=TEST_TAG)