Exemple #1
0
    def test_read_legend(self, tmp_path, monkeypatch):
        legend_url = 'NB_LAB;LCCOwnLabel;R;G;B\r\n0;No data;0;0;0' \
                     '\r\n10;Cropland, rainfed;255;255;100\r\n11;Herbaceous cover' \
                     ';255;255;100\r\n12;Tree or shrub cover;255;255;0\r\n20;Cropland,' \
                     ' irrigated or post-flooding;170;240;240'

        output_csv = pd.read_csv(StringIO(legend_url), delimiter=';')

        def mockread(url, delimiter):
            return output_csv

        monkeypatch.setattr(pd, 'read_csv', mockread)

        exporter = ESACCIExporter(tmp_path)
        legend = exporter.read_legend()
        assert (legend.columns == [
            'code', 'label', 'label_text', 'R', 'G', 'B'
        ]).all()
Exemple #2
0
    def test_read_legend(self, tmp_path, monkeypatch):
        legend_url = (
            "NB_LAB;LCCOwnLabel;R;G;B\r\n0;No data;0;0;0"
            "\r\n10;Cropland, rainfed;255;255;100\r\n11;Herbaceous cover"
            ";255;255;100\r\n12;Tree or shrub cover;255;255;0\r\n20;Cropland,"
            " irrigated or post-flooding;170;240;240")

        output_csv = pd.read_csv(StringIO(legend_url), delimiter=";")

        def mockread(url, delimiter):
            return output_csv

        monkeypatch.setattr(pd, "read_csv", mockread)

        exporter = ESACCIExporter(tmp_path)
        legend = exporter.read_legend()
        assert (legend.columns == [
            "code", "label", "label_text", "R", "G", "B"
        ]).all()