NOTICE: All information contained herein is, and remains
the property of TechnoCore.
The intellectual and technical concepts contained
herein are proprietary to TechnoCore and dissemination of this information or reproduction of this material
is strictly forbidden unless prior written permission is obtained
from TechnoCore.
The ObjTest module provides a suite of tools for generating and validating South African ID numbers, including special functions for creating and verifying test-specific IDs. This functionality is exposed through a command-line interface.
This class inherits from ObjData and is designed to assist in software testing and development where valid-looking but identifiable test data is required. It can generate standard SA IDs, validate them using the Luhn algorithm, and produce bulk test IDs that are marked with a non-valid date prefix (999999).
The module is executed as a script and provides the following commands:
generateGenerates a single, valid South African ID number.
Usage:
python3 factory.core/ObjTest.py generate [OPTIONS]
Options:
--dob, -d TEXT: Date of birth in YYYY-MM-DD format. If omitted, a random date is used.--gender, -g TEXT: Gender (male or female). If omitted, a random gender is chosen.--citizen / --permanent-resident: Sets citizenship status. Defaults to citizen.Example:
# Generate a random ID
python3 factory.core/ObjTest.py generate
# Generate an ID for a male born on 1985-11-22
python3 factory.core/ObjTest.py generate --dob 1985-11-22 --gender male
validateValidates a given 13-digit South African ID number to ensure it has a correct checksum.
Usage:
python3 factory.core/ObjTest.py validate <ID_NUMBER>
Example:
python3 factory.core/ObjTest.py validate 9001015000084
generate-test-setGenerates a CSV file containing a specified number of test ID numbers. These IDs are identifiable as they all start with 999999.
Usage:
python3 factory.core/ObjTest.py generate-test-set [OPTIONS] [OUTPUT_FILE]
Arguments:
OUTPUT_FILE: The path for the output CSV file. Defaults to test_ids.csv.Options:
--count, -c INTEGER: The number of test IDs to generate. Defaults to 100.Example:
# Generate 500 test IDs in a file named 'test_data.csv'
python3 factory.core/ObjTest.py generate-test-set --count 500 test_data.csv
validate-test-idChecks if a given ID number is a valid test ID. A valid test ID must start with 999999 and have a correct checksum.
Usage:
python3 factory.core/ObjTest.py validate-test-id <ID_NUMBER>
Example:
python3 factory.core/ObjTest.py validate-test-id 9999995123081