def setUp(self): super(WorkingDirUpgradeTests, self).setUp() # This script occurs after the DB is upgraded, so simulate the # necessary preconditions yum_repos.upgrade(self.v1_test_db.database, self.tmp_test_db.database) iso_repos.upgrade(self.v1_test_db.database, self.tmp_test_db.database) all_repos.upgrade(self.v1_test_db.database, self.tmp_test_db.database) self.tmp_dir = tempfile.mkdtemp(prefix='working-dir-unit-test') repos.WORKING_DIR_ROOT = self.tmp_dir
def setUp(self): super(NoFeedCertificateTests, self).setUp() # This script occurs after the DB is upgraded, so simulate the # necessary preconditions yum_repos.upgrade(self.v1_test_db.database, self.tmp_test_db.database) iso_repos.upgrade(self.v1_test_db.database, self.tmp_test_db.database) all_repos.upgrade(self.v1_test_db.database, self.tmp_test_db.database) # This script also relies on the working directories to be created self.tmp_dir = tempfile.mkdtemp(prefix='no-feeds-fs-unit-test') repos.WORKING_DIR_ROOT = self.tmp_dir repos.upgrade(self.v1_test_db.database, self.tmp_test_db.database)
def test_upgrade(self): # Test all_repos.upgrade(self.v1_test_db.database, self.tmp_test_db.database) # Verify v2_coll = self.tmp_test_db.database.repo_importers # Make sure we didn't wipe out all of the feed URLs v2_parent_repo_importer = v2_coll.find_one({'repo_id' : 'parent'}) self.assertEqual(v2_parent_repo_importer['config']['feed_url'], 'parent-feed') # This one should be empty v2_child_repo_importer = v2_coll.find_one({'repo_id' : 'child'}) self.assertEqual(v2_child_repo_importer['config']['feed_url'], None)
def test_schedule_upgrade_idempotency(self): self._insert_scheduled_v2_repo(self.v1_repo_1_id, self.v1_repo_1_schedule) scheduled_calls = self.tmp_test_db.database.scheduled_calls.find({}) self.assertEqual(scheduled_calls.count(), 1) report = all_repos.upgrade(self.v1_test_db.database, self.tmp_test_db.database) self.assertTrue(report.success) scheduled_calls = self.tmp_test_db.database.scheduled_calls.find({}) self.assertEqual(scheduled_calls.count(), 2)
def test_schedule_upgrade(self): v1_schedules = self.v1_test_db.database.repos.find({'sync_schedule': {'$ne': None}}) self.assertEqual(v1_schedules.count(), 2) scheduled_calls = self.tmp_test_db.database.scheduled_calls.find({}) self.assertEqual(scheduled_calls.count(), 0) report = all_repos.upgrade(self.v1_test_db.database, self.tmp_test_db.database) self.assertTrue(report.success) scheduled_calls = self.tmp_test_db.database.scheduled_calls.find({}) self.assertEqual(scheduled_calls.count(), 2)
def setUp(self): super(FeedCertificateTests, self).setUp() # Munge each repo to point to a sample cert and CA ca_cert_path = os.path.join(DATA_DIR, 'repo_related_files', 'feed_ca.crt') client_cert_path = os.path.join(DATA_DIR, 'repo_related_files', 'feed_cert.crt') v1_repos = self.v1_test_db.database.repos.find() for v1_repo in v1_repos: v1_repo['feed_ca'] = ca_cert_path v1_repo['feed_cert'] = client_cert_path self.v1_test_db.database.repos.save(v1_repo) # This script occurs after the DB is upgraded, so simulate the # necessary preconditions yum_repos.upgrade(self.v1_test_db.database, self.tmp_test_db.database) iso_repos.upgrade(self.v1_test_db.database, self.tmp_test_db.database) all_repos.upgrade(self.v1_test_db.database, self.tmp_test_db.database) # This script also relies on the working directories to be created self.tmp_dir = tempfile.mkdtemp(prefix='feeds-fs-unit-test') repos.WORKING_DIR_ROOT = self.tmp_dir repos.upgrade(self.v1_test_db.database, self.tmp_test_db.database)