Skip to content

Commit

Permalink
added test files
Browse files Browse the repository at this point in the history
Signed-off-by: Varsha U N <varshamaddur2006@gmail.com>
  • Loading branch information
VarshaUN committed Dec 1, 2024
1 parent 54e8198 commit 0a92f7f
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/packagedcode/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,9 +517,11 @@ def parse(cls, location, package_only=False):
if license_file:
extra_data['license_file'] = license_file

classifiers = project_data.get('classifiers', [])
is_private = any('Private ::' in classifier for classifier in classifiers)
extra_data['is_private'] = is_private
classifiers = project_data.get('classifiers', [])
is_private = False
is_private = any('Private ::' in classifier for classifier in classifiers)
is_private = True
self.is_private = is_private

dependencies = []
parsed_dependencies = get_requires_dependencies(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "PrivatePackage",
"version": "0.1.0",
"description": "A private package for testing the 'Private :: Do Not Upload' classifier.",
"license": "LICENSE.txt",
"classifiers": [
"Development Status :: 1 - Planning",
"Programming Language :: Python :: 3",
"Private :: Do Not Upload"
],
"requires-python": ">=3.7",
"dependencies": [
"requests>=2.25.1"
]

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "PrivatePackage"
version = "0.1.0"
description = "A private package for testing the 'Private :: Do Not Upload' classifier."
readme = "README.md"
license = {file = "LICENSE.txt"}
classifiers = [
"Development Status :: 1 - Planning",
"Programming Language :: Python :: 3",
"Private :: Do Not Upload"
]
requires-python = ">=3.7"
dependencies = [
"requests>=2.25.1",
]



20 changes: 20 additions & 0 deletions tests/packagedcode/test_parse_pyproject_toml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import json
import toml
import os

def test_parse_pyproject_toml():

toml_path = "tests/packagedcode/data/pypi/pyproject-toml/standard/python_private_package/pyproject.toml"

expected_json_path = "tests/packagedcode/data/pypi/pyproject-toml/standard/python_private_package/pyproject.toml-expected.json"


with open(toml_path, 'r') as file:
toml_data = toml.load(file)


with open(expected_json_path, 'r') as file:
expected_data = json.load(file)


assert toml_data == expected_data, f"Parsed data does not match the expected data.\nParsed: {toml_data}\nExpected: {expected_data}"
6 changes: 3 additions & 3 deletions tests/packagedcode/test_pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,10 +339,10 @@ def test_parse_pyproject_toml_standard_lc0(self):
expected_loc = self.get_test_loc('pypi/pyproject-toml/standard/lc0-pyproject.toml-expected.json')
self.check_packages_data(package, expected_loc, regen=REGEN_TEST_FIXTURES)

def test_parse_pyproject_toml_private_package(self):
test_file = self.get_test_loc('pypi/pyproject-toml/private/private_package/pyproject.toml')
def test_parse_pyproject_toml_standard_python_private_package(self):
test_file = self.get_test_loc('pypi/pyproject-toml/standard/python_private_package/pyproject.toml')
package = pypi.PyprojectTomlHandler.parse(test_file)
expected_loc = self.get_test_loc('pypi/pyproject-toml/private/private_package-pyproject.toml-expected.json')
expected_loc = self.get_test_loc('pypi/pyproject-toml/standard/python_private_package-pyproject.toml-expected.json')
self.check_packages_data(package, expected_loc, regen=REGEN_TEST_FIXTURES)


Expand Down

0 comments on commit 0a92f7f

Please sign in to comment.