Skip to content

Commit

Permalink
Update test expectations
Browse files Browse the repository at this point in the history
Signed-off-by: Jono Yang <[email protected]>
  • Loading branch information
JonoYang committed Nov 3, 2023
1 parent 362b16b commit eb1dccb
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"type":"maven",
"namespace":"",
"name":"foo",
"name":"Foo",
"version":"",
"qualifiers":"",
"subpath":"",
Expand Down Expand Up @@ -36,9 +36,9 @@
"source_packages":[],
"extra_data":{},
"dependencies":[],
"package_uid":"pkg:maven/foo?uuid=fixed-uid-done-for-testing-5642512d1758",
"package_uid":"pkg:maven/Foo?uuid=fixed-uid-done-for-testing-5642512d1758",
"datasource_id":null,
"purl":"pkg:maven/foo",
"purl":"pkg:maven/Foo",
"repository_homepage_url":null,
"repository_download_url":null,
"api_data_url":null,
Expand Down
6 changes: 3 additions & 3 deletions minecode/tests/testfiles/housekeeping/example_expected.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"type":"maven",
"namespace":"",
"name":"foo",
"name":"Foo",
"version":"",
"qualifiers":"",
"subpath":"",
Expand Down Expand Up @@ -36,9 +36,9 @@
"source_packages":[],
"extra_data":{},
"dependencies":[],
"package_uid":"pkg:maven/foo?uuid=fixed-uid-done-for-testing-5642512d1758",
"package_uid":"pkg:maven/Foo?uuid=fixed-uid-done-for-testing-5642512d1758",
"datasource_id":null,
"purl":"pkg:maven/foo",
"purl":"pkg:maven/Foo",
"repository_homepage_url":null,
"repository_download_url":null,
"api_data_url":null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"type":"maven",
"namespace":"",
"name":"foo",
"name":"Foo",
"version":"",
"qualifiers":"",
"subpath":"",
Expand Down Expand Up @@ -36,9 +36,9 @@
"source_packages":[],
"extra_data":{},
"dependencies":[],
"package_uid":"pkg:maven/foo?uuid=fixed-uid-done-for-testing-5642512d1758",
"package_uid":"pkg:maven/Foo?uuid=fixed-uid-done-for-testing-5642512d1758",
"datasource_id":null,
"purl":"pkg:maven/foo",
"purl":"pkg:maven/Foo",
"repository_homepage_url":null,
"repository_download_url":null,
"api_data_url":null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"type":"maven",
"namespace":"",
"name":"foo",
"name":"Foo",
"version":"",
"qualifiers":"",
"subpath":"",
Expand Down Expand Up @@ -36,9 +36,9 @@
"source_packages":[],
"extra_data":{},
"dependencies":[],
"package_uid":"pkg:maven/foo?uuid=fixed-uid-done-for-testing-5642512d1758",
"package_uid":"pkg:maven/Foo?uuid=fixed-uid-done-for-testing-5642512d1758",
"datasource_id":null,
"purl":"pkg:maven/foo",
"purl":"pkg:maven/Foo",
"repository_homepage_url":null,
"repository_download_url":null,
"api_data_url":null,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Generated by Django 4.1.2 on 2023-10-31 20:44

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("packagedb", "0078_alter_package_release_date"),
]

operations = [
migrations.RemoveIndex(
model_name="package",
name="packagedb_p_search__8d33bb_gin",
),
migrations.RemoveField(
model_name="package",
name="search_vector",
),
migrations.AlterField(
model_name="package",
name="name",
field=models.CharField(
blank=True, help_text="Name of the package.", max_length=100
),
),
migrations.AlterField(
model_name="package",
name="namespace",
field=models.CharField(
blank=True,
help_text="Package name prefix, such as Maven groupid, Docker image owner, GitHub user or organization, etc.",
max_length=255,
),
),
migrations.AlterField(
model_name="package",
name="qualifiers",
field=models.CharField(
blank=True,
help_text="Extra qualifying data for a package such as the name of an OS, architecture, distro, etc.",
max_length=1024,
),
),
migrations.AlterField(
model_name="package",
name="subpath",
field=models.CharField(
blank=True,
help_text="Extra subpath within a package, relative to the package root.",
max_length=200,
),
),
migrations.AlterField(
model_name="package",
name="type",
field=models.CharField(
blank=True,
help_text="A short code to identify the type of this package. For example: gem for a Rubygem, docker for a container, pypi for a Python Wheel or Egg, maven for a Maven Jar, deb for a Debian package, etc.",
max_length=16,
),
),
]
8 changes: 4 additions & 4 deletions packagedb/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def test_package_api_list_endpoint_filter(self):
def test_package_api_list_endpoint_filter_by_purl_fields_ignores_case(self):
for key, value in self.package_data.items():
# Skip non-purl fields
if key not in ['type', 'namespace', 'name', 'version', 'qualifiers', 'subpath']:
if key not in ['type', 'namespace', 'name']:
continue

response = self.client.get('/api/packages/?{}={}'.format(key, value.lower()))
Expand All @@ -384,7 +384,7 @@ def test_package_api_retrieve_endpoint(self):
continue

if key in ['type', 'namespace', 'name', 'version', 'qualifiers', 'subpath']:
self.assertEqual(value.lower(), getattr(self.package, key))
self.assertEqual(value, getattr(self.package, key))
continue

if key == 'history':
Expand Down Expand Up @@ -640,7 +640,7 @@ def test_reindex_package(self):
self.assertEqual('error', self.scannableuri.index_error)
self.assertEqual(self.scan_request_date, self.scannableuri.scan_request_date)
response = self.client.get(f'/api/packages/{self.package.uuid}/reindex_package/')
self.assertEqual('pkg:maven/sample/baz@90.12 has been queued for reindexing', response.data['status'])
self.assertEqual('pkg:maven/sample/Baz@90.12 has been queued for reindexing', response.data['status'])
self.scannableuri.refresh_from_db()
self.assertEqual(True, self.scannableuri.rescan_uri)
self.assertEqual(100, self.scannableuri.priority)
Expand All @@ -664,7 +664,7 @@ def test_reindex_packages_basic(self):
self.assertEqual('error', self.scannableuri2.index_error)
self.assertEqual(self.scan_request_date2, self.scannableuri2.scan_request_date)
existing_purls = [
'pkg:maven/sample/baz@90.12',
'pkg:maven/sample/Baz@90.12',
'pkg:npm/example/[email protected]',
]
nonexistent_purls = [
Expand Down
12 changes: 0 additions & 12 deletions packagedb/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,6 @@ def setUp(self):
self.created_package = Package.objects.create(**self.created_package_data)
self.inserted_package = Package.objects.insert(**self.inserted_package_data)

def test_package_creation(self):
test_package = Package.objects.get(download_url=self.created_package_download_url)
self.assertIsNotNone(test_package)
for key, val in self.created_package_data.items():
self.assertEqual(val.lower(), getattr(test_package, key))

def test_package_insertion(self):
test_package = Package.objects.get(download_url=self.inserted_package_download_url)
self.assertIsNotNone(test_package)
for key, val in self.inserted_package_data.items():
self.assertEqual(val.lower(), getattr(test_package, key))

def test_package_download_url_is_unique(self):
self.assertIsNone(Package.objects.insert(download_url=self.created_package_download_url))
self.assertIsNone(Package.objects.insert(download_url=self.inserted_package_download_url))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"type":"generic",
"namespace":"generic",
"name":"foo",
"name":"Foo",
"version":"12.34",
"qualifiers":"test_qual=qual",
"subpath":"test_subpath",
Expand Down Expand Up @@ -35,9 +35,9 @@
"source_packages":[],
"extra_data":{},
"dependencies":[],
"package_uid":"pkg:generic/generic/foo@12.34?test_qual=qual&uuid=fixed-uid-done-for-testing-5642512d1758#test_subpath",
"package_uid":"pkg:generic/generic/Foo@12.34?test_qual=qual&uuid=fixed-uid-done-for-testing-5642512d1758#test_subpath",
"datasource_id":null,
"purl":"pkg:generic/generic/foo@12.34?test_qual=qual#test_subpath",
"purl":"pkg:generic/generic/Foo@12.34?test_qual=qual#test_subpath",
"repository_homepage_url":null,
"repository_download_url":null,
"api_data_url":null,
Expand All @@ -46,7 +46,7 @@
{
"type":"npm",
"namespace":"example",
"name":"bar",
"name":"Bar",
"version":"56.78",
"qualifiers":"",
"subpath":"",
Expand Down Expand Up @@ -79,9 +79,9 @@
"source_packages":[],
"extra_data":{},
"dependencies":[],
"package_uid":"pkg:npm/example/bar@56.78?uuid=fixed-uid-done-for-testing-5642512d1758",
"package_uid":"pkg:npm/example/Bar@56.78?uuid=fixed-uid-done-for-testing-5642512d1758",
"datasource_id":null,
"purl":"pkg:npm/example/bar@56.78",
"purl":"pkg:npm/example/Bar@56.78",
"repository_homepage_url":null,
"repository_download_url":null,
"api_data_url":null,
Expand All @@ -90,7 +90,7 @@
{
"type":"jar",
"namespace":"sample",
"name":"baz",
"name":"Baz",
"version":"90.12",
"qualifiers":"",
"subpath":"",
Expand Down Expand Up @@ -123,9 +123,9 @@
"source_packages":[],
"extra_data":{},
"dependencies":[],
"package_uid":"pkg:jar/sample/baz@90.12?uuid=fixed-uid-done-for-testing-5642512d1758",
"package_uid":"pkg:jar/sample/Baz@90.12?uuid=fixed-uid-done-for-testing-5642512d1758",
"datasource_id":null,
"purl":"pkg:jar/sample/baz@90.12",
"purl":"pkg:jar/sample/Baz@90.12",
"repository_homepage_url":null,
"repository_download_url":null,
"api_data_url":null,
Expand All @@ -134,7 +134,7 @@
{
"type":"jar",
"namespace":"sample",
"name":"baz",
"name":"Baz",
"version":"90.123",
"qualifiers":"",
"subpath":"",
Expand Down Expand Up @@ -167,9 +167,9 @@
"source_packages":[],
"extra_data":{},
"dependencies":[],
"package_uid":"pkg:jar/sample/baz@90.123?uuid=fixed-uid-done-for-testing-5642512d1758",
"package_uid":"pkg:jar/sample/Baz@90.123?uuid=fixed-uid-done-for-testing-5642512d1758",
"datasource_id":null,
"purl":"pkg:jar/sample/baz@90.123",
"purl":"pkg:jar/sample/Baz@90.123",
"repository_homepage_url":null,
"repository_download_url":null,
"api_data_url":null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
{
"filename":"Foo.zip",
"package_content":null,
"purl":"pkg:generic/generic/foo@12.34?test_qual=qual#test_subpath",
"purl":"pkg:generic/generic/Foo@12.34?test_qual=qual#test_subpath",
"type":"generic",
"namespace":"generic",
"name":"foo",
"name":"Foo",
"version":"12.34",
"qualifiers":"test_qual=qual",
"subpath":"test_subpath",
Expand Down Expand Up @@ -39,18 +39,18 @@
"notice_text":null,
"source_packages":[],
"extra_data":{},
"package_uid":"pkg:generic/generic/foo@12.34?test_qual=qual&uuid=fixed-uid-done-for-testing-5642512d1758#test_subpath",
"package_uid":"pkg:generic/generic/Foo@12.34?test_qual=qual&uuid=fixed-uid-done-for-testing-5642512d1758#test_subpath",
"datasource_id":null,
"file_references":[],
"dependencies":[]
},
{
"filename":"Bar.zip",
"package_content":null,
"purl":"pkg:npm/example/bar@56.78",
"purl":"pkg:npm/example/Bar@56.78",
"type":"npm",
"namespace":"example",
"name":"bar",
"name":"Bar",
"version":"56.78",
"qualifiers":"",
"subpath":"",
Expand Down Expand Up @@ -84,18 +84,18 @@
"notice_text":null,
"source_packages":[],
"extra_data":{},
"package_uid":"pkg:npm/example/bar@56.78?uuid=fixed-uid-done-for-testing-5642512d1758",
"package_uid":"pkg:npm/example/Bar@56.78?uuid=fixed-uid-done-for-testing-5642512d1758",
"datasource_id":null,
"file_references":[],
"dependencies":[]
},
{
"filename":"Baz.zip",
"package_content":null,
"purl":"pkg:jar/sample/baz@90.12",
"purl":"pkg:jar/sample/Baz@90.12",
"type":"jar",
"namespace":"sample",
"name":"baz",
"name":"Baz",
"version":"90.12",
"qualifiers":"",
"subpath":"",
Expand Down Expand Up @@ -129,18 +129,18 @@
"notice_text":null,
"source_packages":[],
"extra_data":{},
"package_uid":"pkg:jar/sample/baz@90.12?uuid=fixed-uid-done-for-testing-5642512d1758",
"package_uid":"pkg:jar/sample/Baz@90.12?uuid=fixed-uid-done-for-testing-5642512d1758",
"datasource_id":null,
"file_references":[],
"dependencies":[]
},
{
"filename":"Baz.zip",
"package_content":"binary",
"purl":"pkg:jar/sample/baz@90.123",
"purl":"pkg:jar/sample/Baz@90.123",
"type":"jar",
"namespace":"sample",
"name":"baz",
"name":"Baz",
"version":"90.123",
"qualifiers":"",
"subpath":"",
Expand Down Expand Up @@ -174,7 +174,7 @@
"notice_text":null,
"source_packages":[],
"extra_data":{},
"package_uid":"pkg:jar/sample/baz@90.123?uuid=fixed-uid-done-for-testing-5642512d1758",
"package_uid":"pkg:jar/sample/Baz@90.123?uuid=fixed-uid-done-for-testing-5642512d1758",
"datasource_id":null,
"file_references":[],
"dependencies":[]
Expand Down

0 comments on commit eb1dccb

Please sign in to comment.