# Path: gridded/tests/test_ugrid/utilities.py
# @pytest.fixture
# def two_triangles():
#     """
#     Returns a simple triangular grid: 4 nodes, two triangles, five edges.
# 
#     """
#     nodes = [(0.1, 0.1),
#              (2.1, 0.1),
#              (1.1, 2.1),
#              (3.1, 2.1)]
# 
#     faces = [(0, 1, 2),
#              (1, 3, 2), ]
# 
#     edges = [(0, 1),
#              (1, 3),
#              (3, 2),
#              (2, 0),
#              (1, 2)]
# 
#     return ugrid.UGrid(nodes=nodes, faces=faces, edges=edges)


import numpy as np
import pytest
from .utilities import two_triangles
    assert np.array_equal(grid.data['u'].data, [1.0, 2.0])


def test_add_face_data_wrong(two_triangles):
    """Too short an array."""

    grid = two_triangles

    # Create a UVar object for velocity:
    u_vel = UVar('u', location='face', data=[1.0])

    with pytest.raises(ValueError):
        grid.add_data(u_vel)


def test_add_edge_data(two_triangles):
    grid = two_triangles

    # Create a UVar object for velocity:
    bnds = UVar('bounds', location='edge', data=[0, 1, 0, 0, 1])
    bnds.attributes['standard_name'] = 'boundary type'

    grid.add_data(bnds)

    assert grid.data['bounds'].name == 'bounds'
    assert np.array_equal(grid.data['bounds'].data, [0, 1, 0, 0, 1])


def test_add_edge_data_wrong(two_triangles):
    """Too long an array."""

# Path: gridded/tests/test_ugrid/utilities.py
# @pytest.fixture
# def two_triangles():
#     """
#     Returns a simple triangular grid: 4 nodes, two triangles, five edges.
# 
#     """
#     nodes = [(0.1, 0.1),
#              (2.1, 0.1),
#              (1.1, 2.1),
#              (3.1, 2.1)]
# 
#     faces = [(0, 1, 2),
#              (1, 3, 2), ]
# 
#     edges = [(0, 1),
#              (1, 3),
#              (3, 2),
#              (2, 0),
#              (1, 2)]
# 
#     return ugrid.UGrid(nodes=nodes, faces=faces, edges=edges)


# Path: gridded/tests/test_ugrid/test_add_data.py
import numpy as np
import pytest
from .utilities import two_triangles

    assert np.array_equal(grid.data['u'].data, [1.0, 2.0])


def test_add_face_data_wrong(two_triangles):
    """Too short an array."""

    grid = two_triangles

    # Create a UVar object for velocity:
    u_vel = UVar('u', location='face', data=[1.0])

    with pytest.raises(ValueError):
        grid.add_data(u_vel)


def test_add_edge_data(two_triangles):
    grid = two_triangles

    # Create a UVar object for velocity:
    bnds = UVar('bounds', location='edge', data=[0, 1, 0, 0, 1])
    bnds.attributes['standard_name'] = 'boundary type'

    grid.add_data(bnds)

    assert grid.data['bounds'].name == 'bounds'
    assert np.array_equal(grid.data['bounds'].data, [0, 1, 0, 0, 1])


def test_add_edge_data_wrong(two_triangles):
    """Too long an array."""

    grid = two_triangles