|
| 1 | +"""Regression test for issue #1226. |
| 2 | +
|
| 3 | +GitHub Issue: https://github.com/dgunning/edgartools/issues/1226 |
| 4 | +
|
| 5 | +`XBRL.entity_info` classified the report by comparing the whole |
| 6 | +`dei:DocumentType` against `'10-K'`, so Shopify's 10-K/A came back with |
| 7 | +`amendment=True` alongside `annual_report=False` — a classification that |
| 8 | +contradicts itself and the filing, which tags `dei:DocumentAnnualReport` true. |
| 9 | +
|
| 10 | +An amended annual report is still an annual report. The suffix is now stripped |
| 11 | +before classifying, and the form list `period_selector` kept as its own tuple |
| 12 | +for the same decision is now the one both use |
| 13 | +(`edgar.xbrl.core.is_annual_document_type`). |
| 14 | +""" |
| 15 | + |
| 16 | +import pytest |
| 17 | + |
| 18 | +from edgar.xbrl.core import ( |
| 19 | + is_amendment_document_type, |
| 20 | + is_annual_document_type, |
| 21 | + is_quarterly_document_type, |
| 22 | +) |
| 23 | +from edgar.xbrl.parsers import XBRLParser |
| 24 | + |
| 25 | +INSTANCE = """<?xml version="1.0" encoding="UTF-8"?> |
| 26 | +<xbrl xmlns="http://www.xbrl.org/2003/instance" |
| 27 | + xmlns:xbrli="http://www.xbrl.org/2003/instance" |
| 28 | + xmlns:dei="http://xbrl.sec.gov/dei/2024" |
| 29 | + xmlns:xlink="http://www.w3.org/1999/xlink"> |
| 30 | + <context id="c1"> |
| 31 | + <entity><identifier scheme="http://www.sec.gov/CIK">0001594805</identifier></entity> |
| 32 | + <period><startDate>2024-01-01</startDate><endDate>2024-12-31</endDate></period> |
| 33 | + </context> |
| 34 | + <dei:DocumentType contextRef="c1">{document_type}</dei:DocumentType> |
| 35 | + <dei:AmendmentFlag contextRef="c1">true</dei:AmendmentFlag> |
| 36 | + <dei:DocumentAnnualReport contextRef="c1">true</dei:DocumentAnnualReport> |
| 37 | + <dei:DocumentFiscalPeriodFocus contextRef="c1">FY</dei:DocumentFiscalPeriodFocus> |
| 38 | + <dei:DocumentFiscalYearFocus contextRef="c1">2024</dei:DocumentFiscalYearFocus> |
| 39 | + <dei:EntityRegistrantName contextRef="c1">SHOPIFY INC.</dei:EntityRegistrantName> |
| 40 | +</xbrl> |
| 41 | +""" |
| 42 | + |
| 43 | + |
| 44 | +def _entity_info(document_type): |
| 45 | + parser = XBRLParser() |
| 46 | + parser.parse_instance_content(INSTANCE.format(document_type=document_type)) |
| 47 | + return parser.entity_info |
| 48 | + |
| 49 | + |
| 50 | +def test_amended_annual_report_keeps_both_halves_of_its_identity(): |
| 51 | + """The report's own case: Shopify's 10-K/A, accession 0001594805-25-000039.""" |
| 52 | + info = _entity_info("10-K/A") |
| 53 | + |
| 54 | + assert info["entity_name"] == "SHOPIFY INC." |
| 55 | + assert info["document_type"] == "10-K/A" |
| 56 | + assert info["annual_report"] is True |
| 57 | + assert info["amendment"] is True |
| 58 | + assert info["quarterly_report"] is False |
| 59 | + |
| 60 | + |
| 61 | +def test_an_unamended_annual_report_is_unchanged(): |
| 62 | + info = _entity_info("10-K") |
| 63 | + |
| 64 | + assert info["annual_report"] is True |
| 65 | + assert info["amendment"] is False |
| 66 | + |
| 67 | + |
| 68 | +def test_an_amended_quarterly_report_is_still_quarterly(): |
| 69 | + info = _entity_info("10-Q/A") |
| 70 | + |
| 71 | + assert info["quarterly_report"] is True |
| 72 | + assert info["amendment"] is True |
| 73 | + assert info["annual_report"] is False |
| 74 | + |
| 75 | + |
| 76 | +@pytest.mark.parametrize("document_type,annual,quarterly,amendment", [ |
| 77 | + ("10-K", True, False, False), |
| 78 | + ("10-K/A", True, False, True), |
| 79 | + ("10-KT", True, False, False), |
| 80 | + ("20-F", True, False, False), |
| 81 | + ("20-F/A", True, False, True), |
| 82 | + ("40-F", True, False, False), |
| 83 | + ("10-Q", False, True, False), |
| 84 | + ("10-Q/A", False, True, True), |
| 85 | + ("8-K", False, False, False), |
| 86 | + ("", False, False, False), |
| 87 | + (None, False, False, False), |
| 88 | +]) |
| 89 | +def test_document_type_classification(document_type, annual, quarterly, amendment): |
| 90 | + assert is_annual_document_type(document_type) is annual |
| 91 | + assert is_quarterly_document_type(document_type) is quarterly |
| 92 | + assert is_amendment_document_type(document_type) is amendment |
0 commit comments