tap-foxapis 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,10 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .pytest_cache/
4
+ dist/
5
+ build/
6
+ *.egg-info/
7
+ .venv/
8
+ .env
9
+ config.json
10
+ dist/
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 FoxAPIs
4
+
5
+ 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:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ 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.
@@ -0,0 +1,75 @@
1
+ Metadata-Version: 2.5
2
+ Name: tap-foxapis
3
+ Version: 0.1.0
4
+ Summary: Singer tap for FoxAPIs: Form D raises, layoff records and executive changes.
5
+ Project-URL: Homepage, https://foxapis.com/docs
6
+ Project-URL: Repository, https://github.com/OsakaSaul/tap-foxapis
7
+ Project-URL: Issues, https://github.com/OsakaSaul/tap-foxapis/issues
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: company-data,elt,foxapis,meltano,singer,tap
11
+ Requires-Python: >=3.9
12
+ Requires-Dist: singer-sdk>=0.40
13
+ Provides-Extra: dev
14
+ Requires-Dist: pytest; extra == 'dev'
15
+ Requires-Dist: responses; extra == 'dev'
16
+ Description-Content-Type: text/markdown
17
+
18
+ # tap-foxapis
19
+
20
+ A [Singer](https://www.singer.io) tap for [FoxAPIs](https://foxapis.com/docs?ref=gh-singer-tap), built with the [Meltano Singer SDK](https://sdk.meltano.com). It reads three sourced record sets into your warehouse.
21
+
22
+ | Stream | What it holds | Incremental by |
23
+ | --- | --- | --- |
24
+ | `form_d_raises` | Private raises filed on Form D, with the amounts and the filing link | `filed` |
25
+ | `layoffs` | US layoff records with company, place, headcount and the notice link | `date` |
26
+ | `executive_changes` | Executive appointments and departures, one record per filing | `filed` |
27
+
28
+ Each record returned is charged in credits from the account of your key; what a call costs is listed at https://foxapis.com/pricing?ref=gh-singer-tap . A request that returns nothing is not charged. A key with free starting credits: https://foxapis.com/trial?ref=gh-singer-tap . Start with a recent `start_date` and a small `page_size`.
29
+
30
+ ## Install
31
+
32
+ ```bash
33
+ pipx install tap-foxapis
34
+ ```
35
+
36
+ With Meltano, from your project:
37
+
38
+ ```bash
39
+ meltano add extractor tap-foxapis
40
+ meltano config tap-foxapis set api_key <your key>
41
+ meltano run tap-foxapis target-jsonl
42
+ ```
43
+
44
+ ## Settings
45
+
46
+ | Setting | Required | Default | What it does |
47
+ | --- | --- | --- | --- |
48
+ | `api_key` | yes | | Your FoxAPIs key. Kept secret. |
49
+ | `start_date` | no | | Earliest filing or notice date on the first run (YYYY-MM-DD). Later runs continue from the saved state. |
50
+ | `page_size` | no | 100 | Records per request (executive changes: filings per request). |
51
+ | `state` | no | | Two-letter US state code (Form D raises and layoffs). |
52
+ | `industry` | no | | Industry group text (Form D raises). |
53
+ | `company` | no | | Company name words (layoffs and executive changes). |
54
+ | `min_employees` | no | | Smallest headcount (layoffs). |
55
+ | `cik` | no | | Company registry number (executive changes). |
56
+ | `base_url` | no | `https://api.foxapis.com` | Leave the default. |
57
+
58
+ Run `tap-foxapis --about` for the same list from the tool.
59
+
60
+ ## Develop
61
+
62
+ ```bash
63
+ pip install -e ".[dev]"
64
+ pytest
65
+ ```
66
+
67
+ The tests replace the HTTP answers and need no key. The REST reference is https://foxapis.com/openapi.json .
68
+
69
+ ## Not for
70
+
71
+ Do not use these records to decide on credit, employment, housing or insurance eligibility.
72
+
73
+ ## License
74
+
75
+ MIT
@@ -0,0 +1,58 @@
1
+ # tap-foxapis
2
+
3
+ A [Singer](https://www.singer.io) tap for [FoxAPIs](https://foxapis.com/docs?ref=gh-singer-tap), built with the [Meltano Singer SDK](https://sdk.meltano.com). It reads three sourced record sets into your warehouse.
4
+
5
+ | Stream | What it holds | Incremental by |
6
+ | --- | --- | --- |
7
+ | `form_d_raises` | Private raises filed on Form D, with the amounts and the filing link | `filed` |
8
+ | `layoffs` | US layoff records with company, place, headcount and the notice link | `date` |
9
+ | `executive_changes` | Executive appointments and departures, one record per filing | `filed` |
10
+
11
+ Each record returned is charged in credits from the account of your key; what a call costs is listed at https://foxapis.com/pricing?ref=gh-singer-tap . A request that returns nothing is not charged. A key with free starting credits: https://foxapis.com/trial?ref=gh-singer-tap . Start with a recent `start_date` and a small `page_size`.
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ pipx install tap-foxapis
17
+ ```
18
+
19
+ With Meltano, from your project:
20
+
21
+ ```bash
22
+ meltano add extractor tap-foxapis
23
+ meltano config tap-foxapis set api_key <your key>
24
+ meltano run tap-foxapis target-jsonl
25
+ ```
26
+
27
+ ## Settings
28
+
29
+ | Setting | Required | Default | What it does |
30
+ | --- | --- | --- | --- |
31
+ | `api_key` | yes | | Your FoxAPIs key. Kept secret. |
32
+ | `start_date` | no | | Earliest filing or notice date on the first run (YYYY-MM-DD). Later runs continue from the saved state. |
33
+ | `page_size` | no | 100 | Records per request (executive changes: filings per request). |
34
+ | `state` | no | | Two-letter US state code (Form D raises and layoffs). |
35
+ | `industry` | no | | Industry group text (Form D raises). |
36
+ | `company` | no | | Company name words (layoffs and executive changes). |
37
+ | `min_employees` | no | | Smallest headcount (layoffs). |
38
+ | `cik` | no | | Company registry number (executive changes). |
39
+ | `base_url` | no | `https://api.foxapis.com` | Leave the default. |
40
+
41
+ Run `tap-foxapis --about` for the same list from the tool.
42
+
43
+ ## Develop
44
+
45
+ ```bash
46
+ pip install -e ".[dev]"
47
+ pytest
48
+ ```
49
+
50
+ The tests replace the HTTP answers and need no key. The REST reference is https://foxapis.com/openapi.json .
51
+
52
+ ## Not for
53
+
54
+ Do not use these records to decide on credit, employment, housing or insurance eligibility.
55
+
56
+ ## License
57
+
58
+ MIT
@@ -0,0 +1,33 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "tap-foxapis"
7
+ version = "0.1.0"
8
+ description = "Singer tap for FoxAPIs: Form D raises, layoff records and executive changes."
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = "MIT"
12
+ keywords = ["singer", "meltano", "tap", "foxapis", "elt", "company-data"]
13
+ dependencies = ["singer-sdk>=0.40"]
14
+
15
+ [project.optional-dependencies]
16
+ dev = ["pytest", "responses"]
17
+
18
+ [project.urls]
19
+ Homepage = "https://foxapis.com/docs"
20
+ Repository = "https://github.com/OsakaSaul/tap-foxapis"
21
+ Issues = "https://github.com/OsakaSaul/tap-foxapis/issues"
22
+
23
+ [project.scripts]
24
+ tap-foxapis = "tap_foxapis.tap:TapFoxAPIs.cli"
25
+
26
+ [tool.hatch.build.targets.wheel]
27
+ packages = ["tap_foxapis"]
28
+
29
+ [tool.hatch.build.targets.sdist]
30
+ include = ["tap_foxapis/", "tests/", "README.md", "LICENSE"]
31
+
32
+ [tool.pytest.ini_options]
33
+ testpaths = ["tests"]
@@ -0,0 +1 @@
1
+ """Singer tap for FoxAPIs."""
@@ -0,0 +1,60 @@
1
+ """REST client shared by the FoxAPIs streams."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import typing as t
6
+
7
+ from singer_sdk.authenticators import BearerTokenAuthenticator
8
+ from singer_sdk.pagination import BaseAPIPaginator
9
+ from singer_sdk.streams import RESTStream
10
+
11
+ if t.TYPE_CHECKING:
12
+ import requests
13
+
14
+ DEFAULT_URL_BASE = "https://api.foxapis.com"
15
+
16
+
17
+ class CursorPaginator(BaseAPIPaginator[t.Optional[str]]):
18
+ """Follow `next_cursor` while the answer says `has_more`."""
19
+
20
+ def __init__(self) -> None:
21
+ super().__init__(None)
22
+
23
+ def get_next(self, response: requests.Response) -> str | None:
24
+ body = response.json()
25
+ if body.get("has_more") and body.get("next_cursor"):
26
+ return str(body["next_cursor"])
27
+ return None
28
+
29
+
30
+ class PagePaginator(BaseAPIPaginator[int]):
31
+ """Page through a list that answers `page_size` records per page until a short page comes back."""
32
+
33
+ def __init__(self, page_size: int) -> None:
34
+ super().__init__(1)
35
+ self.page_size = page_size
36
+
37
+ def has_more(self, response: requests.Response) -> bool:
38
+ records = response.json().get("records") or []
39
+ return len(records) >= self.page_size
40
+
41
+ def get_next(self, response: requests.Response) -> int | None:
42
+ return self.current_value + 1
43
+
44
+
45
+ class FoxAPIsStream(RESTStream):
46
+ """Base stream: Bearer key, fixed address, nothing but the records leaves the tap."""
47
+
48
+ @property
49
+ def url_base(self) -> str:
50
+ return str(self.config.get("base_url") or DEFAULT_URL_BASE).rstrip("/")
51
+
52
+ @property
53
+ def authenticator(self) -> BearerTokenAuthenticator:
54
+ return BearerTokenAuthenticator.create_for_stream(self, token=self.config["api_key"])
55
+
56
+ @property
57
+ def http_headers(self) -> dict:
58
+ headers = super().http_headers
59
+ headers["User-Agent"] = "tap-foxapis/0.1.0"
60
+ return headers
@@ -0,0 +1,140 @@
1
+ """Streams: Form D raises, layoff records and executive changes."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import typing as t
6
+
7
+ from singer_sdk import typing as th
8
+
9
+ from tap_foxapis.client import CursorPaginator, FoxAPIsStream, PagePaginator
10
+
11
+ if t.TYPE_CHECKING:
12
+ from singer_sdk.helpers.types import Context
13
+
14
+
15
+ class _ListStream(FoxAPIsStream):
16
+ """The two list calls: a `rows` array, filters in the query string, a cursor for the next page."""
17
+
18
+ http_method = "GET"
19
+ records_jsonpath = "$.rows[*]"
20
+ start_param = "date_from"
21
+
22
+ def get_new_paginator(self) -> CursorPaginator:
23
+ return CursorPaginator()
24
+
25
+ def get_url_params(self, context: Context | None, next_page_token: str | None) -> dict[str, t.Any]:
26
+ params: dict[str, t.Any] = {"limit": int(self.config.get("page_size", 100))}
27
+ start = self.get_starting_replication_key_value(context)
28
+ if start:
29
+ params[self.start_param] = str(start)[:10]
30
+ if next_page_token:
31
+ params["cursor"] = next_page_token
32
+ for key in self.extra_filters:
33
+ if self.config.get(key) not in (None, ""):
34
+ params[key] = self.config[key]
35
+ return params
36
+
37
+ extra_filters: t.ClassVar[tuple[str, ...]] = ()
38
+
39
+
40
+ class FormDRaisesStream(_ListStream):
41
+ """Private raises filed on Form D, newest first. Each row returned is charged."""
42
+
43
+ name = "form_d_raises"
44
+ path = "/v1/raises/form-d/list"
45
+ primary_keys = ("accession",)
46
+ replication_key = "filed"
47
+ extra_filters = ("state", "industry")
48
+
49
+ schema = th.PropertiesList(
50
+ th.Property("accession", th.StringType, description="Filing number."),
51
+ th.Property("filed", th.DateType, description="Filing date."),
52
+ th.Property("signed", th.DateType),
53
+ th.Property("issuer", th.StringType),
54
+ th.Property("sec_cik", th.StringType),
55
+ th.Property("city", th.StringType),
56
+ th.Property("state", th.StringType),
57
+ th.Property("industry", th.StringType),
58
+ th.Property("entity_type", th.StringType),
59
+ th.Property("year_formed", th.StringType),
60
+ th.Property("amendment", th.BooleanType),
61
+ th.Property("sold_usd", th.NumberType, description="Amount sold, US dollars."),
62
+ th.Property("offering_usd", th.NumberType, description="Offering amount, US dollars."),
63
+ th.Property("offering_as_filed", th.StringType),
64
+ th.Property("first_form_d_in_our_records", th.BooleanType),
65
+ th.Property("source_url", th.StringType, description="Link to the filing."),
66
+ ).to_dict()
67
+
68
+
69
+ class LayoffsStream(_ListStream):
70
+ """Layoff records, newest first. Each row returned is charged."""
71
+
72
+ name = "layoffs"
73
+ path = "/v1/layoffs/list"
74
+ primary_keys = ("source_url", "company", "date", "city")
75
+ replication_key = "date"
76
+ extra_filters = ("state", "company", "min_employees")
77
+
78
+ schema = th.PropertiesList(
79
+ th.Property("date", th.DateType, description="Notice date."),
80
+ th.Property("company", th.StringType),
81
+ th.Property("city", th.StringType),
82
+ th.Property("county", th.StringType),
83
+ th.Property("state", th.StringType),
84
+ th.Property("employees", th.IntegerType, description="Affected employees."),
85
+ th.Property("kind", th.StringType),
86
+ th.Property("type", th.StringType),
87
+ th.Property("permanence", th.StringType),
88
+ th.Property("effective_date", th.DateType),
89
+ th.Property("date_precision", th.StringType),
90
+ th.Property("industry_as_filed", th.StringType),
91
+ th.Property("warn_notice_id", th.IntegerType),
92
+ th.Property("source_url", th.StringType, description="Link to the notice."),
93
+ ).to_dict()
94
+
95
+
96
+ class ExecutiveChangesStream(FoxAPIsStream):
97
+ """Executive appointments and departures, one record per filing, newest first. Each filing returned is charged."""
98
+
99
+ name = "executive_changes"
100
+ path = "/v1/executive_changes"
101
+ http_method = "POST"
102
+ records_jsonpath = "$.records[*]"
103
+ primary_keys = ("accession",)
104
+ replication_key = "filed"
105
+
106
+ schema = th.PropertiesList(
107
+ th.Property("accession", th.StringType, description="Filing number."),
108
+ th.Property("form", th.StringType),
109
+ th.Property("filed", th.DateType, description="Filing date."),
110
+ th.Property("company", th.StringType),
111
+ th.Property("sec_cik", th.StringType),
112
+ th.Property("tickers", th.StringType),
113
+ th.Property(
114
+ "changes",
115
+ th.ArrayType(
116
+ th.ObjectType(
117
+ th.Property("role", th.StringType),
118
+ th.Property("person", th.StringType),
119
+ th.Property("change_type", th.StringType),
120
+ th.Property("effective_date", th.DateType),
121
+ th.Property("sentence", th.StringType),
122
+ ),
123
+ ),
124
+ ),
125
+ th.Property("filing_url", th.StringType),
126
+ th.Property("document_url", th.StringType),
127
+ ).to_dict()
128
+
129
+ def get_new_paginator(self) -> PagePaginator:
130
+ return PagePaginator(int(self.config.get("page_size", 10)))
131
+
132
+ def prepare_request_payload(self, context: Context | None, next_page_token: int | None) -> dict | None:
133
+ payload: dict[str, t.Any] = {"page": next_page_token or 1, "page_size": int(self.config.get("page_size", 10))}
134
+ start = self.get_starting_replication_key_value(context)
135
+ if start:
136
+ payload["filed_from"] = str(start)[:10]
137
+ for key in ("company", "cik"):
138
+ if self.config.get(key) not in (None, ""):
139
+ payload[key] = self.config[key]
140
+ return payload
@@ -0,0 +1,61 @@
1
+ """FoxAPIs tap class."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from singer_sdk import Tap
6
+ from singer_sdk import typing as th
7
+
8
+ from tap_foxapis import streams
9
+
10
+
11
+ class TapFoxAPIs(Tap):
12
+ """Singer tap for FoxAPIs: sourced company and people records (https://foxapis.com/docs)."""
13
+
14
+ name = "tap-foxapis"
15
+
16
+ config_jsonschema = th.PropertiesList(
17
+ th.Property(
18
+ "api_key",
19
+ th.StringType,
20
+ required=True,
21
+ secret=True,
22
+ title="API key",
23
+ description="Your FoxAPIs key. Free starting credits: https://foxapis.com/trial",
24
+ ),
25
+ th.Property(
26
+ "start_date",
27
+ th.DateType,
28
+ title="Start date",
29
+ description="Earliest filing or notice date to read on the first run (YYYY-MM-DD). Later runs continue from the saved state.",
30
+ ),
31
+ th.Property(
32
+ "page_size",
33
+ th.IntegerType,
34
+ default=100,
35
+ title="Page size",
36
+ description="Records per request. Each record returned is charged, so a small first run is cheap.",
37
+ ),
38
+ th.Property("state", th.StringType, title="State", description="Two-letter US state code (Form D raises and layoffs)."),
39
+ th.Property("industry", th.StringType, title="Industry", description="Industry group text (Form D raises)."),
40
+ th.Property("company", th.StringType, title="Company", description="Company name words (layoffs and executive changes)."),
41
+ th.Property("min_employees", th.IntegerType, title="Minimum employees", description="Smallest headcount (layoffs)."),
42
+ th.Property("cik", th.IntegerType, title="CIK", description="Company registry number (executive changes)."),
43
+ th.Property(
44
+ "base_url",
45
+ th.StringType,
46
+ default="https://api.foxapis.com",
47
+ title="Base URL",
48
+ description="The FoxAPIs address. Leave the default.",
49
+ ),
50
+ ).to_dict()
51
+
52
+ def discover_streams(self) -> list[streams.FoxAPIsStream]:
53
+ return [
54
+ streams.FormDRaisesStream(self),
55
+ streams.LayoffsStream(self),
56
+ streams.ExecutiveChangesStream(self),
57
+ ]
58
+
59
+
60
+ if __name__ == "__main__":
61
+ TapFoxAPIs.cli()
@@ -0,0 +1,154 @@
1
+ """Tests for tap-foxapis: no key, no network (HTTP answers are replaced)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+
7
+ import pytest
8
+ import responses
9
+
10
+ from tap_foxapis.tap import TapFoxAPIs
11
+
12
+ BASE = "https://api.foxapis.com"
13
+ KEY = "fxp_live_DEMO00000000000000000000000" # the public demo key printed in the FoxAPIs docs
14
+
15
+ FORM_D_ROW = {
16
+ "city": "SHERIDAN",
17
+ "filed": "2026-12-01",
18
+ "state": "WY",
19
+ "issuer": "Example Capital Partners Fund LLC",
20
+ "signed": "2026-12-01",
21
+ "sec_cik": "2167917",
22
+ "industry": "Other",
23
+ "sold_usd": 0,
24
+ "accession": "0002167917-26-000001",
25
+ "amendment": False,
26
+ "source_url": "https://example.com/filing",
27
+ "entity_type": "Limited Liability Company",
28
+ "year_formed": "2026",
29
+ "offering_usd": 2000000,
30
+ "offering_as_filed": "2000000",
31
+ "first_form_d_in_our_records": True,
32
+ }
33
+ LAYOFF_ROW = {
34
+ "city": "Goshen, IN",
35
+ "date": "2026-12-01",
36
+ "kind": "warn_notice",
37
+ "type": "layoff",
38
+ "state": "OR",
39
+ "company": "Example RV Company",
40
+ "employees": 353,
41
+ "source_url": "https://example.com/notice",
42
+ "date_precision": "day",
43
+ "warn_notice_id": 65538,
44
+ }
45
+ EXEC_RECORD = {
46
+ "form": "8-K",
47
+ "filed": "2026-10-23",
48
+ "changes": [{"role": "Chief Executive Officer", "person": "Jane Example", "change_type": "departed", "effective_date": "2026-10-23", "sentence": "..."}],
49
+ "company": "EXAMPLE CORP",
50
+ "sec_cik": "1065696",
51
+ "tickers": "EXM",
52
+ "accession": "0001065696-26-000047",
53
+ "filing_url": "https://example.com/index",
54
+ "document_url": "https://example.com/doc",
55
+ }
56
+
57
+
58
+ def run_tap(capsys, config=None, state=None):
59
+ cfg = {"api_key": KEY, "page_size": 2, **(config or {})}
60
+ tap = TapFoxAPIs(config=cfg, state=state, parse_env_config=False)
61
+ tap.sync_all()
62
+ out = capsys.readouterr().out
63
+ messages = [json.loads(line) for line in out.splitlines() if line.startswith("{")]
64
+ return tap, messages
65
+
66
+
67
+ def records(messages, stream):
68
+ return [m["record"] for m in messages if m["type"] == "RECORD" and m["stream"] == stream]
69
+
70
+
71
+ @pytest.fixture(autouse=True)
72
+ def only_mocked_calls():
73
+ with responses.RequestsMock(assert_all_requests_are_fired=False) as rsps:
74
+ rsps.add(responses.GET, f"{BASE}/v1/layoffs/list", json={"rows": [], "has_more": False, "next_cursor": None})
75
+ rsps.add(responses.POST, f"{BASE}/v1/executive_changes", json={"records": [], "page": 1, "page_size": 2})
76
+ yield rsps
77
+
78
+
79
+ def test_discovers_three_streams():
80
+ tap = TapFoxAPIs(config={"api_key": KEY}, parse_env_config=False)
81
+ assert sorted(s.name for s in tap.discover_streams()) == ["executive_changes", "form_d_raises", "layoffs"]
82
+
83
+
84
+ def test_form_d_follows_the_cursor_and_sends_the_bearer_key(capsys, only_mocked_calls):
85
+ only_mocked_calls.add(
86
+ responses.GET,
87
+ f"{BASE}/v1/raises/form-d/list",
88
+ json={"rows": [FORM_D_ROW], "has_more": True, "next_cursor": "abc"},
89
+ match=[responses.matchers.query_param_matcher({"limit": "2"})],
90
+ )
91
+ only_mocked_calls.add(
92
+ responses.GET,
93
+ f"{BASE}/v1/raises/form-d/list",
94
+ json={"rows": [{**FORM_D_ROW, "accession": "0002167917-26-000002"}], "has_more": False, "next_cursor": None},
95
+ match=[responses.matchers.query_param_matcher({"limit": "2", "cursor": "abc"})],
96
+ )
97
+ _, messages = run_tap(capsys)
98
+ rows = records(messages, "form_d_raises")
99
+ assert [r["accession"] for r in rows] == ["0002167917-26-000001", "0002167917-26-000002"]
100
+ first = [c for c in only_mocked_calls.calls if "form-d" in c.request.url][0]
101
+ assert first.request.headers["Authorization"] == f"Bearer {KEY}"
102
+ assert first.request.headers["User-Agent"] == "tap-foxapis/0.1.0"
103
+
104
+
105
+ def test_start_date_and_state_filter_reach_the_request(capsys, only_mocked_calls):
106
+ only_mocked_calls.add(
107
+ responses.GET,
108
+ f"{BASE}/v1/raises/form-d/list",
109
+ json={"rows": [], "has_more": False, "next_cursor": None},
110
+ )
111
+ run_tap(capsys, {"start_date": "2026-11-01", "state": "CA"})
112
+ url = [c.request.url for c in only_mocked_calls.calls if "form-d" in c.request.url][0]
113
+ assert "date_from=2026-11-01" in url and "state=CA" in url and "limit=2" in url
114
+
115
+
116
+ def test_layoffs_read_rows_and_save_the_newest_date(capsys, only_mocked_calls):
117
+ only_mocked_calls.replace(
118
+ responses.GET,
119
+ f"{BASE}/v1/layoffs/list",
120
+ json={"rows": [LAYOFF_ROW], "has_more": False, "next_cursor": None},
121
+ )
122
+ only_mocked_calls.add(responses.GET, f"{BASE}/v1/raises/form-d/list", json={"rows": [], "has_more": False})
123
+ tap, messages = run_tap(capsys)
124
+ assert records(messages, "layoffs")[0]["company"] == "Example RV Company"
125
+ state = [m["value"] for m in messages if m["type"] == "STATE"][-1]
126
+ assert state["bookmarks"]["layoffs"]["replication_key_value"] == "2026-12-01"
127
+
128
+
129
+ def test_executive_changes_page_until_a_short_page(capsys, only_mocked_calls):
130
+ second = {**EXEC_RECORD, "accession": "0001065696-26-000048"}
131
+ only_mocked_calls.replace(
132
+ responses.POST,
133
+ f"{BASE}/v1/executive_changes",
134
+ json={"records": [EXEC_RECORD, second], "page": 1, "page_size": 2},
135
+ match=[responses.matchers.json_params_matcher({"page": 1, "page_size": 2})],
136
+ )
137
+ only_mocked_calls.add(
138
+ responses.POST,
139
+ f"{BASE}/v1/executive_changes",
140
+ json={"records": [{**EXEC_RECORD, "accession": "0001065696-26-000049"}], "page": 2, "page_size": 2},
141
+ match=[responses.matchers.json_params_matcher({"page": 2, "page_size": 2})],
142
+ )
143
+ only_mocked_calls.add(responses.GET, f"{BASE}/v1/raises/form-d/list", json={"rows": [], "has_more": False})
144
+ _, messages = run_tap(capsys)
145
+ got = records(messages, "executive_changes")
146
+ assert [r["accession"] for r in got] == ["0001065696-26-000047", "0001065696-26-000048", "0001065696-26-000049"]
147
+ assert got[0]["changes"][0]["person"] == "Jane Example"
148
+
149
+
150
+ def test_an_http_error_stops_the_run_and_names_the_status(capsys, only_mocked_calls):
151
+ only_mocked_calls.add(responses.GET, f"{BASE}/v1/raises/form-d/list", status=401, json={"detail": "bad key"})
152
+ with pytest.raises(Exception) as err:
153
+ run_tap(capsys)
154
+ assert "401" in str(err.value)