Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
server/pulp/server/db/migrations/0020_drop_celery_taskmeta.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
""" | ||
This migration removes the `celery_taskmeta` collection. | ||
""" | ||
from pulp.server.db import connection | ||
|
||
|
||
def migrate(*args, **kwargs): | ||
""" | ||
Perform the migration as described in this module's docblock. | ||
:param args: unused | ||
:type args: list | ||
:param kwargs: unused | ||
:type kwargs: dict | ||
""" | ||
db = connection.get_database() | ||
collection = db['celery_taskmeta'] | ||
collection.drop() |
23 changes: 23 additions & 0 deletions
23
server/test/unit/server/db/migrations/test_0020_drop_celery_taskmeta.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
""" | ||
This module contains tests for pulp.server.db.migrations.0020_drop_celery_taskmeta.py | ||
""" | ||
import unittest | ||
|
||
from mock import patch | ||
|
||
from pulp.server.db.migrate.models import _import_all_the_way | ||
|
||
migration = _import_all_the_way('pulp.server.db.migrations.0020_drop_celery_taskmeta') | ||
|
||
|
||
class TestMigrate(unittest.TestCase): | ||
""" | ||
Test the migrate() function. | ||
""" | ||
|
||
@patch.object(migration.connection, 'get_database') | ||
def test_celery_taskmeta_collection_dropped(self, mock_get_database): | ||
mock_get_database.return_value.collection_names.return_value = [] | ||
collection = mock_get_database.return_value['celery_taskmeta'] | ||
migration.migrate() | ||
collection.drop.assert_called_once() |