|
| 1 | +# Run with: |
| 2 | +# cd nixpkgs |
| 3 | +# nix-build -A python3Packages.arelle.passthru.tests.cli |
| 4 | +# |
| 5 | +# Note: These are uninteresting generated smoke tests to verify basic functionality |
| 6 | +{ |
| 7 | + lib, |
| 8 | + runCommand, |
| 9 | + arelle, |
| 10 | +}: |
| 11 | + |
| 12 | +runCommand "arelle-test-cli${lib.optionalString (!arelle.hasGUI) "-headless"}" |
| 13 | + { |
| 14 | + nativeBuildInputs = [ arelle ]; |
| 15 | + } |
| 16 | + '' |
| 17 | + # Set up temporary home directory |
| 18 | + export HOME=$(mktemp -d) |
| 19 | +
|
| 20 | + # Test basic CLI commands work with proper assertions |
| 21 | + arelleCmdLine --version --disablePersistentConfig 2>&1 | grep "Arelle(r) 2.37.59" > /dev/null |
| 22 | + arelleCmdLine --help --disablePersistentConfig 2>&1 | grep "Usage: arelleCmdLine \[options\]" > /dev/null |
| 23 | + arelleCmdLine --about --disablePersistentConfig 2>&1 | grep "An open source XBRL platform" > /dev/null |
| 24 | +
|
| 25 | + ${lib.optionalString arelle.hasGUI '' |
| 26 | + # Test executables exist and are accessible |
| 27 | + if [ -f "${lib.getBin arelle}/bin/arelleGUI" ]; then |
| 28 | + test -x "${lib.getBin arelle}/bin/arelleGUI" |
| 29 | + fi |
| 30 | + ''} |
| 31 | +
|
| 32 | + # Create a simple but valid XBRL instance for testing validation functionality |
| 33 | + cat > test-instance.xbrl << 'EOF' |
| 34 | + <?xml version="1.0" encoding="UTF-8"?> |
| 35 | + <xbrl xmlns="http://www.xbrl.org/2003/instance" |
| 36 | + xmlns:link="http://www.xbrl.org/2003/linkbase" |
| 37 | + xmlns:xlink="http://www.w3.org/1999/xlink"> |
| 38 | +
|
| 39 | + <link:schemaRef xlink:href="http://www.xbrl.org/2003/xbrl-instance-2003-12-31.xsd" xlink:type="simple"/> |
| 40 | +
|
| 41 | + <context id="test_context"> |
| 42 | + <entity> |
| 43 | + <identifier scheme="http://example.com/entities">TEST_ENTITY</identifier> |
| 44 | + </entity> |
| 45 | + <period> |
| 46 | + <instant>2023-12-31</instant> |
| 47 | + </period> |
| 48 | + </context> |
| 49 | +
|
| 50 | + </xbrl> |
| 51 | + EOF |
| 52 | +
|
| 53 | + # Also create a minimal test schema for more comprehensive testing |
| 54 | + cat > test-schema.xsd << 'EOF' |
| 55 | + <?xml version="1.0" encoding="UTF-8"?> |
| 56 | + <schema xmlns="http://www.w3.org/2001/XMLSchema" |
| 57 | + xmlns:xbrli="http://www.xbrl.org/2003/instance" |
| 58 | + xmlns:link="http://www.xbrl.org/2003/linkbase" |
| 59 | + xmlns:xlink="http://www.w3.org/1999/xlink" |
| 60 | + xmlns:test="http://example.com/test" |
| 61 | + targetNamespace="http://example.com/test" |
| 62 | + elementFormDefault="qualified"> |
| 63 | +
|
| 64 | + <import namespace="http://www.xbrl.org/2003/instance" |
| 65 | + schemaLocation="http://www.xbrl.org/2003/xbrl-instance-2003-12-31.xsd"/> |
| 66 | +
|
| 67 | + <element name="TestElement" type="xbrli:stringItemType" |
| 68 | + substitutionGroup="xbrli:item" xbrli:periodType="instant"/> |
| 69 | +
|
| 70 | + </schema> |
| 71 | + EOF |
| 72 | +
|
| 73 | + # Test XBRL validation functionality |
| 74 | + arelleCmdLine \ |
| 75 | + --file test-instance.xbrl \ |
| 76 | + --validate \ |
| 77 | + --disablePersistentConfig \ |
| 78 | + --internetConnectivity=offline \ |
| 79 | + --logLevel=info 2>&1 | grep "\[info\] validated in .* secs - .*test-instance.xbrl" > /dev/null |
| 80 | +
|
| 81 | + # Test with the built-in empty instance from arelle config |
| 82 | + arelleCmdLine \ |
| 83 | + --file "${arelle}/lib/python3.13/site-packages/arelle/config/empty-instance.xml" \ |
| 84 | + --validate \ |
| 85 | + --disablePersistentConfig \ |
| 86 | + --internetConnectivity=offline \ |
| 87 | + --logLevel=info 2>&1 | grep "\[info\] validated in .* secs - .*empty-instance.xml" > /dev/null |
| 88 | +
|
| 89 | + # Test formula functionality (without running - just checking it loads) |
| 90 | + arelleCmdLine \ |
| 91 | + --file test-instance.xbrl \ |
| 92 | + --formula=none \ |
| 93 | + --disablePersistentConfig \ |
| 94 | + --internetConnectivity=offline 2>&1 | grep "\[info\] loaded in .* secs.*test-instance.xbrl" > /dev/null |
| 95 | +
|
| 96 | + # Test facts output functionality |
| 97 | + TEMP_DIR=$(mktemp -d) |
| 98 | + arelleCmdLine \ |
| 99 | + --file test-instance.xbrl \ |
| 100 | + --facts="$TEMP_DIR/test-facts.csv" \ |
| 101 | + --disablePersistentConfig \ |
| 102 | + --internetConnectivity=offline 2>&1 | grep "\[info\] loaded in .* secs.*test-instance.xbrl" > /dev/null |
| 103 | +
|
| 104 | + # Test schema validation |
| 105 | + arelleCmdLine \ |
| 106 | + --file test-schema.xsd \ |
| 107 | + --validate \ |
| 108 | + --disablePersistentConfig \ |
| 109 | + --internetConnectivity=offline \ |
| 110 | + --logLevel=info 2>&1 | grep "\[info\] validated in .* secs - .*test-schema.xsd" > /dev/null |
| 111 | +
|
| 112 | + # Test disclosure system validation option |
| 113 | + arelleCmdLine \ |
| 114 | + --disclosureSystem=help \ |
| 115 | + --disablePersistentConfig 2>&1 | grep "Disclosure system choices:" > /dev/null |
| 116 | +
|
| 117 | + # Create success marker |
| 118 | + touch $out |
| 119 | + '' |
0 commit comments