icp-scoring-sheet 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,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 OneGTMLab
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,75 @@
1
+ Metadata-Version: 2.4
2
+ Name: icp-scoring-sheet
3
+ Version: 0.1.0
4
+ Summary: A spreadsheet template with live formulas that scores accounts against your ideal customer profile, plus a Python scorer that gives the same numbers
5
+ Author: Jainendra Ojha
6
+ License: MIT
7
+ Project-URL: Homepage, https://www.onegtmlab.dev/free-resources
8
+ Project-URL: Source, https://github.com/jaizendra-netizen/icp-scoring-sheet
9
+ Requires-Python: >=3.8
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Provides-Extra: xlsx
13
+ Requires-Dist: openpyxl>=3.1; extra == "xlsx"
14
+ Dynamic: license-file
15
+
16
+ # icp-scoring-sheet
17
+
18
+ A spreadsheet template that scores accounts against your **ideal customer profile**, with every score a live formula you can read and change,
19
+ plus a small Python scorer that produces the same numbers from a CSV. Open `icp-scoring-template.xlsx` in Excel, Google Sheets or LibreOffice (scores calculate when the file is opened).
20
+
21
+ | Sheet | What is in it |
22
+ |---|---|
23
+ | `Criteria` | five editable weights, the Tier A and Tier B thresholds, and the employee-size bands (employees from, points) |
24
+ | `Accounts` | type company, domain, employees, industry fit (0-5), tech match (0-5), region match (Yes/No) and trigger event (Yes/No); size points, region points, trigger points, **Score (0-100)** and **Tier** fill in by formula for 200 rows |
25
+
26
+ The score is the weighted average of the five criteria, each worth up to 5 points:
27
+
28
+ ```
29
+ score = round( 100 * (industry*w1 + tech*w2 + size_points*w3 + region*w4 + trigger*w5) / (5 * (w1+...+w5)) )
30
+ tier = A if score >= Tier A threshold, B if score >= Tier B threshold, otherwise C
31
+ ```
32
+
33
+ The weights, thresholds and size bands in the file are **placeholders** (weights 3, 2, 2, 1, 2; tiers at 75 and 50): replace them with your own
34
+ before you rely on a tier. The three example companies are fictional.
35
+
36
+ ## Score a CSV without a spreadsheet
37
+
38
+ ```bash
39
+ python -m icp_scoring_sheet score examples/accounts.csv --out scored.csv
40
+ # Example Co A 92 A
41
+ # Example Co B 44 C
42
+ # Example Co C 28 C
43
+ ```
44
+
45
+ Columns: `company, domain, employees, industry_fit, tech_match, region_match, trigger_event`. Python 3.8+, standard library only for scoring.
46
+
47
+ ## Rebuild or customise the template
48
+
49
+ ```bash
50
+ pip install openpyxl
51
+ python -m icp_scoring_sheet build my-template.xlsx # with the three example rows
52
+ python -m icp_scoring_sheet build my-template.xlsx --empty
53
+ ```
54
+
55
+ Edit `CRITERIA`, `SIZE_BANDS`, `TIER_A` and `TIER_B` in `icp_scoring_sheet/__init__.py` to change the defaults.
56
+
57
+ ## Tests
58
+
59
+ ```bash
60
+ python -m unittest discover -s tests -v
61
+ ```
62
+
63
+ The spreadsheet test recalculates the workbook's formulas with the `formulas` package (`pip install openpyxl formulas`) and checks that every example row equals the Python scorer; without those packages that one test is skipped.
64
+
65
+ ## Background
66
+
67
+ [Ideal customer profile](https://www.onegtmlab.dev/glossary/ideal-customer-profile),
68
+ [lead scoring](https://www.onegtmlab.dev/glossary/lead-scoring),
69
+ [firmographics](https://www.onegtmlab.dev/glossary/firmographics) and
70
+ [lead qualification](https://www.onegtmlab.dev/glossary/lead-qualification) are defined in the OneGTMLab glossary.
71
+ More free GTM material, such as the signal-based outbound playbook, is on the [free resources page](https://www.onegtmlab.dev/free-resources).
72
+
73
+ ## Licence
74
+
75
+ MIT. Made by [OneGTMLab](https://www.onegtmlab.dev), GTM engineering for B2B teams.
@@ -0,0 +1,60 @@
1
+ # icp-scoring-sheet
2
+
3
+ A spreadsheet template that scores accounts against your **ideal customer profile**, with every score a live formula you can read and change,
4
+ plus a small Python scorer that produces the same numbers from a CSV. Open `icp-scoring-template.xlsx` in Excel, Google Sheets or LibreOffice (scores calculate when the file is opened).
5
+
6
+ | Sheet | What is in it |
7
+ |---|---|
8
+ | `Criteria` | five editable weights, the Tier A and Tier B thresholds, and the employee-size bands (employees from, points) |
9
+ | `Accounts` | type company, domain, employees, industry fit (0-5), tech match (0-5), region match (Yes/No) and trigger event (Yes/No); size points, region points, trigger points, **Score (0-100)** and **Tier** fill in by formula for 200 rows |
10
+
11
+ The score is the weighted average of the five criteria, each worth up to 5 points:
12
+
13
+ ```
14
+ score = round( 100 * (industry*w1 + tech*w2 + size_points*w3 + region*w4 + trigger*w5) / (5 * (w1+...+w5)) )
15
+ tier = A if score >= Tier A threshold, B if score >= Tier B threshold, otherwise C
16
+ ```
17
+
18
+ The weights, thresholds and size bands in the file are **placeholders** (weights 3, 2, 2, 1, 2; tiers at 75 and 50): replace them with your own
19
+ before you rely on a tier. The three example companies are fictional.
20
+
21
+ ## Score a CSV without a spreadsheet
22
+
23
+ ```bash
24
+ python -m icp_scoring_sheet score examples/accounts.csv --out scored.csv
25
+ # Example Co A 92 A
26
+ # Example Co B 44 C
27
+ # Example Co C 28 C
28
+ ```
29
+
30
+ Columns: `company, domain, employees, industry_fit, tech_match, region_match, trigger_event`. Python 3.8+, standard library only for scoring.
31
+
32
+ ## Rebuild or customise the template
33
+
34
+ ```bash
35
+ pip install openpyxl
36
+ python -m icp_scoring_sheet build my-template.xlsx # with the three example rows
37
+ python -m icp_scoring_sheet build my-template.xlsx --empty
38
+ ```
39
+
40
+ Edit `CRITERIA`, `SIZE_BANDS`, `TIER_A` and `TIER_B` in `icp_scoring_sheet/__init__.py` to change the defaults.
41
+
42
+ ## Tests
43
+
44
+ ```bash
45
+ python -m unittest discover -s tests -v
46
+ ```
47
+
48
+ The spreadsheet test recalculates the workbook's formulas with the `formulas` package (`pip install openpyxl formulas`) and checks that every example row equals the Python scorer; without those packages that one test is skipped.
49
+
50
+ ## Background
51
+
52
+ [Ideal customer profile](https://www.onegtmlab.dev/glossary/ideal-customer-profile),
53
+ [lead scoring](https://www.onegtmlab.dev/glossary/lead-scoring),
54
+ [firmographics](https://www.onegtmlab.dev/glossary/firmographics) and
55
+ [lead qualification](https://www.onegtmlab.dev/glossary/lead-qualification) are defined in the OneGTMLab glossary.
56
+ More free GTM material, such as the signal-based outbound playbook, is on the [free resources page](https://www.onegtmlab.dev/free-resources).
57
+
58
+ ## Licence
59
+
60
+ MIT. Made by [OneGTMLab](https://www.onegtmlab.dev), GTM engineering for B2B teams.
@@ -0,0 +1,57 @@
1
+ """ICP account scoring: one set of weights, used by both the spreadsheet and the Python scorer."""
2
+ import csv
3
+
4
+ __version__ = "0.1.0"
5
+
6
+ # (name, default weight): each criterion is scored 0-5 per account.
7
+ CRITERIA = [
8
+ ("Industry fit", 3),
9
+ ("Tech stack match", 2),
10
+ ("Company size", 2),
11
+ ("Region match", 1),
12
+ ("Trigger event", 2),
13
+ ]
14
+ # Lower bound of the employee band -> points (0-5). Edit in the sheet or here.
15
+ SIZE_BANDS = [(0, 0), (11, 2), (51, 4), (201, 5), (1001, 3)]
16
+ TIER_A, TIER_B = 75, 50 # score thresholds out of 100
17
+
18
+ INPUT_FIELDS = ["company", "domain", "employees", "industry_fit", "tech_match", "region_match", "trigger_event"]
19
+
20
+
21
+ def size_points(employees, bands=SIZE_BANDS):
22
+ pts = 0
23
+ for lower, p in bands: # approximate-match lookup, same as the sheet's LOOKUP()
24
+ if employees >= lower:
25
+ pts = p
26
+ return pts
27
+
28
+
29
+ def score_row(row, weights=None, bands=SIZE_BANDS, tier_a=TIER_A, tier_b=TIER_B):
30
+ """row: dict with employees (number), industry_fit and tech_match (0-5), region_match and trigger_event (yes/no)."""
31
+ w = weights or [c[1] for c in CRITERIA]
32
+ yes = lambda v: 5 if str(v).strip().lower() in ("yes", "y", "true", "1") else 0
33
+ pts = [
34
+ float(row["industry_fit"]), float(row["tech_match"]), size_points(float(row["employees"]), bands),
35
+ yes(row["region_match"]), yes(row["trigger_event"]),
36
+ ]
37
+ total = round(100 * sum(p * x for p, x in zip(pts, w)) / (5 * sum(w)))
38
+ tier = "A" if total >= tier_a else "B" if total >= tier_b else "C"
39
+ return total, tier
40
+
41
+
42
+ def read_accounts(path):
43
+ with open(path, newline="", encoding="utf-8-sig") as f:
44
+ return list(csv.DictReader(f))
45
+
46
+
47
+ def score_csv(path, out=None):
48
+ rows = read_accounts(path)
49
+ res = []
50
+ for r in rows:
51
+ s, t = score_row(r)
52
+ res.append(dict(r, score=s, tier=t))
53
+ if out:
54
+ with open(out, "w", newline="", encoding="utf-8") as f:
55
+ w = csv.DictWriter(f, fieldnames=list(rows[0].keys()) + ["score", "tier"])
56
+ w.writeheader(); w.writerows(res)
57
+ return res
@@ -0,0 +1,26 @@
1
+ import argparse, sys
2
+ from . import INPUT_FIELDS, score_csv
3
+
4
+
5
+ def main(argv=None):
6
+ p = argparse.ArgumentParser(prog="icp-scoring-sheet", description="Build the ICP scoring spreadsheet, or score a CSV with the same maths.")
7
+ sub = p.add_subparsers(dest="cmd", required=True)
8
+ b = sub.add_parser("build", help="write the .xlsx template (needs: pip install openpyxl)")
9
+ b.add_argument("path", nargs="?", default="icp-scoring-template.xlsx")
10
+ b.add_argument("--empty", action="store_true", help="leave out the three fictional example rows")
11
+ s = sub.add_parser("score", help="score a CSV with columns: " + ", ".join(INPUT_FIELDS))
12
+ s.add_argument("csv"); s.add_argument("--out")
13
+ a = p.parse_args(argv)
14
+ if a.cmd == "build":
15
+ from .build import build
16
+ build(a.path, sample=not a.empty)
17
+ print("wrote " + a.path)
18
+ else:
19
+ rows = score_csv(a.csv, a.out)
20
+ for r in rows:
21
+ print("%-20s %3d %s" % (r.get("company", ""), r["score"], r["tier"]))
22
+ return 0
23
+
24
+
25
+ if __name__ == "__main__":
26
+ sys.exit(main())
@@ -0,0 +1,59 @@
1
+ """Write the .xlsx template (needs openpyxl). Every score cell is a live formula."""
2
+ from openpyxl import Workbook
3
+ from openpyxl.styles import Font, PatternFill
4
+ from openpyxl.worksheet.datavalidation import DataValidation
5
+ from . import CRITERIA, SIZE_BANDS, TIER_A, TIER_B
6
+
7
+ SAMPLE = [ # fictional example rows, to show the formulas working
8
+ ("Example Co A", "example-a.test", 120, 5, 4, "Yes", "Yes"),
9
+ ("Example Co B", "example-b.test", 30, 3, 2, "Yes", "No"),
10
+ ("Example Co C", "example-c.test", 2500, 2, 1, "No", "No"),
11
+ ]
12
+ ROWS = 200 # formulas pre-filled this far down
13
+
14
+
15
+ def build(path, sample=True):
16
+ wb = Workbook()
17
+ cr = wb.active; cr.title = "Criteria"
18
+ bold = Font(bold=True); fill = PatternFill("solid", fgColor="FFF2CC")
19
+ cr.append(["Criterion", "Weight (edit)", "How it is scored (0-5)"])
20
+ how = ["Type 0-5 in the Accounts sheet", "Type 0-5 in the Accounts sheet",
21
+ "Looked up from the Size bands table", "Yes = 5, No = 0", "Yes = 5, No = 0"]
22
+ for (n, w), h in zip(CRITERIA, how):
23
+ cr.append([n, w, h])
24
+ cr["A8"], cr["B8"] = "Tier A at or above", TIER_A
25
+ cr["A9"], cr["B9"] = "Tier B at or above", TIER_B
26
+ cr["A11"] = "Size bands (employees from -> points)"; cr["A11"].font = bold
27
+ cr["A12"], cr["B12"] = "Employees from", "Points"
28
+ for i, (lo, p) in enumerate(SIZE_BANDS):
29
+ cr.cell(row=13 + i, column=1, value=lo); cr.cell(row=13 + i, column=2, value=p)
30
+ for c in ("A1", "B1", "C1", "A12", "B12"): cr[c].font = bold
31
+ for r in range(2, 7): cr.cell(row=r, column=2).fill = fill
32
+ cr["B8"].fill = fill; cr["B9"].fill = fill
33
+ cr.column_dimensions["A"].width = 38; cr.column_dimensions["C"].width = 40
34
+
35
+ ac = wb.create_sheet("Accounts")
36
+ head = ["Company", "Domain", "Employees", "Industry fit (0-5)", "Tech match (0-5)", "Region match", "Trigger event",
37
+ "Size points", "Region points", "Trigger points", "Score (0-100)", "Tier"]
38
+ ac.append(head)
39
+ for c in ac[1]: c.font = bold
40
+ n_bands = len(SIZE_BANDS)
41
+ lo, pts = "Criteria!$A$13:$A$%d" % (12 + n_bands), "Criteria!$B$13:$B$%d" % (12 + n_bands)
42
+ for r in range(2, ROWS + 2):
43
+ if sample and r - 2 < len(SAMPLE):
44
+ for c, v in enumerate(SAMPLE[r - 2], start=1): ac.cell(row=r, column=c, value=v)
45
+ ac.cell(row=r, column=8, value='=IF(C%d="","",LOOKUP(C%d,%s,%s))' % (r, r, lo, pts))
46
+ ac.cell(row=r, column=9, value='=IF(F%d="","",IF(F%d="Yes",5,0))' % (r, r))
47
+ ac.cell(row=r, column=10, value='=IF(G%d="","",IF(G%d="Yes",5,0))' % (r, r))
48
+ ac.cell(row=r, column=11, value=(
49
+ '=IF(OR(C{r}="",D{r}="",E{r}="",F{r}="",G{r}=""),"",ROUND(100*(D{r}*Criteria!$B$2+E{r}*Criteria!$B$3+H{r}*Criteria!$B$4'
50
+ '+I{r}*Criteria!$B$5+J{r}*Criteria!$B$6)/(5*SUM(Criteria!$B$2:$B$6)),0))').format(r=r))
51
+ ac.cell(row=r, column=12, value='=IF(K{r}="","",IF(K{r}>=Criteria!$B$8,"A",IF(K{r}>=Criteria!$B$9,"B","C")))'.format(r=r))
52
+ yn = DataValidation(type="list", formula1='"Yes,No"', allow_blank=True)
53
+ nums = DataValidation(type="whole", operator="between", formula1="0", formula2="5", allow_blank=True)
54
+ ac.add_data_validation(yn); ac.add_data_validation(nums)
55
+ yn.add("F2:G%d" % (ROWS + 1)); nums.add("D2:E%d" % (ROWS + 1))
56
+ for col, wdt in zip("ABCDEFGHIJKL", (22, 20, 12, 18, 16, 14, 14, 12, 14, 14, 14, 8)):
57
+ ac.column_dimensions[col].width = wdt
58
+ ac.freeze_panes = "A2"
59
+ wb.save(path)
@@ -0,0 +1,75 @@
1
+ Metadata-Version: 2.4
2
+ Name: icp-scoring-sheet
3
+ Version: 0.1.0
4
+ Summary: A spreadsheet template with live formulas that scores accounts against your ideal customer profile, plus a Python scorer that gives the same numbers
5
+ Author: Jainendra Ojha
6
+ License: MIT
7
+ Project-URL: Homepage, https://www.onegtmlab.dev/free-resources
8
+ Project-URL: Source, https://github.com/jaizendra-netizen/icp-scoring-sheet
9
+ Requires-Python: >=3.8
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Provides-Extra: xlsx
13
+ Requires-Dist: openpyxl>=3.1; extra == "xlsx"
14
+ Dynamic: license-file
15
+
16
+ # icp-scoring-sheet
17
+
18
+ A spreadsheet template that scores accounts against your **ideal customer profile**, with every score a live formula you can read and change,
19
+ plus a small Python scorer that produces the same numbers from a CSV. Open `icp-scoring-template.xlsx` in Excel, Google Sheets or LibreOffice (scores calculate when the file is opened).
20
+
21
+ | Sheet | What is in it |
22
+ |---|---|
23
+ | `Criteria` | five editable weights, the Tier A and Tier B thresholds, and the employee-size bands (employees from, points) |
24
+ | `Accounts` | type company, domain, employees, industry fit (0-5), tech match (0-5), region match (Yes/No) and trigger event (Yes/No); size points, region points, trigger points, **Score (0-100)** and **Tier** fill in by formula for 200 rows |
25
+
26
+ The score is the weighted average of the five criteria, each worth up to 5 points:
27
+
28
+ ```
29
+ score = round( 100 * (industry*w1 + tech*w2 + size_points*w3 + region*w4 + trigger*w5) / (5 * (w1+...+w5)) )
30
+ tier = A if score >= Tier A threshold, B if score >= Tier B threshold, otherwise C
31
+ ```
32
+
33
+ The weights, thresholds and size bands in the file are **placeholders** (weights 3, 2, 2, 1, 2; tiers at 75 and 50): replace them with your own
34
+ before you rely on a tier. The three example companies are fictional.
35
+
36
+ ## Score a CSV without a spreadsheet
37
+
38
+ ```bash
39
+ python -m icp_scoring_sheet score examples/accounts.csv --out scored.csv
40
+ # Example Co A 92 A
41
+ # Example Co B 44 C
42
+ # Example Co C 28 C
43
+ ```
44
+
45
+ Columns: `company, domain, employees, industry_fit, tech_match, region_match, trigger_event`. Python 3.8+, standard library only for scoring.
46
+
47
+ ## Rebuild or customise the template
48
+
49
+ ```bash
50
+ pip install openpyxl
51
+ python -m icp_scoring_sheet build my-template.xlsx # with the three example rows
52
+ python -m icp_scoring_sheet build my-template.xlsx --empty
53
+ ```
54
+
55
+ Edit `CRITERIA`, `SIZE_BANDS`, `TIER_A` and `TIER_B` in `icp_scoring_sheet/__init__.py` to change the defaults.
56
+
57
+ ## Tests
58
+
59
+ ```bash
60
+ python -m unittest discover -s tests -v
61
+ ```
62
+
63
+ The spreadsheet test recalculates the workbook's formulas with the `formulas` package (`pip install openpyxl formulas`) and checks that every example row equals the Python scorer; without those packages that one test is skipped.
64
+
65
+ ## Background
66
+
67
+ [Ideal customer profile](https://www.onegtmlab.dev/glossary/ideal-customer-profile),
68
+ [lead scoring](https://www.onegtmlab.dev/glossary/lead-scoring),
69
+ [firmographics](https://www.onegtmlab.dev/glossary/firmographics) and
70
+ [lead qualification](https://www.onegtmlab.dev/glossary/lead-qualification) are defined in the OneGTMLab glossary.
71
+ More free GTM material, such as the signal-based outbound playbook, is on the [free resources page](https://www.onegtmlab.dev/free-resources).
72
+
73
+ ## Licence
74
+
75
+ MIT. Made by [OneGTMLab](https://www.onegtmlab.dev), GTM engineering for B2B teams.
@@ -0,0 +1,13 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ icp_scoring_sheet/__init__.py
5
+ icp_scoring_sheet/__main__.py
6
+ icp_scoring_sheet/build.py
7
+ icp_scoring_sheet.egg-info/PKG-INFO
8
+ icp_scoring_sheet.egg-info/SOURCES.txt
9
+ icp_scoring_sheet.egg-info/dependency_links.txt
10
+ icp_scoring_sheet.egg-info/entry_points.txt
11
+ icp_scoring_sheet.egg-info/requires.txt
12
+ icp_scoring_sheet.egg-info/top_level.txt
13
+ tests/test_score.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ icp-scoring-sheet = icp_scoring_sheet.__main__:main
@@ -0,0 +1,3 @@
1
+
2
+ [xlsx]
3
+ openpyxl>=3.1
@@ -0,0 +1 @@
1
+ icp_scoring_sheet
@@ -0,0 +1,19 @@
1
+ [project]
2
+ name = "icp-scoring-sheet"
3
+ version = "0.1.0"
4
+ description = "A spreadsheet template with live formulas that scores accounts against your ideal customer profile, plus a Python scorer that gives the same numbers"
5
+ license = { text = "MIT" }
6
+ readme = "README.md"
7
+ authors = [{ name = "Jainendra Ojha" }]
8
+ requires-python = ">=3.8"
9
+ dependencies = []
10
+
11
+ [project.optional-dependencies]
12
+ xlsx = ["openpyxl>=3.1"]
13
+
14
+ [project.scripts]
15
+ icp-scoring-sheet = "icp_scoring_sheet.__main__:main"
16
+
17
+ [project.urls]
18
+ Homepage = "https://www.onegtmlab.dev/free-resources"
19
+ Source = "https://github.com/jaizendra-netizen/icp-scoring-sheet"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,47 @@
1
+ import os, sys, tempfile, unittest
2
+ sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
3
+ from icp_scoring_sheet import score_row, size_points, score_csv
4
+ HERE = os.path.dirname(__file__)
5
+
6
+
7
+ class T(unittest.TestCase):
8
+ def test_size_points(self):
9
+ self.assertEqual([size_points(n) for n in (1, 10, 11, 50, 51, 200, 201, 1000, 1001)], [0, 0, 2, 2, 4, 4, 5, 5, 3])
10
+
11
+ def test_known_scores(self):
12
+ a = dict(employees=120, industry_fit=5, tech_match=4, region_match="Yes", trigger_event="Yes")
13
+ # (5*3 + 4*2 + 4*2 + 5*1 + 5*2) / (5*10) = 46/50 -> 92
14
+ self.assertEqual(score_row(a), (92, "A"))
15
+ b = dict(employees=30, industry_fit=3, tech_match=2, region_match="Yes", trigger_event="No")
16
+ # (3*3 + 2*2 + 2*2 + 5*1 + 0) / 50 = 22/50 -> 44
17
+ self.assertEqual(score_row(b), (44, "C"))
18
+
19
+ def test_csv(self):
20
+ out = os.path.join(tempfile.mkdtemp(), "o.csv")
21
+ res = score_csv(os.path.join(HERE, "..", "examples", "accounts.csv"), out)
22
+ self.assertEqual([(r["score"], r["tier"]) for r in res][:2], [(92, "A"), (44, "C")])
23
+ self.assertTrue(open(out).read().startswith("company,domain"))
24
+
25
+
26
+ class SheetMatchesPython(unittest.TestCase):
27
+ """Recalculate the .xlsx formulas with the `formulas` package and compare to score_row(). Skipped when not installed."""
28
+ def test_sheet(self):
29
+ try:
30
+ import formulas, openpyxl # noqa
31
+ except ImportError:
32
+ self.skipTest("pip install openpyxl formulas to run the spreadsheet check")
33
+ from icp_scoring_sheet.build import build, SAMPLE
34
+ d = tempfile.mkdtemp(); p = os.path.join(d, "t.xlsx"); build(p)
35
+ xl = formulas.ExcelModel().loads(p).finish(); sol = xl.calculate()
36
+ def cell(ref):
37
+ v = sol["'[t.xlsx]ACCOUNTS'!" + ref].value[0, 0]
38
+ return v
39
+ for i, (_, _, emp, ind, tech, reg, trg) in enumerate(SAMPLE):
40
+ want = score_row(dict(employees=emp, industry_fit=ind, tech_match=tech, region_match=reg, trigger_event=trg))
41
+ r = i + 2
42
+ self.assertEqual((int(cell("K%d" % r)), cell("L%d" % r)), want, "row %d" % r)
43
+ self.assertEqual(cell("K50"), "") # empty rows stay blank
44
+
45
+
46
+ if __name__ == "__main__":
47
+ unittest.main()