def test_maseya_blend(): """Assert that passing "Default" will perform the desired Maseya blend.""" # Get base palette data. data = _read_internal_json("base") # Get the color data we'll be expecting from the final rom product. expected = _read_internal_json("maseya") # Declare this array now so `next_color` can use it as nonlocal. random_values = [] # Run test for all palette subsets. for args in powerset(SUBSETS): next_color_index = 0 random_values = _get_stored_random_colors(expected, args) def next_color(): """Generate colors from our JSON test data.""" nonlocal next_color_index nonlocal random_values try: result = random_values[next_color_index] except: assert False next_color_index += 1 return result options = _generate_options(args) rom = _initialize_test_rom(data, args) randomize(rom, "Default", next_color, options) _assert_changes_to_rom(rom, expected, args)
def test_blackout(): """Assert that passing "Blackout" will make an all-black palette.""" # Get base palette data. data = _read_internal_json("base") # Run test for all palette subsets. for args in powerset(SUBSETS): options = _generate_options(args) rom = _initialize_test_rom(data, args) randomize(rom, "Blackout", None, options) _assert_blackout_to_rom(rom, data, args)
def test_no_randomize(): """Assert that passing "None" will not change the rom data.""" # Get base palette data. data = _read_internal_json("base") # Run test for all palette subsets. for args in powerset(SUBSETS): options = _generate_options(args) rom = _initialize_test_rom(data, args) randomize(rom, "None", None, options) _assert_changes_to_rom(rom, data, args)
def test_grayscale(): """Assert that passing "Grayscale" will gray out the palette.""" # Get base palette data. data = _read_internal_json("base") # Run test for all palette subsets. expected = _read_internal_json("grayscale") for args in powerset(SUBSETS): options = _generate_options(args) rom = _initialize_test_rom(data, args) randomize(rom, "Grayscale", None, options) _assert_changes_to_rom(rom, expected, args)
def test_no_randomize(): """Assert that passing "None" will not change the rom data.""" # Get base palette data. data = _read_internal_json("base") # Run test for all palette subsets. for args in powerset(SUBSETS): options = _generate_options(args) rom = _initialize_test_rom(_iterate_offsets(data, args)) offset_collections = build_offset_collections(options) randomize(rom, "None", offset_collections) _assert_values_in_rom(rom, _iterate_offsets(data, args))
def test_cached_randomize_with_blackout(): """Assert blackout mode with cached offset array.""" # Cache JSON data into memory. offsets_array_cache = cache_offset_collections() # Get base palette data. data = _read_internal_json("base") # Run test for all palette subsets. for args in powerset(SUBSETS): options = _generate_options(args) rom = _initialize_test_rom(_iterate_offsets(data, args)) offset_collections = iterate_cached_offset_collections( offsets_array_cache, options) randomize(rom, "Blackout", offset_collections) _assert_blackout_to_rom(rom, data, args)
def _assert_blend(name: str): """Assert that passing a blend option does the intended blend.""" # Get base palette data. data = _read_internal_json("base") # Get the color data we'll be expecting from the final rom product. expected = _read_internal_json(name) # Run test for all palette subsets. for args in powerset(SUBSETS): # Get deterministic color generator for testing. random_values = _get_stored_random_colors(expected, args) options = _generate_options(args) rom = _initialize_test_rom(_iterate_offsets(data, args)) offset_collections = build_offset_collections(options) randomize(rom, name, offset_collections, random_values) _assert_values_in_rom(rom, _iterate_offsets(expected, args))
def test_cached_randomize_with_maseya_blend(): """Assert maseya blend mode with cached offset array.""" # Cache JSON data into memory. cached_offset_collections = cache_offset_collections() # Get base palette data. data = _read_internal_json("base") # Get the color data we'll be expecting from the final rom product. expected = _read_internal_json("maseya") # Run test for all palette subsets. for args in powerset(SUBSETS): # Get deterministic color generator for testing. random_values = _get_stored_random_colors(expected, args) options = _generate_options(args) rom = _initialize_test_rom(_iterate_offsets(data, args)) offset_collections = iterate_cached_offset_collections( cached_offset_collections, options) randomize(rom, "Maseya", offset_collections, random_values) _assert_values_in_rom(rom, _iterate_offsets(expected, args))