Skip to content

Commit

Permalink
fixes failing pytest
Browse files Browse the repository at this point in the history
Signed-off-by: Nishant Bansal <[email protected]>
  • Loading branch information
NishantBansal2003 committed Nov 9, 2024
1 parent a6b1815 commit c7bf7d9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions raster/r.colors.out/tests/r3_colors_out_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Tests of r3.colors.out"""

import pytest
import grass.script as gs


Expand All @@ -22,20 +23,23 @@ def validate_plain_text_output(data):
), f"test failed: expected {expected} but got {data.keys()}"


@pytest.mark.needs_solo_run
def test_r3_colors_out_plain_output(raster3_color_dataset):
"""Test r3.colors.out command for plain output format."""
session = raster3_color_dataset
data = gs.parse_command("r3.colors.out", map="b", format="plain", env=session.env)
validate_plain_text_output(data)


@pytest.mark.needs_solo_run
def test_r3_colors_out_without_format_option(raster3_color_dataset):
"""Test r3.colors.out command without any format option."""
session = raster3_color_dataset
data = gs.parse_command("r3.colors.out", map="b", env=session.env)
validate_plain_text_output(data)


@pytest.mark.needs_solo_run
def test_r3_colors_out_with_p_flag(raster3_color_dataset):
"""Test r3.colors.out command with percentage values."""
session = raster3_color_dataset
Expand Down Expand Up @@ -65,6 +69,7 @@ def validate_common_json_structure(data):
), "The length of the output JSON does not match the expected value of 8."


@pytest.mark.needs_solo_run
def test_r3_colors_out_json_with_default_option(raster3_color_dataset):
"""Test r3.colors.out command for JSON output format for default color option."""
session = raster3_color_dataset
Expand All @@ -83,6 +88,7 @@ def test_r3_colors_out_json_with_default_option(raster3_color_dataset):
assert expected == data, f"test failed: expected {expected} but got {data}"


@pytest.mark.needs_solo_run
def test_r3_colors_out_json_with_triplet_option(raster3_color_dataset):
"""Test r3.colors.out command for JSON output format for triplet color option."""
session = raster3_color_dataset
Expand All @@ -103,6 +109,7 @@ def test_r3_colors_out_json_with_triplet_option(raster3_color_dataset):
assert expected == data, f"test failed: expected {expected} but got {data}"


@pytest.mark.needs_solo_run
def test_r3_colors_out_json_with_rgb_option(raster3_color_dataset):
"""Test r3.colors.out command for JSON output format for rgb color option."""
session = raster3_color_dataset
Expand All @@ -127,6 +134,7 @@ def test_r3_colors_out_json_with_rgb_option(raster3_color_dataset):
assert expected == data, f"test failed: expected {expected} but got {data}"


@pytest.mark.needs_solo_run
def test_r3_colors_out_json_with_hex_option(raster3_color_dataset):
"""Test r3.colors.out command for JSON output format for hex color option."""
session = raster3_color_dataset
Expand All @@ -151,6 +159,7 @@ def test_r3_colors_out_json_with_hex_option(raster3_color_dataset):
assert expected == data, f"test failed: expected {expected} but got {data}"


@pytest.mark.needs_solo_run
def test_r3_colors_out_json_with_hsv_option(raster3_color_dataset):
"""Test r3.colors.out command for JSON output format for hsv color option."""
session = raster3_color_dataset
Expand Down
9 changes: 9 additions & 0 deletions raster/r.colors.out/tests/r_colors_out_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Tests of r.colors.out"""

import pytest
import grass.script as gs


Expand All @@ -22,20 +23,23 @@ def validate_plain_text_output(data):
), f"test failed: expected {expected} but got {data.keys()}"


@pytest.mark.needs_solo_run
def test_r_colors_out_plain_output(raster_color_dataset):
"""Test r.colors.out command for plain output format."""
session = raster_color_dataset
data = gs.parse_command("r.colors.out", map="a", format="plain", env=session.env)
validate_plain_text_output(data)


@pytest.mark.needs_solo_run
def test_r_colors_out_without_format_option(raster_color_dataset):
"""Test r.colors.out command without any format option."""
session = raster_color_dataset
data = gs.parse_command("r.colors.out", map="a", env=session.env)
validate_plain_text_output(data)


@pytest.mark.needs_solo_run
def test_r_colors_out_with_p_flag(raster_color_dataset):
"""Test r.colors.out command with percentage values."""
session = raster_color_dataset
Expand Down Expand Up @@ -65,6 +69,7 @@ def validate_common_json_structure(data):
), "The length of the output JSON does not match the expected value of 8."


@pytest.mark.needs_solo_run
def test_r_colors_out_json_with_default_option(raster_color_dataset):
"""Test r.colors.out command for JSON output format for default color option."""
session = raster_color_dataset
Expand All @@ -83,6 +88,7 @@ def test_r_colors_out_json_with_default_option(raster_color_dataset):
assert expected == data, f"test failed: expected {expected} but got {data}"


@pytest.mark.needs_solo_run
def test_r_colors_out_json_with_triplet_option(raster_color_dataset):
"""Test r.colors.out command for JSON output format for triplet color option."""
session = raster_color_dataset
Expand All @@ -103,6 +109,7 @@ def test_r_colors_out_json_with_triplet_option(raster_color_dataset):
assert expected == data, f"test failed: expected {expected} but got {data}"


@pytest.mark.needs_solo_run
def test_r_colors_out_json_with_rgb_option(raster_color_dataset):
"""Test r.colors.out command for JSON output format for rgb color option."""
session = raster_color_dataset
Expand All @@ -127,6 +134,7 @@ def test_r_colors_out_json_with_rgb_option(raster_color_dataset):
assert expected == data, f"test failed: expected {expected} but got {data}"


@pytest.mark.needs_solo_run
def test_r_colors_out_json_with_hex_option(raster_color_dataset):
"""Test r.colors.out command for JSON output format for hex color option."""
session = raster_color_dataset
Expand All @@ -151,6 +159,7 @@ def test_r_colors_out_json_with_hex_option(raster_color_dataset):
assert expected == data, f"test failed: expected {expected} but got {data}"


@pytest.mark.needs_solo_run
def test_r_colors_out_json_with_hsv_option(raster_color_dataset):
"""Test r.colors.out command for JSON output format for hsv color option."""
session = raster_color_dataset
Expand Down

0 comments on commit c7bf7d9

Please sign in to comment.