Skip to content

Commit

Permalink
Move miners test to own directory #515
Browse files Browse the repository at this point in the history
Signed-off-by: Jono Yang <[email protected]>
  • Loading branch information
JonoYang committed Aug 9, 2024
1 parent 38d4a7e commit 039bba3
Show file tree
Hide file tree
Showing 33 changed files with 76 additions and 66 deletions.
8 changes: 8 additions & 0 deletions minecode/tests/collectors/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Copyright (c) nexB Inc. and others. All rights reserved.
# purldb is a trademark of nexB Inc.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/nexB/purldb for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#
8 changes: 8 additions & 0 deletions minecode/tests/miners/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Copyright (c) nexB Inc. and others. All rights reserved.
# purldb is a trademark of nexB Inc.
# SPDX-License-Identifier: Apache-2.0
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text.
# See https://github.com/nexB/purldb for support or download.
# See https://aboutcode.org for more information about nexB OSS projects.
#
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


class ApacheVistorTest(JsonBasedTesting, DjangoTestCase):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_ApacheDistIndexVisitor(self):
uri = 'http://apache.org/dist/zzz/find-ls.gz'
Expand Down Expand Up @@ -129,7 +129,7 @@ def test_ApachePodlingsJsonVisitor(self):


class ApacheMapperTest(JsonBasedTesting, DjangoTestCase):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_build_package_from_download(self):
package = miners.apache.build_package_from_download(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@


class BitbucketVisitorTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_BitbucketIndexVisitor(self):
uri = 'https://api.bitbucket.org/2.0/repositories?pagelen=10'
Expand Down Expand Up @@ -75,7 +75,7 @@ def test_BitbucketDetailsVisitorPaginated(self):


class BitbucketMapperTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_pattern_match_without_download(self):
url = 'https://api.bitbucket.org/2.0/repositories/phlogistonjohn/tweakmsg'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


class BowerVistorTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_visit_findls_file(self):
uri = 'https://registry.bower.io/packages'
Expand All @@ -46,7 +46,7 @@ def test_visit_bower_json_file(self):


class BowerMapperTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_build_packages_metafile_from_bowerjson1(self):
with open(self.get_test_loc('bower/28msec_bower.json')) as bower_metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


class CpanVisitorTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_metacpanauthorurlvisitors(self):
uri = 'https://fastapi.metacpan.org/author/_search?q=email:a*&size=5000'
Expand Down Expand Up @@ -73,7 +73,7 @@ def test_visit_readme_file(self):


class CpanMapperTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_build_from_release_search_json(self):
with open(self.get_test_loc('cpan/release_search.json')) as cpan_metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


class CranVistorTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_visit_metacpan_api_projects(self):
uri = 'https://cloud.r-project.org/web/packages/available_packages_by_date.html'
Expand All @@ -37,7 +37,7 @@ def test_visit_metacpan_api_projects(self):


class CranMapperTest(JsonBasedTesting, DjangoTestCase):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_build_packages_from_directory_listing(self):
ResourceURI.objects.create(uri='https://cloud.r-project.org/web/packages/ANN2/index.html')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


class BaseDebianTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def check_objects_expected(self, results, expected_loc, regen=FIXTURES_REGEN):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

class DockerHubTest(JsonBasedTesting):

test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')


class DockerHubVistorTest(DockerHubTest):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


class EclipseVistorTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_visit_eclipse_projects(self):
uri = 'https://projects.eclipse.org/list-of-projects'
Expand Down Expand Up @@ -100,7 +100,7 @@ def test_visitor_eclipse_projects_json_download_timeout_error(self):


class TestEclipseMap(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_build_packages(self):
with open(self.get_test_loc('eclipse/birt.json')) as eclipse_metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


class TestFdroidVisitor(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_FdroidPackageRepoVisitor(self):
uri = 'https://f-droid.org/repo/index-v2.json'
Expand All @@ -37,7 +37,7 @@ def test_FdroidPackageRepoVisitor(self):


class TestFdroidMapper(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_build_packages(self):
with open(self.get_test_loc('fdroid/index-v2-visited.json')) as fdroid_data:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


class FreeBSDVistorTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_visit_freebsd_seed(self):
uri = 'https://pkg.freebsd.org'
Expand Down Expand Up @@ -54,7 +54,7 @@ def test_visit_freebsd_indexvisitor(self):


class FreedesktopMapperTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_map_index_file(self):
with open(self.get_test_loc('freebsd/mapper_input1')) as freebsd_metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

class FreedesktopTest(JsonBasedTesting):

test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')


class FreedesktopVistorTest(FreedesktopTest):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


class GithubVisitorTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

@patch('github.MainClass.Github.get_repo')
def test_GithubRepoVisitor(self, mock_get_repo):
Expand Down Expand Up @@ -141,7 +141,7 @@ def test_GithubReposVisitor(self):


class GithubMapperTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_github_repo_mapper1(self):
with open(self.get_test_loc('github/calendar_builder.json')) as json_metadata:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@


class GitlabTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')


class GitlabVistorTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

@unittest.skip('The test is to test fetching remotely through http connection')
def test_visit_api_header_getheaders(self):
Expand All @@ -47,7 +47,7 @@ def test_visit_metacpan_api_projects(self):


class GitlabMapperTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_map_software_html_page_hal(self):
with open(self.get_test_loc('gitlab/microservice-express-mongo.json')) as gitlab_json:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


class GoLangVisitorTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_GoLangGoDocAPIVisitor(self):
uri = 'https://api.godoc.org/packages'
Expand Down Expand Up @@ -65,7 +65,7 @@ def test_parse_package_path(self):


class GoLangMapperTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_build_golang_package(self):
purl = 'pkg:golang/github.com/golang/glog?vcs_repository=https://github.com/golang/glog'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


class GoogleNewAPIVisitorsTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_visit_google_download_zip_visitor(self):
uri = 'https://storage.googleapis.com/google-code-archive/google-code-archive.txt.zip'
Expand Down Expand Up @@ -81,7 +81,7 @@ def test_visit_googleapi_project_json(self):


class GoogleNewAPIMappersTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_build_packages_from_v2_projects_json(self):
with open(self.get_test_loc('googlecode/v2_api/project.json')) as projectsjson_meta:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


class GstreamerVistorTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_visit_gstreamer_source_root(self):
uri = 'https://gstreamer.freedesktop.org/src/'
Expand All @@ -44,7 +44,7 @@ def test_visit_Gstreamer_subpath_contains_file_resources(self):


class GstreamerMappersTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_build_package_mapper_regex(self):
regex = re.compile(r'^https://gstreamer.freedesktop.org/src/([\w\-\.]+/)*[\w\-\.]+[.tar\.bz2|\.sha1sum|\.md5|\.gz|\.tar\.xz|\.asc]$')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@


class HaxeVistorTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_visit_haxe_projects(self):
uri = 'https://lib.haxe.org/all'
Expand Down Expand Up @@ -53,7 +53,7 @@ def test_visit_haxe_package_json(self):


class HaxeMappersTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_build_project_package_json(self):
with open(self.get_test_loc('haxe/project_package.json')) as projectsjson_meta:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def sort_deps(results):


class MavenMiscTest(JsonBasedTesting, DjangoTestCase):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_get_entries(self):
index = self.get_test_loc('maven/index/nexus-maven-repository-index.gz')
Expand Down Expand Up @@ -193,7 +193,7 @@ def test_build_maven_xml_url(self):


class MavenVisitorTest(JsonBasedTesting, DjangoTestCase):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_MavenNexusIndexVisitor_uris(self):
uri = 'https://repo1.maven.org/maven2/.index/nexus-maven-repository-index.gz'
Expand Down Expand Up @@ -265,7 +265,7 @@ def test_MavenPOMVisitor_data(self):

class MavenEnd2EndTest(JsonBasedTesting, DjangoTestCase):

test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_MavenNexusIndexVisitor_with_run_visit_then_map_end2end(self):
# setup
Expand Down Expand Up @@ -433,7 +433,7 @@ def test_visit_and_map_with_index(self):


class MavenXmlMetadataVisitorTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_visit_maven_medatata_xml_file(self):
uri = 'https://repo1.maven.org/maven2/st/digitru/identity-core/maven-metadata.xml'
Expand All @@ -446,7 +446,7 @@ def test_visit_maven_medatata_xml_file(self):


class MavenHtmlIndexVisitorTest(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_visit_maven_medatata_html_index_jcenter_1(self):
uri = 'http://jcenter.bintray.com/'
Expand Down Expand Up @@ -478,7 +478,7 @@ def test_visit_maven_medatata_html_index_jcenter_3(self):

# FIXME: we should not need to call a visitor for testing a mapper
class MavenMapperVisitAndMapTest(JsonBasedTesting, DjangoTestCase):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_visit_and_build_package_from_pom_axis(self):
uri = 'https://repo1.maven.org/maven2/axis/axis/1.4/axis-1.4.pom'
Expand Down Expand Up @@ -552,7 +552,7 @@ def test_visit_and_build_package_from_pom_with_unicode(self):


class MavenMapperGetPackageTest(JsonBasedTesting, DjangoTestCase):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_get_package_from_pom_1(self):
test_loc = self.get_test_loc('maven/parsing/parse/jds-3.0.1.pom')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


class TestNPMVisit(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

# FIXME: use smaller test files
def test_NpmRegistryVisitor(self):
Expand Down Expand Up @@ -57,7 +57,7 @@ def test_NpmRegistryVisitor_1000records(self):


class TestNPMMapper(JsonBasedTesting):
test_data_dir = os.path.join(os.path.dirname(__file__), 'testfiles')
test_data_dir = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'testfiles')

def test_build_packages(self):
with open(self.get_test_loc('npm/0flux.json')) as npm_metadata:
Expand Down
Loading

0 comments on commit 039bba3

Please sign in to comment.