def test_parse_renames_rename_too_long_columns(): assert _parse_renames( { "A": "BBBBBBBBBB", "BBBBBBBBBB": "BBBBBBBBBB" }, ["A", "BBBBBBBBBB"], settings=Settings(MAX_BYTES_PER_COLUMN_NAME=10), ) == ( { "A": "BBBBBBBB 2" }, [ RenderError( cjwmodule_i18n_message( "util.colnames.warnings.truncated", { "n_columns": 1, "first_colname": "BBBBBBBB 2", "n_bytes": 10 }, )), RenderError( cjwmodule_i18n_message( "util.colnames.warnings.numbered", { "n_columns": 1, "first_colname": "BBBBBBBB 2" }, )), ], )
def test_parse_renames_swap(self): self.assertEqual( _parse_renames( {"A": "B", "B": "C", "C": "A"}, ["A", "B", "C"], settings=Settings() ), ({"A": "B", "B": "C", "C": "A"}, []), )
def test_parse_renames_swap(): assert _parse_renames({ "A": "B", "B": "C", "C": "A" }, ["A", "B", "C"], settings=Settings()) == ({ "A": "B", "B": "C", "C": "A" }, [])
def test_parse_renames_ignore_missing_columns(): assert _parse_renames({ "A": "B", "C": "D" }, ["A", "X"], settings=Settings()) == ( { "A": "B" }, [], )
def test_parse_renames_avoid_duplicates(self): self.assertEqual( _parse_renames({"A": "B", "C": "B"}, ["A", "B", "C"], settings=Settings()), ( {"A": "B 2", "C": "B 3"}, [ cjwmodule_i18n_message( id="util.colnames.warnings.numbered", arguments={"n_columns": 2, "first_colname": "B 2"}, ), ], ), )
def test_parse_renames_avoid_duplicates_without_original(self): self.assertEqual( _parse_renames({"A": "C", "B": "C"}, ["A", "B"], settings=Settings()), ( {"A": "C", "B": "C 2"}, [ cjwmodule_i18n_message( id="util.colnames.warnings.numbered", arguments={"n_columns": 1, "first_colname": "C 2"}, ) ], ), )
def test_parse_renames_avoid_duplicates_without_original(): assert _parse_renames({ "A": "C", "B": "C" }, ["A", "B"], settings=Settings()) == ( { "A": "C", "B": "C 2" }, [ RenderError( cjwmodule_i18n_message( id="util.colnames.warnings.numbered", arguments={ "n_columns": 1, "first_colname": "C 2" }, )) ], )
def test_parse_renames_avoid_duplicates(): assert _parse_renames({ "A": "B", "C": "B" }, ["A", "B", "C"], settings=Settings()) == ( { "A": "B 2", "C": "B 3" }, [ RenderError( cjwmodule_i18n_message( id="util.colnames.warnings.numbered", arguments={ "n_columns": 2, "first_colname": "B 2" }, ), ) ], )
def test_parse_renames_rename_too_long_columns(self): self.assertEqual( _parse_renames( {"A": "BBBBBBBBBB", "BBBBBBBBBB": "BBBBBBBBBB"}, ["A", "BBBBBBBBBB"], settings=Settings(MAX_BYTES_PER_COLUMN_NAME=10), ), ( {"A": "BBBBBBBB 2"}, [ cjwmodule_i18n_message( "util.colnames.warnings.truncated", {"n_columns": 1, "first_colname": "BBBBBBBB 2", "n_bytes": 10}, ), cjwmodule_i18n_message( "util.colnames.warnings.numbered", {"n_columns": 1, "first_colname": "BBBBBBBB 2"}, ), ], ), )
def test_parse_renames_ignore_missing_columns(self): self.assertEqual( _parse_renames({"A": "B", "C": "D"}, ["A", "X"], settings=Settings()), ({"A": "B"}, []), )