Skip to content

Commit

Permalink
tests(fw): add test for fill's property file
Browse files Browse the repository at this point in the history
  • Loading branch information
danceratopz committed Jun 13, 2024
1 parent 51e4e68 commit 4dc1c87
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/pytest_plugins/test_filler/tests/test_test_filler.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
"""
Test the forks plugin.
"""

import configparser
import json
import os
import textwrap
from datetime import datetime
from pathlib import Path

import pytest
Expand Down Expand Up @@ -95,6 +98,25 @@ def test_shanghai_two(state_test, x):
[2, 2, 2, 2, 2, 2, 2, 2, 2, 6, 6, 6],
id="default-args",
),
pytest.param(
["--build-name", "test_build"],
[
Path("fixtures/blockchain_tests/paris/module_paris/paris_one.json"),
Path("fixtures/blockchain_tests_hive/paris/module_paris/paris_one.json"),
Path("fixtures/state_tests/paris/module_paris/paris_one.json"),
Path("fixtures/blockchain_tests/paris/module_paris/paris_two.json"),
Path("fixtures/blockchain_tests_hive/paris/module_paris/paris_two.json"),
Path("fixtures/state_tests/paris/module_paris/paris_two.json"),
Path("fixtures/blockchain_tests/shanghai/module_shanghai/shanghai_one.json"),
Path("fixtures/blockchain_tests_hive/shanghai/module_shanghai/shanghai_one.json"),
Path("fixtures/state_tests/shanghai/module_shanghai/shanghai_one.json"),
Path("fixtures/blockchain_tests/shanghai/module_shanghai/shanghai_two.json"),
Path("fixtures/blockchain_tests_hive/shanghai/module_shanghai/shanghai_two.json"),
Path("fixtures/state_tests/shanghai/module_shanghai/shanghai_two.json"),
],
[2, 2, 2, 2, 2, 2, 2, 2, 2, 6, 6, 6],
id="build-name-in-properties-file",
),
pytest.param(
["--flat-output"],
[
Expand Down Expand Up @@ -495,8 +517,10 @@ def test_fixture_output_based_on_command_line_args(

all_files = get_all_files_in_directory(output_dir)

properties_file = None
for file in all_files:
if file.name == "fixtures.properties":
properties_file = file
all_files.remove(file)
break

Expand All @@ -507,3 +531,16 @@ def test_fixture_output_based_on_command_line_args(
assert set(all_files) == set(
expected_fixture_files
), f"Unexpected files in directory: {set(all_files) - set(expected_fixture_files)}"

assert properties_file is not None, "No properties file was written"
config = configparser.ConfigParser()
config.read(properties_file)

properties = {key: value for key, value in config.items("FIXTURES")}
assert "timestamp" in properties
timestamp = datetime.fromisoformat(properties["timestamp"])
assert timestamp.year == datetime.now().year
if "--build-name" in args:
assert "build" in properties
build_name = args[args.index("--build-name") + 1]
assert properties["build"] == build_name

0 comments on commit 4dc1c87

Please sign in to comment.