This project provides a Python script to review the Matter test case mapping JSON files against a reference list of test cases stored in a Google Sheet(TC_List).
-
Test Case List Validation
- Compares Column D in the Google Sheet with JSON test case IDs.
- Reports:
- Test cases present in the sheet but missing in JSON.
- Extra/unwanted test cases in JSON not listed in the sheet.
-
Certification Status Checks
- Detects empty
"CertificationStatus": ""entries. - Ensures consistency:
- If
"CertificationStatus": "Executable", the next line must be"cert": "true". - If
"CertificationStatus": "Provisional"or"Blocked", the next line must be"cert": "false".
- If
- Detects empty
-
Google Sheet vs JSON (Column F Validation)
- Column F (“Certification Status”) in the sheet is compared against JSON:
- Sheet = Executable → JSON must be
"CertificationStatus": "Executable"and"cert": "true". - Sheet = Provisional → JSON must be
"CertificationStatus": "Provisional"and"cert": "false". - Sheet = Blocked → JSON must be
"CertificationStatus": "Blocked"and"cert": "false".
- Sheet = Executable → JSON must be
- Any mismatch between the sheet and JSON is logged with line number + test case ID.
- Column F (“Certification Status”) in the sheet is compared against JSON:
-
PICS Validation
- Inside
"PICS": [ ... ]blocks, checks for forbidden characters:, & ( ) { } -
- Logs invalid entries with test case ID and line number.
- Inside
ℹ️ Note on point 2 & point 3 checks
The script intentionally performs two levels of CertificationStatus validation:
- Internal JSON consistency check – "Point 2" verifies that
"CertificationStatus"and the following"cert"value match correctly within the JSON file itself.- Google Sheet vs JSON check – "Point 3" validates that Column F (Certification Status) in the Google Sheet matches the JSON mapping (including the correct
"cert"value).Because of this, the same issue may appear in both sections of the log.
This is not a duplication error, but a safety measure to ensure both the JSON structure and the Sheet alignment are correct.
- Clone the repository:
git clone https://github.com/KishokG/Matter_CHIP.git
- Navigate to the directory:
cd Matter_CHIP/TC_MappingFile_Review/ - Create a virtual environment (folder .venv inside project):
python3 -m venv .venv
- Activate it:
source .venv/bin/activate - Install dependencies:
pip install -r requirements.txt
- All configurable values are stored in
config.yaml. - Before running the script, update the config file with the correct values for:
- Google Sheets credentials file (
credentials_file) - Google Sheet URL (
sheet_url) - Worksheet/tab name (
worksheet_name) - Local JSON file path (
json_file) - Output log file (
output_file)
- Google Sheets credentials file (
-
Go to Google Cloud Console.
-
Enable the Google Sheets API
- In Cloud Console, go to APIs & Services → Library
- Search for Google Sheets API
- Click Google Sheets API → Enable
-
Create a Service Account and download the credentials JSON file
- In Cloud Console, go to IAM & Admin → Service Accounts
- Click ➕ CREATE SERVICE ACCOUNT
- Service account name: e.g.
json-reviewer - Service account ID will be auto-filled
- Service account name: e.g.
- Click CREATE (you can skip granting roles here; roles are for broader GCP access — not required just to access a spreadsheet if you share the sheet with the service account)
- After creation, click the service account entry → Keys tab → Add Key → Create new key
- Choose JSON → Create → a file like
credentials-XXXXX.jsonwill download - Save and rename it to
credentials.json(or keep the filename and update the path inconfig.yaml)
-
Update your project
- Place the
credentials.jsonfile inside your project folder - Open
config.yamland update thecredentials_filepath if needed
- Place the
-
Share your Google Sheet with the Service Account
- Open your Google Sheet in the browser
- Click Share (top-right)
- Open the downloaded
credentials.jsonin an editor and copy the value ofclient_email"client_email": "json-reviewer@my-project.iam.gserviceaccount.com"
- Paste this email into the Sheet’s share dialog and grant at least Viewer access (or Editor)
- Activate your virtual environment (if not already active):
source .venv/bin/activate - Run the script
python3 JSON_comparision.py