Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ Mr. Shahadad PP

Ms. Priti Kumari

Mr. Adnan Abdullah

===============================

Project Management
Expand Down
Empty file added tests/__init__.py
Empty file.
35 changes: 35 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# tests/conftest.py
import pytest

class DummyBolt:
def __init__(self, diameter):
self.diameter = diameter

class DummyMember:
def __init__(self, web_thickness=10, flange_thickness=20, depth=300, flange_width=150, r1=5):
self.web_thickness = web_thickness
self.flange_thickness = flange_thickness
self.depth = depth
self.flange_width = flange_width
self.r1 = r1

class DummyPlate:
def __init__(self, thickness, height):
self.thickness = thickness
self.height = height

@pytest.fixture
def bolt():
return DummyBolt(diameter=20)

@pytest.fixture
def supported_member():
return DummyMember(web_thickness=12, flange_thickness=18, depth=300, flange_width=180, r1=6)

@pytest.fixture
def supporting_member():
return DummyMember(web_thickness=10, flange_thickness=15, depth=310, flange_width=190, r1=5)

@pytest.fixture
def plate():
return DummyPlate(thickness=10, height=120)
11 changes: 11 additions & 0 deletions tests/dummy_is800.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# tests/dummy_is800.py
class FakeIS800:
@staticmethod
def cl_10_5_2_3_min_weld_size(p1, p2):
return 2

@staticmethod
def cl_10_5_3_1_max_weld_throat_thickness(p1, p2):
return 4

IS800_2007 = FakeIS800()
18 changes: 18 additions & 0 deletions tests/osdag_screening/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Python virtual environments
.venv/
venv310/

# Python cache
__pycache__/
*.pyc

# PyTest cache
.pytest_cache/

# Build/Executable files
dist/
build/

# OS files
Thumbs.db
.DS_Store
21 changes: 21 additions & 0 deletions tests/osdag_screening/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 sandipanb01

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1 change: 1 addition & 0 deletions tests/osdag_screening/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Complete screening task files for FOSSEE Osdag
3 changes: 3 additions & 0 deletions tests/osdag_screening/batch.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fu,410
bolt,M20,8.8
plate,10,250
13 changes: 13 additions & 0 deletions tests/osdag_screening/batch1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{"command": "fu", "args": ["410"]},
{"command": "fy", "args": ["250"]},
{"command": "tf", "args": ["10"]},
{"command": "bolt", "args": ["M20", "8.8"]},
{"command": "plate", "args": ["10", "250"]},
{"command": "fu", "args": ["0"]},
{"command": "fy", "args": ["-10"]},
{"command": "tf", "args": ["-5"]},
{"command": "bolt", "args": ["M99", "8.8"]},
{"command": "plate", "args": ["-10", "200"]}
]

Empty file.
23 changes: 23 additions & 0 deletions tests/osdag_screening/demo_module/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# demo_module/utils.py
"""Small demo utilities."""

def compute_area(width, height):
if width is None or height is None:
raise TypeError("width and height must be numbers")
try:
if width < 0 or height < 0:
raise ValueError("dimensions must be non-negative")
except TypeError:
raise TypeError("width and height must be numbers")
return width * height

def parse_profile_string(s):
if not isinstance(s, str):
raise TypeError("profile must be a string")
try:
t = s[0]
rest = s[1:]
a_str, b_str = rest.split('x')
return {"type": t, "a": int(a_str), "b": int(b_str)}
except:
raise ValueError("invalid profile format")
52 changes: 52 additions & 0 deletions tests/osdag_screening/install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import os
import shutil
import sys
from pathlib import Path
import stat

print("\n=== Installing osdag-validator-cli ===")

ROOT = Path(__file__).resolve().parent
SRC = ROOT / "osdag_validator_cli"

def remove_readonly(func, path, exc):
"""Make read-only files writable and retry delete."""
os.chmod(path, stat.S_IWRITE)
func(path)

def safe_rmtree(path: Path):
"""Remove a directory even if __pycache__ is locked or read-only."""
if path.exists():
shutil.rmtree(path, onerror=remove_readonly)

def install_package():
venv_site = Path(sys.executable).parent.parent / "Lib" / "site-packages"
dst = venv_site / "osdag_validator_cli"

if not SRC.exists():
print("ERROR: osdag_validator_cli/ not found beside install.py")
sys.exit(1)

print(f"Source: {SRC}")
print(f"Target: {dst}")

# 1 — Remove existing installation (safe)
if dst.exists():
print("Removing old installation...")
safe_rmtree(dst)

# 2 — Copy fresh package
print("Copying new package...")
shutil.copytree(SRC, dst)

print("\nSUCCESS: osdag-validator-cli installed.")
print("You can now run:")
print(" python -m osdag_validator_cli.auto_cli")
print(" python -m osdag_validator_cli.cli_typer")
print(" python -m osdag_validator_cli.cli")

def main():
install_package()

if __name__ == "__main__":
main()
38 changes: 38 additions & 0 deletions tests/osdag_screening/osdag-val.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# -*- mode: python ; coding: utf-8 -*-


a = Analysis(
['osdag_validator_cli\\entry.py'],
pathex=[],
binaries=[],
datas=[('Osdag\\src\\osdag\\data\\ResourceFiles', 'osdag\\data\\ResourceFiles')],
hiddenimports=['osdag', 'osdag.data', 'osdag_validator'],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name='osdag-val',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
6 changes: 6 additions & 0 deletions tests/osdag_screening/osdag-validator-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# osdag-validator-cli

Small CLI wrapper around osdag_validator.Validator.

Install (from repo root):

33 changes: 33 additions & 0 deletions tests/osdag_screening/osdag-validator-cli/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[build-system]
requires = ["setuptools>=61.0", "wheel", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "osdag-validator-cli"
version = "0.1.0"
description = "Command-line wrappers around osdag_validator for validation tasks (fu, fy, plate, bolt, etc.)"
readme = "README.md"
requires-python = ">=3.8"
license = { text = "MIT" }
authors = [
{name="Sandipan Bhattacherjee", email="sandipanb12@gmail.com"}
]
keywords = ["osdag", "cli", "validator", "construction", "foss"]
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent"
]

[project.urls]
"Homepage" = "https://github.com/sandipanb01"
"Source" = "https://github.com/sandipanb01"

[tool.setuptools.packages.find]
where = ["."]

# --------------------------------------------------------
# ⭐ CRUCIAL PART — SCRIPT ENTRYPOINT
# --------------------------------------------------------
[project.scripts]
osdag-val = "osdag_validator_cli.cli:main"
21 changes: 21 additions & 0 deletions tests/osdag_screening/osdag-validator-cli/tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import subprocess
import sys
import os

# run the installed console script using the interpreter in the current venv
PY = sys.executable

def run(cmd_args):
# execute using python -m to be robust
p = subprocess.run([PY, "-m", "osdag_validator_cli.cli"] + cmd_args, capture_output=True, text=True)
return p

def test_fu_410_valid():
p = run(["fu", "410"])
assert p.returncode == 0
assert ("Valid" in p.stdout) or ("Invalid" in p.stdout)

def test_show_help():
p = run([])
assert p.returncode == 0
assert "usage" in p.stdout.lower()
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# osdag-validator-cli/tests/test_cli_generated.py
"""
Generated tests for osdag_validator_cli.cli

These tests run the CLI using the same Python interpreter (sys.executable).
They expect the CLI module to be importable via `python -m osdag_validator_cli.cli`.
If a particular Validator method isn't implemented, the CLI intentionally prints
"Invalid" and returns 0 for that command (this behavior is accepted by the tests).
"""

import sys
import subprocess
import pytest

PY = sys.executable

def run_cli(args):
"""Run the CLI module and return CompletedProcess (capture text)."""
cmd = [PY, "-m", "osdag_validator_cli.cli"] + args
p = subprocess.run(cmd, capture_output=True, text=True)
return p

def assert_valid_or_invalid(stdout):
"""Helper: pass if stdout contains 'Valid' or 'Invalid' (case-sensitive)."""
s = stdout.strip()
assert ("Valid" in s) or ("Invalid" in s), f"stdout does not contain Valid/Invalid: {s!r}"

def test_fu_valid():
p = run_cli(["fu", "410"])
assert p.returncode == 0
assert_valid_or_invalid(p.stdout)

def test_fy_valid():
p = run_cli(["fy", "250"])
assert p.returncode == 0
assert_valid_or_invalid(p.stdout)

def test_fu_fy_relation():
p = run_cli(["fu-fy", "410", "250"])
assert p.returncode == 0
assert_valid_or_invalid(p.stdout)

def test_number_check():
p = run_cli(["number", "12.5"])
assert p.returncode == 0
assert_valid_or_invalid(p.stdout)

def test_positive_check():
p = run_cli(["positive", "8"])
assert p.returncode == 0
assert_valid_or_invalid(p.stdout)

def test_tf_if_present():
p = run_cli(["tf", "20"])
# Accept either normal valid/invalid output or 'Invalid' if function missing
assert p.returncode == 0
assert_valid_or_invalid(p.stdout)

def test_bolt_if_present():
p = run_cli(["bolt", "M20", "8.8"])
assert p.returncode == 0
assert_valid_or_invalid(p.stdout)

def test_plate_if_present():
p = run_cli(["plate", "10", "250"])
assert p.returncode == 0
assert_valid_or_invalid(p.stdout)
Empty file.
5 changes: 5 additions & 0 deletions tests/osdag_screening/osdag_validator/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#from .core import *
#from .plugin import load_plugin
from .validator import Validator

__all__ = ["Validator"]
15 changes: 15 additions & 0 deletions tests/osdag_screening/osdag_validator/core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from osdag.utils.validator import (
Validator,
ConnectionValidator,
ShearConnectionValidator,
FinPlateConnectionValidator,
EndPlateConnectionValidator
)

__all__ = [
"Validator",
"ConnectionValidator",
"ShearConnectionValidator",
"FinPlateConnectionValidator",
"EndPlateConnectionValidator",
]
Loading