Example #1
0
def test_nonplural_lead_units_works(da_lead, lead_units):
    """Test that non-plural lead units work on lead units check."""
    da_lead["lead"].attrs["units"] = lead_units[:-1]
    with pytest.warns(UserWarning) as record:
        has_valid_lead_units(da_lead)
    expected = f'The letter "s" was appended to the lead units; now {lead_units}.'
    assert record[0].message.args[0] == expected
Example #2
0
def test_valid_lead_units_invalid_units(da_lead):
    """Test that valid lead units check breaks if invalid units provided."""
    da_lead["lead"].attrs["units"] = "dummy"
    with pytest.raises(AttributeError):
        has_valid_lead_units(da_lead)
Example #3
0
def test_valid_lead_units(da_lead, lead_units):
    """Test that lead units check passes with appropriate lead units."""
    da_lead["lead"].attrs["units"] = lead_units
    assert has_valid_lead_units(da_lead)
Example #4
0
def test_valid_lead_units_no_units(da_lead):
    """Test that valid lead units check breaks if there are no units."""
    with pytest.raises(AttributeError):
        has_valid_lead_units(da_lead)
Example #5
0
def test_valid_lead_units_invalid_units(da_lead):
    """Test that valid lead units check breaks if invalid units provided."""
    da_lead['lead'].attrs['units'] = 'dummy'
    with pytest.raises(AttributeError):
        has_valid_lead_units(da_lead)