Example #1
0
    def test_given_one_func_key_mapped_when_removed_then_template_empty(self):
        template_row = self.add_func_key_template()
        func_key = self.create_func_key_for_template(template_row, 1)

        dao.remove_func_key_from_templates(func_key)

        self.assert_template_empty(template_row)
Example #2
0
    def test_given_one_func_key_mapped_when_removed_then_template_empty(self):
        template_row = self.add_func_key_template()
        func_key = self.create_func_key_for_template(template_row, 1)

        dao.remove_func_key_from_templates(func_key)

        self.assert_template_empty(template_row)
Example #3
0
    def test_given_two_func_keys_mapped_when_first_removed_then_other_func_key_remains(self):
        template_row = self.add_func_key_template()
        first_func_key = self.create_func_key_for_template(template_row, 1)
        second_func_key = self.create_func_key_for_template(template_row, 2)

        dao.remove_func_key_from_templates(first_func_key)

        self.assert_template_contains_func_key(template_row, second_func_key)
Example #4
0
    def test_given_two_func_keys_mapped_when_first_removed_then_other_func_key_remains(self):
        template_row = self.add_func_key_template()
        first_func_key = self.create_func_key_for_template(template_row, 1)
        second_func_key = self.create_func_key_for_template(template_row, 2)

        dao.remove_func_key_from_templates(first_func_key)

        self.assert_template_contains_func_key(template_row, second_func_key)
Example #5
0
    def test_given_database_error_then_transaction_aborted(self, commit_or_abort):
        func_key = Mock(id=1)
        dao.remove_func_key_from_templates(func_key)

        commit_or_abort.assert_called_with(ANY, DataError.on_delete, 'FuncKeyTemplate')
Example #6
0
    def test_given_database_error_then_transaction_aborted(self, commit_or_abort):
        func_key = Mock(id=1)
        dao.remove_func_key_from_templates(func_key)

        commit_or_abort.assert_called_with(ANY, ElementDeletionError, 'FuncKeyTemplate')
Example #7
0
def delete_user_destination(user):
    func_keys = func_key_dao.find_all_by_destination('user', user.id)
    for func_key in func_keys:
        template_dao.remove_func_key_from_templates(func_key)
        func_key_dao.delete(func_key)