-def test_convert_php_settings(sp_importer, testfile_dir, tmp_path):
- """
- Test that _convert_php_settings_if_needed() convert the given
- php file to a json file.
- """
- php_file = (testfile_dir / 'phrase_settings.php').resolve()
-
- temp_settings = (tmp_path / 'phrase_settings.php').resolve()
- copyfile(php_file, temp_settings)
- sp_importer._convert_php_settings_if_needed(temp_settings)
-
- assert (tmp_path / 'phrase_settings.json').is_file()
-
-def test_convert_settings_wrong_file(sp_importer):
- """
- Test that _convert_php_settings_if_needed() raise an exception
- if the given file is not a valid file.
- """
- with pytest.raises(UsageError, match='random_file is not a valid file.'):
- sp_importer._convert_php_settings_if_needed('random_file')
-
-def test_convert_settings_json_already_exist(sp_importer, testfile_dir):
- """
- Test that if we give to '_convert_php_settings_if_needed' a php file path
- and that a the corresponding json file already exists, it is returned.
- """
- php_file = (testfile_dir / 'phrase_settings.php').resolve()
- json_file = (testfile_dir / 'phrase_settings.json').resolve()
-
- returned = sp_importer._convert_php_settings_if_needed(php_file)
-
- assert returned == json_file
-
-def test_convert_settings_giving_json(sp_importer, testfile_dir):
- """
- Test that if we give to '_convert_php_settings_if_needed' a json file path
- the same path is directly returned
- """
- json_file = (testfile_dir / 'phrase_settings.json').resolve()
-
- returned = sp_importer._convert_php_settings_if_needed(json_file)
-
- assert returned == json_file