示例#1
0
    def test_arg_pass_normal(self, pynonymize, create_parser, load_dotenv,
                             find_dotenv):
        """
        the parsed set of args should be passed to the pynonymize main function
        """
        parser_mock = Mock(parse_args=Mock(return_value=self.parsed_args))
        create_parser.return_value = parser_mock

        main([])

        create_parser.assert_called()
        parser_mock.parse_args.assert_called()
        pynonymize.assert_called_once_with(
            input_path="TEST_INPUT",
            strategyfile_path="TEST_STRATEGYFILE",
            output_path="TEST_OUTPUT",
            db_type="TEST_TYPE",
            db_host="TEST_HOST",
            db_port="TEST_PORT",
            db_name="TEST_NAME",
            db_user="******",
            db_password="******",
            fake_locale="TEST_LOCALE",
            start_at_step="TEST_START_AT_STEP",
            skip_steps=["TEST_SKIP_1", "TEST_SKIP_2"],
            stop_at_step="TEST_STOP_AT_STEP",
            seed_rows=None,
            mssql_backup_compression=False,
            mysql_dump_opts="--compatible=mysql4 --max_allowed_packet=1024M",
            dry_run=True,
            verbose=True)
示例#2
0
def test_sysexit_on_database_connection_error():
    """
    If pynonymize throws an argument validation error, main should exit with err 1
    """
    with pytest.raises(SystemExit) as e_info:
        main(["blah"])

    assert e_info.value.code == 1
示例#3
0
    def test_dotenv_called(self, pynonymize, create_parser, load_dotenv,
                           find_dotenv):
        """
        dotenv should be called
        """
        parser_mock = Mock(parse_args=Mock(return_value=self.parsed_args))
        create_parser.return_value = parser_mock

        main([])

        find_dotenv.assert_called()
        load_dotenv.assert_called()
示例#4
0
    def test_arg_pass_legacy_override(self, pynonymize, create_parser,
                                      load_dotenv, find_dotenv):
        """
        the parsed set of args should be passed to the pynonymize main function
        legacy args should override normal ones to account for old positional behaviour
        """
        self.parsed_args.legacy_input = "LEGACY_INPUT"
        self.parsed_args.legacy_strategyfile = "LEGACY_STRATEGYFILE"
        self.parsed_args.legacy_output = "LEGACY_OUTPUT"
        parser_mock = Mock(parse_args=Mock(return_value=self.parsed_args))
        create_parser.return_value = parser_mock

        main([])

        create_parser.assert_called()
        parser_mock.parse_args.assert_called()

        call_kwargs = pynonymize.call_args[1]

        assert call_kwargs["input_path"] == "LEGACY_INPUT"
        assert call_kwargs["strategyfile_path"] == "LEGACY_STRATEGYFILE"
        assert call_kwargs["output_path"] == "LEGACY_OUTPUT"