def test_nectar_config(self, fake_descriptor): config = Mock() fake_config = Mock() fake_descriptor.nectar_config.return_value = fake_config cataloger = YumCataloger() nectar_config = cataloger.nectar_config(config) fake_descriptor.nectar_config.assert_called_with(config) self.assertEqual(nectar_config, fake_config)
def test_json_serializable(self, mock_add): """ ensure the arguments are json serializable see https://pulp.plan.io/issues/2012 """ url = 'file://%s/' % self.tmp_dir conduit = CatalogerConduit(SOURCE_ID, EXPIRES) cataloger = YumCataloger() cataloger.refresh(conduit, {}, url) for call in mock_add.call_args_list: json.dumps(call)
def test_get_downloader(self, fake_factory): url = 'my-url' conduit = Mock() config = Mock() fake_downloader = Mock() fake_factory.create_downloader.return_value = fake_downloader cataloger = YumCataloger() cataloger.nectar_config = Mock() downloader = cataloger.get_downloader(conduit, config, url) fake_factory.create_downloader.assert_called_with(url, cataloger.nectar_config()) self.assertEqual(downloader, fake_downloader)
def test_refresh(self, mock_add): url = 'file://%s/' % self.tmp_dir conduit = CatalogerConduit(SOURCE_ID, EXPIRES) cataloger = YumCataloger() cataloger.refresh(conduit, {}, url) with open(JSON_PATH) as fp: expected = json.load(fp) self.assertEqual(mock_add.call_count, len(expected)) for entry in expected: self.assertTrue( mock_add.called_with(SOURCE_ID, EXPIRES, entry['type_id'], entry['unit_key'], self._normalized(entry['url'])))
def test_refresh(self, mock_add): url = 'file://%s/' % self.tmp_dir conduit = CatalogerConduit(SOURCE_ID, EXPIRES) cataloger = YumCataloger() cataloger.refresh(conduit, {}, url) with open(JSON_PATH) as fp: expected = json.load(fp) self.assertEqual(mock_add.call_count, len(expected)) for entry in expected: self.assertTrue( mock_add.called_with( SOURCE_ID, EXPIRES, entry['type_id'], entry['unit_key'], self._normalized(entry['url'])))
def test_metadata(self): md = YumCataloger.metadata() expected = { 'id': TYPE_ID, 'display_name': "Yum Cataloger", 'types': [models.RPM.TYPE] } self.assertEqual(md, expected)
def test_metadata(self): md = YumCataloger.metadata() expected = { 'id': TYPE_ID, 'display_name': "Yum Cataloger", 'types': [RPM._content_type_id.default] } self.assertEqual(md, expected)