def activate(self, actions): """Register hooks to generate project using django-admin. Args: actions (list): list of actions to perform Returns: list: updated list of actions """ # `get_default_options` uses passed options to compute derived ones, # so it is better to prepend actions that modify options. actions = helpers.register(actions, enforce_django_options, before="get_default_options") # `apply_update_rules` uses CWD information, # so it is better to prepend actions that modify it. actions = helpers.register(actions, create_django_proj, before="apply_update_rules") actions = helpers.register(actions, fix_django_settings, before="apply_update_rules") return actions
def test_register_default_position(): # Given an action list with define_structure, actions = [api.init_git, define_structure, init_git] # When a new action is registered without position reference, actions = helpers.register(actions, custom_action) # Then this action should be placed after define_structure assert actions == [api.init_git, define_structure, custom_action, init_git]
def test_register_default_position(): # Given an action list with define_structure, actions = [api.init_git, define_structure, init_git] # When a new action is registered without position reference, actions = helpers.register(actions, custom_action) # Then this action should be placed after define_structure assert actions == [api.init_git, define_structure, custom_action, init_git]
def test_register_after(): # Given an action list, actions = [api.init_git] # When a new action is registered after another, using the function name # as position reference, actions = helpers.register(actions, custom_action, after='init_git') # Then this action should be correctly placed assert actions == [api.init_git, custom_action]
def test_register_after(): # Given an action list, actions = [api.init_git] # When a new action is registered after another, using the function name # as position reference, actions = helpers.register(actions, custom_action, after='init_git') # Then this action should be correctly placed assert actions == [api.init_git, custom_action]
def test_register_with_qualified_name(): # Given an action list with actions that share the same name, actions = [api.init_git, init_git] # When a new action is registered using the "qualified" name # (module+function) as position reference, actions = helpers.register(actions, custom_action, after='pyscaffold.api:init_git') # Then this action should be correctly placed assert actions == [api.init_git, custom_action, init_git]
def test_register_with_qualified_name(): # Given an action list with actions that share the same name, actions = [api.init_git, init_git] # When a new action is registered using the "qualified" name # (module+function) as position reference, actions = helpers.register(actions, custom_action, after='pyscaffold.api:init_git') # Then this action should be correctly placed assert actions == [api.init_git, custom_action, init_git]
def test_register_with_invalid_reference(): # Given an action list, actions = [api.init_git] # When a new action is registered using an invalid reference, with pytest.raises(ActionNotFound): # Then the proper exception should be raised, actions = helpers.register(actions, custom_action, after='undefined_action') # And the action list should remain the same assert actions == [api.init_git]
def test_register_with_invalid_reference(): # Given an action list, actions = [api.init_git] # When a new action is registered using an invalid reference, with pytest.raises(ActionNotFound): # Then the proper exception should be raised, actions = helpers.register(actions, custom_action, after='undefined_action') # And the action list should remain the same assert actions == [api.init_git]
def activate(self, actions): """Activate extension Args: actions (list): list of actions to perform Returns: list: updated list of actions """ actions = helpers.register(actions, self.action, after="create_structure") return actions
def activate(self, actions): """Activate extension Args: actions (list): list of actions to perform Returns: list: updated list of actions """ # adds a custom action (helpers always return a new list) actions = helpers.register( actions, self.create_my_own_structure, after="define_structure" ) # removes the init git step actions = helpers.unregister(actions, "init_git") return actions