def test_resolve_fail(self): a_contract = GitPackage.from_dict({ 'git': 'http://example.com', 'revision': '0.0.1' }) b_contract = GitPackage.from_dict({ 'git': 'http://example.com', 'revision': '0.0.2' }) a = GitUnpinnedPackage.from_contract(a_contract) b = GitUnpinnedPackage.from_contract(b_contract) c = a.incorporate(b) self.assertEqual(c.git, 'http://example.com') self.assertEqual(c.revisions, ['0.0.1', '0.0.2']) with self.assertRaises(dbt.exceptions.DependencyException): c.resolved()
def test_resolve_ok(self): a_contract = GitPackage.from_dict({ 'git': 'http://example.com', 'revision': '0.0.1' }) b_contract = GitPackage.from_dict({ 'git': 'http://example.com', 'revision': '0.0.1', 'warn-unpinned': False }) a = GitUnpinnedPackage.from_contract(a_contract) b = GitUnpinnedPackage.from_contract(b_contract) self.assertTrue(a.warn_unpinned) self.assertFalse(b.warn_unpinned) c = a.incorporate(b) c_pinned = c.resolved() self.assertEqual(c_pinned.name, 'http://example.com') self.assertEqual(c_pinned.get_version(), '0.0.1') self.assertEqual(c_pinned.source_type(), 'git') self.assertFalse(c_pinned.warn_unpinned)
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_default_revision(self): a_contract = GitPackage.from_dict({'git': 'http://example.com'}) self.assertEqual(a_contract.revision, None) self.assertIs(a_contract.warn_unpinned, None) a = GitUnpinnedPackage.from_contract(a_contract) self.assertEqual(a.git, 'http://example.com') self.assertEqual(a.revisions, []) self.assertIs(a.warn_unpinned, True) a_pinned = a.resolved() self.assertEqual(a_pinned.name, 'http://example.com') self.assertEqual(a_pinned.get_version(), 'HEAD') self.assertEqual(a_pinned.source_type(), 'git') self.assertIs(a_pinned.warn_unpinned, True)
def test_init(self): a_contract = GitPackage.from_dict( { 'git': 'http://example.com', 'revision': '0.0.1' }, ) self.assertEqual(a_contract.git, 'http://example.com') self.assertEqual(a_contract.revision, '0.0.1') self.assertIs(a_contract.warn_unpinned, None) a = GitUnpinnedPackage.from_contract(a_contract) self.assertEqual(a.git, 'http://example.com') self.assertEqual(a.revisions, ['0.0.1']) self.assertIs(a.warn_unpinned, True) a_pinned = a.resolved() self.assertEqual(a_pinned.name, 'http://example.com') self.assertEqual(a_pinned.get_version(), '0.0.1') self.assertEqual(a_pinned.source_type(), 'git') self.assertIs(a_pinned.warn_unpinned, True)