def test_get_package_from_spec_exception(self, mock_find): """Test `get_package_from_spec` with missing parent namespace.""" with GitHandler.clone(TEST_MAVEN_REPO_URL) as git: repo_dir = git.repository pom_files = Maven.find_pom_files(repo_dir) assert any(pom_files) with open(pom_files[0], 'r') as pom_spec: # set up mock mock_find.return_value = None package = Maven.get_package_from_spec(pom_spec) self.assertIsNotNone(package) self.assertTrue(isinstance(package, Package)) self.assertTrue( all([ getattr(package, attr, None) is None for attr in ['aid', 'gid', 'name', 'owner', 'version', 'description'] ]) )
def test_get_package_from_spec(self): """Test MavenRepository `get_package_from_spec` method.""" with GitHandler.clone(TEST_MAVEN_REPO_URL) as git: repo_dir = git.repository pom_files = Maven.find_pom_files(repo_dir) assert any(pom_files) with open(pom_files[0], 'r') as pom_spec: package = Maven.get_package_from_spec(pom_spec) self.assertIsNotNone(package) self.assertTrue(isinstance(package, Package)) self.assertTrue( all([getattr(package, attr, None)] for attr in ['name', 'owner', 'version', 'description']))