Skip to content

Commit 82f1366

Browse files
- Test python changes.
1 parent 509cedb commit 82f1366

File tree

12 files changed

+44
-41
lines changed

12 files changed

+44
-41
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ on:
2929

3030
env:
3131
GOTESTCMD: "go test -timeout 1200s --tags \"sqlite_stackql\" -v ./..."
32-
TESTSCRIPT: "test/python/main.py"
32+
TESTSCRIPT: "test/deprecated/python/main.py"
3333
GOPRIVATE: github.com/stackql/*
3434
GH_ACCESS_TOKEN: ${{ secrets.ACTIONS_PRIVATE_PACKAGE_SECRET }}
3535
PLANCACHEENABLED: "false"
@@ -119,7 +119,7 @@ jobs:
119119
120120
- name: Generate rewritten registry for simulations
121121
run: |
122-
python3 test\python\registry-rewrite.py
122+
python3 test\python\registry_rewrite.py
123123
124124
- name: Get dependencies
125125
run: |
@@ -196,7 +196,7 @@ jobs:
196196

197197
- name: Test Script
198198
if: success()
199-
run: python.exe test/python/main.py
199+
run: python.exe test/deprecated/python/main.py
200200

201201
- name: Upload Artifact
202202
# uses: actions/upload-artifact@v3
@@ -256,7 +256,7 @@ jobs:
256256
257257
- name: Generate rewritten registry for simulations
258258
run: |
259-
python3 test/python/registry-rewrite.py
259+
python3 test/python/registry_rewrite.py
260260
261261
- name: Get dependencies
262262
run: |
@@ -523,7 +523,7 @@ jobs:
523523
- name: Generate rewritten registry for simulations
524524
if: ${{ matrix.registry != 'test/registry' }}
525525
run: |
526-
python3 test/python/registry-rewrite.py
526+
python3 test/python/registry_rewrite.py
527527
528528
- name: Create certificates for robot tests
529529
run: |
@@ -653,7 +653,7 @@ jobs:
653653
654654
- name: Generate rewritten registry for simulations
655655
run: |
656-
python3 test/python/registry-rewrite.py
656+
python3 test/python/registry_rewrite.py
657657
658658
- name: Get dependencies
659659
run: |
@@ -937,7 +937,7 @@ jobs:
937937

938938
- shell: wsl-bash {0}
939939
name: Generate rewritten registry for simulations
940-
run: python3 test/python/registry-rewrite.py
940+
run: python3 test/python/registry_rewrite.py
941941

942942
- shell: wsl-bash {0}
943943
name: Create certificates for robot tests
@@ -1037,7 +1037,7 @@ jobs:
10371037
10381038
- name: Generate rewritten registry for simulations
10391039
run: |
1040-
python3 test/python/registry-rewrite.py
1040+
python3 test/python/registry_rewrite.py
10411041
10421042
- name: Get dependencies
10431043
run: |
@@ -1557,7 +1557,7 @@ jobs:
15571557
- name: Generate rewritten registry for simulations
15581558
if: env.BUILD_IMAGE_REQUIRED == 'true'
15591559
run: |
1560-
python3 test/python/registry-rewrite.py --replacement-host=host.docker.internal
1560+
python3 test/python/registry_rewrite.py --replacement-host=host.docker.internal
15611561
15621562
15631563
- name: Create certificates for robot tests

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ ADD cicd ${TEST_ROOT_DIR}/cicd
101101
COPY --from=certificates /opt/test/stackql ${TEST_ROOT_DIR}/
102102

103103
RUN pip3 install PyYaml \
104-
&& python3 ${TEST_ROOT_DIR}/test/python/registry-rewrite.py
104+
&& python3 ${TEST_ROOT_DIR}/test/python/registry_rewrite.py
105105

106106
FROM utility AS integration
107107

docs/developer_guide.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,13 @@ Local testing of the application:
186186

187187
1. Run `go test --tags "sqlite_stackql" ./...` tests.
188188
2. Build the executable [as per the root README](/README.md#build)
189-
3. Perform registry rewrites as needed for mocking `python3 test/python/registry-rewrite.py`.
189+
3. Perform registry rewrites as needed for mocking `python3 test/python/registry_rewrite.py`.
190190
3. Run robot tests:
191191
- Functional tests, mocked as needed `robot -d test/robot/functional test/robot/functional`.
192192
- Integration tests `robot -d test/robot/integration test/robot/integration`. For these, you will need to set various envirnonment variables as per the github actions.
193193
4. Run the deprecated manual python tests:
194194
- Prepare with `cp test/db/db.sqlite test/db/tmp/python-tests-tmp-db.sqlite`.
195-
- Run with `python3 test/python/main.py`.
195+
- Run with `python3 test/deprecated/python/main.py`.
196196

197197
[This article](https://medium.com/cbi-engineering/mocking-techniques-for-go-805c10f1676b) gives a nice overview of mocking in golang.
198198

@@ -209,7 +209,7 @@ Then: `go test --tags "sqlite_stackql" -cover ../...`.
209209

210210
Automated functional and integration testing are done largely through robot framework. Please see [the robot test readme](/test/robot/README.md).
211211

212-
There is some legacy, deprecated [manual python testing](/test/python/main.py) which will be migrated to robot and decommissioned.
212+
There is some legacy, deprecated [manual python testing](/test/deprecated/python/main.py) which will be migrated to robot and decommissioned.
213213

214214
### Linting
215215

test/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
Offline invocations of `stackql` are assessed against expected responses, through:
77

8-
1. the functionality of [/test/python/main.py](/test/python/main.py).
8+
1. the functionality of [/test/deprecated/python/main.py](/test/deprecated/python/main.py).
99
2. [robot tests in /test/functional](/test/functional)
1010

1111
(1) is deprecated and will be entirely migrated to (2).
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class TestStatus(Enum):
2323

2424

2525
CURDIR :str = os.path.dirname(os.path.realpath(__file__))
26-
TEST_ROOT_DIR :str = os.path.abspath(os.path.join(CURDIR, '..'))
27-
REPOSITORY_ROOT_DIR :str = os.path.abspath(os.path.join(CURDIR, '../..'))
26+
TEST_ROOT_DIR :str = os.path.abspath(os.path.join(CURDIR, '..', '..'))
27+
REPOSITORY_ROOT_DIR :str = os.path.abspath(os.path.join(CURDIR, '..', '..', '..'))
2828
PROVIDER_REGISTRY_ROOT_DIR :str = os.path.abspath(os.path.join(TEST_ROOT_DIR, 'registry')).replace(os.sep, '/')
2929
TEST_GENERATOR_DEFINITIONS_ROOT :str = os.path.join(TEST_ROOT_DIR, 'test-generators')
3030
TEST_GENERATOR_ALWAYS_ROOT :str = os.path.join(TEST_GENERATOR_DEFINITIONS_ROOT, 'always')

test/python/__init__.py

Whitespace-only changes.

test/python/markdown_testing/__init__.py

Whitespace-only changes.

test/python/markdown_testing/markdown_testing.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"""
2222

2323

24-
def parse_args() -> argparse.Namespace:
24+
def _parse_args() -> argparse.Namespace:
2525
"""
2626
Parse the arguments.
2727
"""
@@ -471,7 +471,7 @@ def _collate_results(results: List[WalkthroughResult]) -> bool:
471471
print(tabulate([[result.name, result.rc, result.passes_stdout_check, result.passes_stderr_check] for result in results], headers=['Test Name', 'Return Code', 'Passes Stdout Checks', 'Passes Stderr Checks']))
472472
return failed == 0
473473

474-
def run_tests(root_dir: str) -> List[WalkthroughResult]:
474+
def _run_tests(root_dir: str) -> List[WalkthroughResult]:
475475
"""
476476
Run all tests.
477477
A decent entry point for a test harness.
@@ -486,17 +486,17 @@ def run_tests(root_dir: str) -> List[WalkthroughResult]:
486486

487487

488488
def _process_tests(root_dir: str) -> List[WalkthroughResult]:
489-
results: List[WalkthroughResult] = run_tests(root_dir)
489+
results: List[WalkthroughResult] = _run_tests(root_dir)
490490
if _collate_results(results):
491491
print('All tests passed.')
492492
sys.exit(0)
493493
print('Some tests failed.')
494494
sys.exit(1)
495495

496-
def _main() -> None:
497-
args :argparse.Namespace = parse_args()
496+
def md_testing() -> None:
497+
args :argparse.Namespace = _parse_args()
498498
_process_tests(args.test_root)
499499

500500

501501
if __name__ == '__main__':
502-
_main()
502+
md_testing()

test/python/oauth2_token.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import argparse
44

55

6-
def create_token(header: dict, claims: dict) -> str:
6+
def _create_token(header: dict, claims: dict) -> str:
77
"""
88
Create a token from the claims.
99
@@ -15,7 +15,7 @@ def create_token(header: dict, claims: dict) -> str:
1515
return f'{header_b64}.{claims_b64}.{base64.urlsafe_b64encode(signature.encode("utf-8")).decode("utf-8")}'
1616

1717

18-
def parse_args() -> argparse.Namespace:
18+
def _parse_args() -> argparse.Namespace:
1919
"""
2020
Parse the arguments.
2121
"""
@@ -26,26 +26,26 @@ def parse_args() -> argparse.Namespace:
2626
return parser.parse_args()
2727

2828

29-
def generate_token(ns: argparse.Namespace) -> str:
29+
def _generate_token(ns: argparse.Namespace) -> str:
3030
"""
3131
Create a token.
3232
"""
3333
header = json.loads(ns.header)
3434
claims = json.loads(ns.claims)
35-
return create_token(header, claims)
35+
return _create_token(header, claims)
3636

3737

38-
def main() -> None:
38+
def get_token() -> None:
3939
"""
4040
Main entry point.
4141
"""
42-
args = parse_args()
42+
args = _parse_args()
4343
if args.create_token:
44-
print(generate_token(args))
44+
print(_generate_token(args))
4545
return
4646
exit(1)
4747

4848

4949
if __name__ == '__main__':
50-
main()
50+
get_token()
5151

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010
import yaml
1111

1212
CURDIR :str = os.path.dirname(os.path.realpath(__file__))
13-
TEST_ROOT_DIR :str = os.path.abspath(os.path.join(CURDIR, '..'))
14-
REPOSITORY_ROOT_DIR :str = os.path.abspath(os.path.join(CURDIR, '../..'))
13+
_TEST_ROOT_DIR :str = os.path.abspath(os.path.join(CURDIR, '..'))
1514

16-
DEFAULT_SRC_DIR = os.path.join(TEST_ROOT_DIR, 'registry', 'src')
17-
DEFAULT_DST_DIR = os.path.join(TEST_ROOT_DIR, 'registry-mocked', 'src')
15+
_DEFAULT_SRC_DIR = os.path.join(_TEST_ROOT_DIR, 'registry', 'src')
16+
_DEFAULT_DST_DIR = os.path.join(_TEST_ROOT_DIR, 'registry-mocked', 'src')
1817
DEFAULT_PORT = 1070
1918
GOOGLE_DEFAULT_PORT = 1080
2019
GOOGLEADMIN_DEFAULT_PORT = 1098
@@ -34,13 +33,13 @@
3433
parser.add_argument(
3534
'--srcdir',
3635
type=str,
37-
default=DEFAULT_SRC_DIR,
36+
default=_DEFAULT_SRC_DIR,
3837
help='directory containing executable'
3938
)
4039
parser.add_argument(
4140
'--destdir',
4241
type=str,
43-
default=DEFAULT_DST_DIR,
42+
default=_DEFAULT_DST_DIR,
4443
help='directory containing config and cache'
4544
)
4645
parser.add_argument(
@@ -235,7 +234,7 @@ def get_port(self, provider_name :str) -> int:
235234
return self._provider_lookup.get(provider_name, self._provider_lookup.get("__default__")).get("port", DEFAULT_PORT)
236235

237236

238-
if __name__ == '__main__':
237+
def rewrite_registry():
239238
args = parser.parse_args()
240239
ppm = ProviderCfgMapping(args)
241240
provider_dirs = [f for f in os.scandir(args.srcdir) if f.is_dir()]
@@ -249,3 +248,7 @@ def get_port(self, provider_name :str) -> int:
249248
)
250249
print(f'{prov_args.srcdir}, {prov_args.destdir}, {prov_args.port}')
251250
rewrite_provider(prov_args)
251+
252+
if __name__ == '__main__':
253+
rewrite_registry
254+
()

0 commit comments

Comments
 (0)