text: import pytest
  from pybrary.databrary.group import Group
  
  
  @pytest.fixture
  def expected_group_dict():
      return {
          "key": "1251",
          "name": "12 month olds",
          "category": "group"
      }
  
  
  @pytest.fixture
  def databrary_group_dict():
      return {
          "id": 1251,
          "category": 5,
          "measures": {
              "26": "12 month olds"
          }
      }
  
  
  @pytest.fixture
  def databrary_group_dict_fail():
      return {
          "category": 5,
          "measures": {
              "26": "12 month olds"
          }
      }
  
  
  def test_to_dict(expected_group_dict):
      assert Group(
          record_key=1251,
          record_id=1251,
          name="12 month olds"
      ).to_dict() == expected_group_dict
  
  
  def test_from_databrary(databrary_group_dict):
      group = Group.from_databrary(databrary_group_dict)
      assert group is not None
  
  
  def test_from_databrary_fail(databrary_group_dict_fail):
      with pytest.raises(Exception) as e:
          Group.from_databrary(databrary_group_dict_fail)
  