Skip to content

Commit

Permalink
Fail CI if import scripts can't run
Browse files Browse the repository at this point in the history
  • Loading branch information
symroe committed May 24, 2024
1 parent e1e8fff commit 0070452
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import boto3
import botocore
from django.apps import apps
from django.core.management import BaseCommand, call_command
from django.core.management import BaseCommand, CommandError, call_command


def get_paths_changed(from_sha, to_sha):
Expand Down Expand Up @@ -182,7 +182,7 @@ def handle(self, *args, **options):
self.run_misc_fixes()
self.update_last_import_sha_on_ssm(to_sha)
elif has_imports and has_application and not is_post_deploy:
self.stdout.write("Need to deploy before running import scripts\n")
raise CommandError("Need to deploy before running import scripts\n")
elif not has_imports:
self.stdout.write(
"No import scripts have changed. So nothing new to import.\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
git_rev_parse,
is_import_script,
)
from django.core.management import call_command
from django.core.management import CommandError, call_command
from django.test import TestCase

no_scripts = [
Expand Down Expand Up @@ -189,15 +189,16 @@ def test_called_without_mock(self):
def test_called_with_app_and_scripts_before_deploy(self):
out = StringIO()
(to_sha, from_sha) = self.cases["scripts_and_app"]
with self.assertRaises(CommandError) as e:
call_command(
self.run_new_imports_name,
to_sha=to_sha,
from_sha=from_sha,
stdout=out,
)

call_command(
self.run_new_imports_name,
to_sha=to_sha,
from_sha=from_sha,
stdout=out,
)
expected_std_out = "Need to deploy before running import scripts\n"
self.assertIn(expected_std_out, out.getvalue())
self.assertIn(expected_std_out, str(e.exception))

@patch(
"data_importers.management.commands.run_new_imports.Command.run_scripts",
Expand Down

0 comments on commit 0070452

Please sign in to comment.