def test_resolve_ranges(self): a_contract = RegistryPackage(package='fishtown-analytics-test/a', version='0.1.2') b_contract = RegistryPackage(package='fishtown-analytics-test/a', version='<0.1.4') a = RegistryUnpinnedPackage.from_contract(a_contract) b = RegistryUnpinnedPackage.from_contract(b_contract) c = a.incorporate(b) self.assertEqual(c.package, 'fishtown-analytics-test/a') self.assertEqual(c.versions, [ VersionSpecifier( build=None, major='0', matcher='=', minor='1', patch='2', prerelease=None, ), VersionSpecifier( build=None, major='0', matcher='<', minor='1', patch='4', prerelease=None, ), ]) c_pinned = c.resolved() self.assertEqual(c_pinned.package, 'fishtown-analytics-test/a') self.assertEqual(c_pinned.version, '0.1.2') self.assertEqual(c_pinned.source_type(), 'hub')
def test_resolve_conflict(self): a_contract = RegistryPackage(package='fishtown-analytics-test/a', version='0.1.2') b_contract = RegistryPackage(package='fishtown-analytics-test/a', version='0.1.3') a = RegistryUnpinnedPackage.from_contract(a_contract) b = RegistryUnpinnedPackage.from_contract(b_contract) c = a.incorporate(b) with self.assertRaises(dbt.exceptions.DependencyException) as exc: c.resolved() msg = ( "Version error for package fishtown-analytics-test/a: Could not " "find a satisfactory version from options: ['=0.1.2', '=0.1.3']") self.assertEqual(msg, str(exc.exception))
def test_resolve_missing_package(self): a = RegistryUnpinnedPackage.from_contract( RegistryPackage(package='fishtown-analytics-test/b', version='0.1.2')) with self.assertRaises(dbt.exceptions.DependencyException) as exc: a.resolved() msg = 'Package fishtown-analytics-test/b was not found in the package index' self.assertEqual(msg, str(exc.exception))
def test_resolve_missing_version(self): a = RegistryUnpinnedPackage.from_contract( RegistryPackage(package='fishtown-analytics-test/a', version='0.1.4')) with self.assertRaises(dbt.exceptions.DependencyException) as exc: a.resolved() msg = ( "Could not find a matching version for package " "fishtown-analytics-test/a\n Requested range: =0.1.4, =0.1.4\n " "Available versions: ['0.1.2', '0.1.3']") self.assertEqual(msg, str(exc.exception))
def update_from(self, src: List[PackageContract]) -> None: pkg: UnpinnedPackage for contract in src: if isinstance(contract, LocalPackage): pkg = LocalUnpinnedPackage.from_contract(contract) elif isinstance(contract, GitPackage): pkg = GitUnpinnedPackage.from_contract(contract) elif isinstance(contract, RegistryPackage): pkg = RegistryUnpinnedPackage.from_contract(contract) else: raise InternalException('Invalid package type {}'.format( type(contract))) self.incorporate(pkg)
def test_init(self): a_contract = RegistryPackage( package='fishtown-analytics-test/a', version='0.1.2', ) self.assertEqual(a_contract.package, 'fishtown-analytics-test/a') self.assertEqual(a_contract.version, '0.1.2') a = RegistryUnpinnedPackage.from_contract(a_contract) self.assertEqual(a.package, 'fishtown-analytics-test/a') self.assertEqual(a.versions, [ VersionSpecifier(build=None, major='0', matcher='=', minor='1', patch='2', prerelease=None) ]) a_pinned = a.resolved() self.assertEqual(a_contract.package, 'fishtown-analytics-test/a') self.assertEqual(a_contract.version, '0.1.2') self.assertEqual(a_pinned.source_type(), 'hub')