nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 117 lines 4.2 kB view raw
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 12runCommand "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) ${arelle.version}" > /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 # check if the arelleGUI command is available 27 command -v arelleGUI 28 ''} 29 30 # Create a simple but valid XBRL instance for testing validation functionality 31 cat > test-instance.xbrl << 'EOF' 32 <?xml version="1.0" encoding="UTF-8"?> 33 <xbrl xmlns="http://www.xbrl.org/2003/instance" 34 xmlns:link="http://www.xbrl.org/2003/linkbase" 35 xmlns:xlink="http://www.w3.org/1999/xlink"> 36 37 <link:schemaRef xlink:href="http://www.xbrl.org/2003/xbrl-instance-2003-12-31.xsd" xlink:type="simple"/> 38 39 <context id="test_context"> 40 <entity> 41 <identifier scheme="http://example.com/entities">TEST_ENTITY</identifier> 42 </entity> 43 <period> 44 <instant>2023-12-31</instant> 45 </period> 46 </context> 47 48 </xbrl> 49 EOF 50 51 # Also create a minimal test schema for more comprehensive testing 52 cat > test-schema.xsd << 'EOF' 53 <?xml version="1.0" encoding="UTF-8"?> 54 <schema xmlns="http://www.w3.org/2001/XMLSchema" 55 xmlns:xbrli="http://www.xbrl.org/2003/instance" 56 xmlns:link="http://www.xbrl.org/2003/linkbase" 57 xmlns:xlink="http://www.w3.org/1999/xlink" 58 xmlns:test="http://example.com/test" 59 targetNamespace="http://example.com/test" 60 elementFormDefault="qualified"> 61 62 <import namespace="http://www.xbrl.org/2003/instance" 63 schemaLocation="http://www.xbrl.org/2003/xbrl-instance-2003-12-31.xsd"/> 64 65 <element name="TestElement" type="xbrli:stringItemType" 66 substitutionGroup="xbrli:item" xbrli:periodType="instant"/> 67 68 </schema> 69 EOF 70 71 # Test XBRL validation functionality 72 arelleCmdLine \ 73 --file test-instance.xbrl \ 74 --validate \ 75 --disablePersistentConfig \ 76 --internetConnectivity=offline \ 77 --logLevel=info 2>&1 | grep "\[info\] validated in .* secs - .*test-instance.xbrl" > /dev/null 78 79 # Test with the built-in empty instance from arelle config 80 arelleCmdLine \ 81 --file "${arelle}/lib/python3.13/site-packages/arelle/config/empty-instance.xml" \ 82 --validate \ 83 --disablePersistentConfig \ 84 --internetConnectivity=offline \ 85 --logLevel=info 2>&1 | grep "\[info\] validated in .* secs - .*empty-instance.xml" > /dev/null 86 87 # Test formula functionality (without running - just checking it loads) 88 arelleCmdLine \ 89 --file test-instance.xbrl \ 90 --formula=none \ 91 --disablePersistentConfig \ 92 --internetConnectivity=offline 2>&1 | grep "\[info\] loaded in .* secs.*test-instance.xbrl" > /dev/null 93 94 # Test facts output functionality 95 TEMP_DIR=$(mktemp -d) 96 arelleCmdLine \ 97 --file test-instance.xbrl \ 98 --facts="$TEMP_DIR/test-facts.csv" \ 99 --disablePersistentConfig \ 100 --internetConnectivity=offline 2>&1 | grep "\[info\] loaded in .* secs.*test-instance.xbrl" > /dev/null 101 102 # Test schema validation 103 arelleCmdLine \ 104 --file test-schema.xsd \ 105 --validate \ 106 --disablePersistentConfig \ 107 --internetConnectivity=offline \ 108 --logLevel=info 2>&1 | grep "\[info\] validated in .* secs - .*test-schema.xsd" > /dev/null 109 110 # Test disclosure system validation option 111 arelleCmdLine \ 112 --disclosureSystem=help \ 113 --disablePersistentConfig 2>&1 | grep "Disclosure system choices:" > /dev/null 114 115 # Create success marker 116 touch $out 117 ''