Skip to content

Commit

Permalink
Align file names and command names
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinMind committed Sep 24, 2024
1 parent b99def4 commit 74812d5
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions Makefile-docker
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ check: check_files check_olympia_user check_debian_packages check_pip_packages c

.PHONY: data_dump
data_dump:
./manage.py dump_data $(ARGS)
./manage.py data_dump $(ARGS)

.PHONY: data_load
data_load:
./manage.py load_data $(ARGS)
./manage.py data_load $(ARGS)

.PHONY: initialize_db
initialize_db: ## create a new database
rm -rf ./user-media/* ./tmp/*
./manage.py seed_data
./manage.py data_seed

.PHONY: reindex_data
reindex_data: ## reindex the data in elasticsearch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ def handle(self, *args, **options):

self.call_command('generate_default_addons_for_frontend')

self.call_command('dump_data', '--name', self.data_backup_init)
self.call_command('data_dump', '--name', self.data_backup_init)
36 changes: 18 additions & 18 deletions src/olympia/amo/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ class BaseTestDataCommand(TestCase):
class Commands:
flush = mock.call('flush', '--noinput')
migrate = mock.call('migrate', '--noinput')
seed_data = mock.call('seed_data')
data_seed = mock.call('data_seed')
reindex = mock.call('reindex', '--noinput', '--force')

flush = mock.call('flush', '--noinput')
Expand All @@ -360,17 +360,17 @@ class Commands:
'generate_default_addons_for_frontend'
)

def dump_data(self, name='_init'):
return mock.call('dump_data', '--name', name)
def data_dump(self, name='_init'):
return mock.call('data_dump', '--name', name)

def generate_addons(self, app, num_addons):
return mock.call('generate_addons', '--app', app, num_addons)

def generate_themes(self, num_themes):
return mock.call('generate_themes', num_themes)

def load_data(self, name='_init'):
return mock.call('load_data', f'--name={name}')
def data_load(self, name='_init'):
return mock.call('data_load', f'--name={name}')

def db_backup(self, output_path):
return mock.call(
Expand Down Expand Up @@ -500,11 +500,11 @@ def setUp(self):
patches = (
(
'mock_make_dir',
'olympia.amo.management.commands.dump_data.BaseDataCommand.make_dir',
'olympia.amo.management.commands.data_dump.BaseDataCommand.make_dir',
),
(
'mock_call_command',
'olympia.amo.management.commands.dump_data.BaseDataCommand.call_command',
'olympia.amo.management.commands.data_dump.BaseDataCommand.call_command',
),
)
self.mocks = {}
Expand All @@ -521,7 +521,7 @@ def test_default_name(self):
db_path = os.path.join(backup_dir, self.db_file)
storage_path = os.path.join(backup_dir, self.storage_file)

call_command('dump_data')
call_command('data_dump')
self.mocks['mock_make_dir'].assert_called_with(backup_dir, force=False)
self._assert_commands_called_in_order(
self.mocks['mock_call_command'],
Expand All @@ -535,7 +535,7 @@ def test_custom_name(self):
name = 'test'
backup_dir = os.path.join(self.backup_dir, name)

call_command('dump_data', name=name)
call_command('data_dump', name=name)
self.mocks['mock_make_dir'].assert_called_with(backup_dir, force=False)


Expand All @@ -545,18 +545,18 @@ def setUp(self):

def test_missing_name(self):
with pytest.raises(CommandError):
call_command('load_data')
call_command('data_load')

@mock.patch(
'olympia.amo.management.commands.load_data.BaseDataCommand.call_command'
'olympia.amo.management.commands.data_load.BaseDataCommand.call_command'
)
def test_loads_correct_path(self, mock_call_command):
name = 'test_backup'
backup_dir = os.path.join(self.backup_dir, name)
db_path = os.path.join(backup_dir, self.db_file)
storage_path = os.path.join(backup_dir, self.storage_file)

call_command('load_data', name=name)
call_command('data_load', name=name)

self._assert_commands_called_in_order(
mock_call_command,
Expand All @@ -566,9 +566,9 @@ def test_loads_correct_path(self, mock_call_command):
],
)

def test_load_data_with_missing_data(self):
def test_data_load_with_missing_data(self):
with pytest.raises(CommandError) as context:
call_command('load_data', name='test_backup')
call_command('data_load', name='test_backup')
assert 'Directory not found' in str(context.value)


Expand All @@ -579,11 +579,11 @@ def setUp(self):
patches = (
(
'mock_call_command',
'olympia.amo.management.commands.seed_data.BaseDataCommand.call_command',
'olympia.amo.management.commands.data_seed.BaseDataCommand.call_command',
),
(
'mock_clean_dir',
'olympia.amo.management.commands.seed_data.BaseDataCommand.clean_dir',
'olympia.amo.management.commands.data_seed.BaseDataCommand.clean_dir',
),
)

Expand All @@ -595,7 +595,7 @@ def setUp(self):
self.mocks[mock_name] = patcher.start()

def test_default(self):
call_command('seed_data')
call_command('data_seed')

self._assert_commands_called_in_order(
self.mocks['mock_call_command'],
Expand All @@ -611,6 +611,6 @@ def test_default(self):
self.mock_commands.generate_addons('android', 10),
self.mock_commands.generate_themes(5),
self.mock_commands.generate_default_addons_for_frontend,
self.mock_commands.dump_data(self.base_data_command.data_backup_init),
self.mock_commands.data_dump(self.base_data_command.data_backup_init),
],
)

0 comments on commit 74812d5

Please sign in to comment.