Exemple #1
0
    def test_init(self):
        config = PluginCallConfiguration(None, {
            constants.PUBLISH_HTTPS_KEYWORD: True,
            constants.PUBLISH_HTTP_KEYWORD: True})
        step = publish.Publisher(self.publisher.get_repo(),
                                 self.publisher.get_conduit(),
                                 config, YUM_DISTRIBUTOR_ID, working_dir=self.working_dir)
        self.assertTrue(isinstance(step.children[-1], publish.GenerateListingFileStep))
        self.assertTrue(isinstance(step.children[-2], publish.GenerateListingFileStep))
        self.assertTrue(isinstance(step.children[-3], publish.AtomicDirectoryPublishStep))
        atomic_publish = step.children[-3]
        repo = self.publisher.get_repo()
        target_publish_locations = [
            ['/', os.path.join(configuration.get_https_publish_dir(config),
                               configuration.get_repo_relative_path(repo, config))],
            ['/', os.path.join(configuration.get_http_publish_dir(config),
                               configuration.get_repo_relative_path(repo, config))]
        ]
        self.assertEquals(atomic_publish.publish_locations, target_publish_locations)

        # verify that listing file steps got the correct arguments
        http_step = step.children[-1]
        https_step = step.children[-2]
        self.assertEqual(http_step.target_dir, target_publish_locations[1][1])
        self.assertEqual(http_step.root_dir, configuration.get_http_publish_dir(config))
        self.assertEqual(https_step.target_dir, target_publish_locations[0][1])
        self.assertEqual(https_step.root_dir, configuration.get_https_publish_dir(config))
Exemple #2
0
    def test_init_incremental_publish_from_http_dir(self, mock_get_http_dir):
        config = PluginCallConfiguration(None, {
            constants.PUBLISH_HTTPS_KEYWORD: False,
            constants.PUBLISH_HTTP_KEYWORD: True})
        # Set the last publish time
        self.publisher.get_conduit().last_publish = \
            mock.Mock(return_value=datetime.datetime.now(tz=isodate.UTC))

        # set up the previous publish directory
        repo = self.publisher.get_repo()
        mock_get_http_dir.return_value = self.working_dir
        specific_master = os.path.join(self.working_dir,
                                       configuration.get_repo_relative_path(repo, config))
        os.makedirs(specific_master)

        step = publish.Publisher(self.publisher.get_repo(),
                                 self.publisher.get_conduit(),
                                 config, YUM_DISTRIBUTOR_ID, working_dir=self.working_dir)
        self.assertTrue(isinstance(step.children[0], publish.CopyDirectoryStep))