Exemplo n.º 1
0
    def test_raise_error_if_some_columns_are_missing(self):
        data = {
            "Exp": [1],
            "Site": ["s"],
            "Hole": [None],
            "Core": [None],
            "Type": [None],
            "Section": [None],
        }
        df = pd.DataFrame(data)

        message = "File does not have the expected columns."
        with pytest.raises(ValueError, match=message):
            create_sample_name(df)
Exemplo n.º 2
0
    def test_removes_dash_from_end_of_string_nan_2(self):
        data = {
            "Exp": [1],
            "Site": [np.nan],
            "Hole": [np.nan],
            "Core": [np.nan],
            "Type": ["t"],
            "Section": [np.nan],
            "A/W": [np.nan],
        }
        df = pd.DataFrame(data)
        data["Sample"] = ["1-t"]
        expected = pd.DataFrame(data)

        create_sample_name(df)

        assert_frame_equal(df, expected)
Exemplo n.º 3
0
    def test_creates_Sample_string_if_column_are_nan_6(self):
        data = {
            "Exp": [1],
            "Site": [np.nan],
            "Hole": [np.nan],
            "Core": [np.nan],
            "Type": [np.nan],
            "Section": [np.nan],
            "A/W": [np.nan],
        }
        df = pd.DataFrame(data, dtype=str)
        data["Sample"] = ["1"]
        expected = pd.DataFrame(data, dtype=str)

        create_sample_name(df)

        assert_frame_equal(df, expected)
Exemplo n.º 4
0
    def test_creates_Sample_string_if_column_are_null_5(self):
        data = {
            "Exp": [1],
            "Site": [None],
            "Hole": [None],
            "Core": [None],
            "Type": [None],
            "Section": [None],
            "A/W": ["a"],
        }
        df = pd.DataFrame(data)
        data["Sample"] = ["1-a"]
        expected = pd.DataFrame(data)

        create_sample_name(df)

        assert_frame_equal(df, expected)
Exemplo n.º 5
0
    def test_creates_Sample_string_if_column_are_nan(self):
        data = {
            "Exp": [1],
            "Site": [np.nan],
            "Hole": ["h"],
            "Core": [2],
            "Type": ["t"],
            "Section": [3],
            "A/W": ["a"],
        }
        df = pd.DataFrame(data)
        data["Sample"] = ["1-h-2t-3-a"]
        expected = pd.DataFrame(data)

        create_sample_name(df)

        assert_frame_equal(df, expected)
Exemplo n.º 6
0
    def test_returns_Sample_if_all_columns_are_present(self):
        data = {
            "Exp": [1],
            "Site": ["s"],
            "Hole": ["h"],
            "Core": [2],
            "Type": ["t"],
            "Section": [3],
            "A/W": ["a"],
        }
        df = pd.DataFrame(data)
        data["Sample"] = ["1-sh-2t-3-a"]
        expected = pd.DataFrame(data)

        create_sample_name(df)

        assert_frame_equal(df, expected)
Exemplo n.º 7
0
    def test_adds_space_extra_sample_data_if_any_aw(self):
        data = {
            "Exp": [1],
            "Site": ["s"],
            "Hole": ["h"],
            "Core": [2],
            "Type": ["t"],
            "Section": [3],
            "A/W": ["a"],
            "Extra Sample ID Data": ["e"],
        }
        df = pd.DataFrame(data)
        data["Sample"] = ["1-sh-2t-3-a e"]
        expected = pd.DataFrame(data)

        create_sample_name(df)

        assert_frame_equal(df, expected)
Exemplo n.º 8
0
    def test_otherwise_raise_error(self):
        df = pd.DataFrame({"foo": [1]})

        message = "File does not have the expected columns."
        with pytest.raises(ValueError, match=message):
            create_sample_name(df)