|
35 | 35 | from extlinks.organisations.models import Organisation |
36 | 36 |
|
37 | 37 |
|
38 | | -class LinkAggregateCommandTest(TransactionTestCase): |
| 38 | +class BaseTransactionTest(TransactionTestCase): |
| 39 | + @classmethod |
| 40 | + def setUpClass(cls): |
| 41 | + super(BaseTransactionTest, cls).setUpClass() |
| 42 | + cls.tenacity_patcher = mock.patch('tenacity.nap.time') |
| 43 | + cls.mock_tenacity = cls.tenacity_patcher.start() |
| 44 | + |
| 45 | + @classmethod |
| 46 | + def tearDownClass(cls): |
| 47 | + super(BaseTransactionTest, cls).tearDownClass() |
| 48 | + cls.tenacity_patcher.stop() |
| 49 | + |
| 50 | +class LinkAggregateCommandTest(BaseTransactionTest): |
39 | 51 | def setUp(self): |
40 | 52 | # Creating one Collection |
41 | 53 | self.organisation = OrganisationFactory(name="ACME Org") |
@@ -233,7 +245,7 @@ def test_link_aggregate_with_argument_delete_org(self): |
233 | 245 | call_command("fill_link_aggregates", collections=[new_collection.pk]) |
234 | 246 |
|
235 | 247 |
|
236 | | -class UserAggregateCommandTest(TransactionTestCase): |
| 248 | +class UserAggregateCommandTest(BaseTransactionTest): |
237 | 249 | def setUp(self): |
238 | 250 | # Creating one Collection |
239 | 251 | self.organisation = OrganisationFactory(name="ACME Org") |
@@ -481,7 +493,7 @@ def test_user_aggregate_with_argument_delete_org(self): |
481 | 493 | call_command("fill_user_aggregates", collections=[new_collection.pk]) |
482 | 494 |
|
483 | 495 |
|
484 | | -class PageProjectAggregateCommandTest(TransactionTestCase): |
| 496 | +class PageProjectAggregateCommandTest(BaseTransactionTest): |
485 | 497 | def setUp(self): |
486 | 498 | # Creating one Collection |
487 | 499 | self.organisation = OrganisationFactory(name="ACME Org") |
@@ -739,7 +751,7 @@ def test_pageproject_aggregate_with_argument_delete_org(self): |
739 | 751 | call_command("fill_pageproject_aggregates", collections=[new_collection.pk]) |
740 | 752 |
|
741 | 753 |
|
742 | | -class MonthlyLinkAggregateCommandTest(TransactionTestCase): |
| 754 | +class MonthlyLinkAggregateCommandTest(BaseTransactionTest): |
743 | 755 | def setUp(self): |
744 | 756 | self.organisation = OrganisationFactory(name="ACME Org") |
745 | 757 | self.collection = CollectionFactory(name="ACME", organisation=self.organisation) |
@@ -863,7 +875,7 @@ def test_specific_year_month(self): |
863 | 875 | ) |
864 | 876 |
|
865 | 877 |
|
866 | | -class MonthlyUserAggregateCommandTest(TransactionTestCase): |
| 878 | +class MonthlyUserAggregateCommandTest(BaseTransactionTest): |
867 | 879 | def setUp(self): |
868 | 880 | self.organisation = OrganisationFactory(name="ACME Org") |
869 | 881 | self.collection = CollectionFactory(name="ACME", organisation=self.organisation) |
@@ -1051,7 +1063,7 @@ def test_specific_year_month(self): |
1051 | 1063 | ) |
1052 | 1064 |
|
1053 | 1065 |
|
1054 | | -class MonthlyPageProjectAggregateCommandTest(TransactionTestCase): |
| 1066 | +class MonthlyPageProjectAggregateCommandTest(BaseTransactionTest): |
1055 | 1067 | def setUp(self): |
1056 | 1068 | self.organisation = OrganisationFactory(name="ACME Org") |
1057 | 1069 | self.collection = CollectionFactory(name="ACME", organisation=self.organisation) |
@@ -1259,7 +1271,7 @@ def test_specific_year_month(self): |
1259 | 1271 | ) |
1260 | 1272 |
|
1261 | 1273 |
|
1262 | | -class ArchiveLinkAggregatesCommandTest(TransactionTestCase): |
| 1274 | +class ArchiveLinkAggregatesCommandTest(BaseTransactionTest): |
1263 | 1275 | def setUp(self): |
1264 | 1276 | self.organisation = OrganisationFactory(name="JSTOR") |
1265 | 1277 | self.collection = CollectionFactory( |
@@ -1518,7 +1530,7 @@ def test_archive_link_aggregates_no_dates(self, mock_swift_connection): |
1518 | 1530 | self.assertEqual(LinkAggregate.objects.count(), 1) |
1519 | 1531 |
|
1520 | 1532 |
|
1521 | | -class ArchiveUserAggregatesCommandTest(TransactionTestCase): |
| 1533 | +class ArchiveUserAggregatesCommandTest(BaseTransactionTest): |
1522 | 1534 | def setUp(self): |
1523 | 1535 | self.user = UserFactory(username="jonsnow") |
1524 | 1536 | self.organisation = OrganisationFactory(name="JSTOR") |
@@ -1782,7 +1794,7 @@ def test_archive_user_aggregates_no_dates(self, mock_swift_connection): |
1782 | 1794 | self.assertEqual(UserAggregate.objects.count(), 1) |
1783 | 1795 |
|
1784 | 1796 |
|
1785 | | -class ArchivePageProjectAggregatesCommandTest(TransactionTestCase): |
| 1797 | +class ArchivePageProjectAggregatesCommandTest(BaseTransactionTest): |
1786 | 1798 | def setUp(self): |
1787 | 1799 | self.page = "TestPage" |
1788 | 1800 | self.project = "en.wikipedia.org" |
@@ -2051,7 +2063,7 @@ def test_archive_pageproject_aggregates_no_dates(self, mock_swift_connection): |
2051 | 2063 | self.assertEqual(PageProjectAggregate.objects.count(), 1) |
2052 | 2064 |
|
2053 | 2065 |
|
2054 | | -class UploadAllArchivedAggregatesCommandTest(TransactionTestCase): |
| 2066 | +class UploadAllArchivedAggregatesCommandTest(BaseTransactionTest): |
2055 | 2067 | @mock.patch.dict( |
2056 | 2068 | os.environ, |
2057 | 2069 | { |
|
0 commit comments