def test_get_deployable_environment_branch(self): """ Tests the model method that should return an environment after correctly validating a branch push event from github """ github_event = GithubWebhookSerializer(data=self.git_message) if github_event.is_valid(): event = github_event.get_change_location() is_tag_event = github_event.is_tag_event() matching_env = self.site.get_deployable_environment( event, is_tag_event) self.assertEqual(matching_env, self.env) else: self.fail(github_event.errors)
def test_get_deployable_environment_wrong_branch(self): """ Tests the model method does not return an environment after correctly validating a branch push event from github for a non-registered branch """ self.git_message['ref'] = 'refs/heads/staging' github_event = GithubWebhookSerializer(data=self.git_message) if github_event.is_valid(): event = github_event.get_change_location() is_tag_event = github_event.is_tag_event() matching_env = self.site.get_deployable_environment( event, is_tag_event) self.assertIsNone(matching_env) else: self.fail(github_event.errors)