Compare commits
	
		
			No commits in common. "2bd094b10bc9ec3ac373a717e4e21563c4c346f8" and "34459c008f2f72ab6c738d917fbde2a11399fb84" have entirely different histories.
		
	
	
		
			2bd094b10b
			...
			34459c008f
		
	
		
					 6 changed files with 1 additions and 110 deletions
				
			
		
							
								
								
									
										19
									
								
								CHANGELOG.md
									
										
									
									
									
								
							
							
						
						
									
										19
									
								
								CHANGELOG.md
									
										
									
									
									
								
							|  | @ -5,25 +5,6 @@ All notable changes to WuttaMess will be documented in this file. | |||
| The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) | ||||
| and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). | ||||
| 
 | ||||
| ## v0.2.0 (2025-01-14) | ||||
| 
 | ||||
| ### Feat | ||||
| 
 | ||||
| - add `util.get_home_path()` function | ||||
| - add `is_symlink()` and `set_timezone()` util functions | ||||
| - add `apt.is_installed()` function | ||||
| - add basic `postgres` module for db setup | ||||
| - add `ssh` module with `cache_host_key()` function | ||||
| - add `util.mako_renderer()` function | ||||
| - add `util` module with `exists()` function | ||||
| - add basic postfix config helpers | ||||
| 
 | ||||
| ### Fix | ||||
| 
 | ||||
| - add `wutta.purge_email_settings()` for cloning prod DB to test | ||||
| - add `postgres.dump_db()` function | ||||
| - add `sync.make_selector()` convenience function | ||||
| 
 | ||||
| ## v0.1.0 (2024-09-10) | ||||
| 
 | ||||
| ### Feat | ||||
|  |  | |||
|  | @ -1,6 +0,0 @@ | |||
| 
 | ||||
| ``wuttamess.wutta`` | ||||
| =================== | ||||
| 
 | ||||
| .. automodule:: wuttamess.wutta | ||||
|    :members: | ||||
|  | @ -36,4 +36,3 @@ project. | |||
|    api/wuttamess.ssh | ||||
|    api/wuttamess.sync | ||||
|    api/wuttamess.util | ||||
|    api/wuttamess.wutta | ||||
|  |  | |||
|  | @ -6,7 +6,7 @@ build-backend = "hatchling.build" | |||
| 
 | ||||
| [project] | ||||
| name = "WuttaMess" | ||||
| version = "0.2.0" | ||||
| version = "0.1.0" | ||||
| description = "Fabric Automation Helpers" | ||||
| readme = "README.md" | ||||
| authors = [{name = "Lance Edgar", email = "lance@wuttaproject.org"}] | ||||
|  |  | |||
|  | @ -1,57 +0,0 @@ | |||
| # -*- coding: utf-8; -*- | ||||
| ################################################################################ | ||||
| # | ||||
| #  WuttaMess -- Fabric Automation Helpers | ||||
| #  Copyright © 2024-2025 Lance Edgar | ||||
| # | ||||
| #  This file is part of Wutta Framework. | ||||
| # | ||||
| #  Wutta Framework is free software: you can redistribute it and/or modify it | ||||
| #  under the terms of the GNU General Public License as published by the Free | ||||
| #  Software Foundation, either version 3 of the License, or (at your option) any | ||||
| #  later version. | ||||
| # | ||||
| #  Wutta Framework is distributed in the hope that it will be useful, but | ||||
| #  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||||
| #  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for | ||||
| #  more details. | ||||
| # | ||||
| #  You should have received a copy of the GNU General Public License along with | ||||
| #  Wutta Framework.  If not, see <http://www.gnu.org/licenses/>. | ||||
| # | ||||
| ################################################################################ | ||||
| """ | ||||
| Utilities for Wutta Framework | ||||
| """ | ||||
| 
 | ||||
| from wuttamess import postgres | ||||
| 
 | ||||
| 
 | ||||
| def purge_email_settings(c, dbname, appname='wutta'): | ||||
|     """ | ||||
|     Purge production email settings for a database. | ||||
| 
 | ||||
|     This can be used when cloning a production app DB to a test | ||||
|     server.  The general pattern is: | ||||
| 
 | ||||
|     * setup test app on test server | ||||
|     * config file should specify test email settings | ||||
|     * clone the production DB to test server | ||||
|     * call this function to purge email settings from test DB | ||||
| 
 | ||||
|     So the end result should be, the test server app can run and send | ||||
|     emails safely using only what is specified in config file(s), | ||||
|     since none of the production email settings remain in the test DB. | ||||
| 
 | ||||
|     :param dbname: Name of the database to be updated. | ||||
| 
 | ||||
|     :param appname: The ``appname`` used to determine setting names. | ||||
|     """ | ||||
|     postgres.sql(c, f"delete from setting where name like '{appname}.email.%.sender';", | ||||
|                  database=dbname) | ||||
|     postgres.sql(c, f"delete from setting where name like '{appname}.email.%.to';", | ||||
|                  database=dbname) | ||||
|     postgres.sql(c, f"delete from setting where name like '{appname}.email.%.cc';", | ||||
|                  database=dbname) | ||||
|     postgres.sql(c, f"delete from setting where name like '{appname}.email.%.bcc';", | ||||
|                  database=dbname) | ||||
|  | @ -1,26 +0,0 @@ | |||
| # -*- coding: utf-8; -*- | ||||
| 
 | ||||
| from unittest import TestCase | ||||
| from unittest.mock import MagicMock, patch, call | ||||
| 
 | ||||
| from wuttamess import wutta as mod | ||||
| 
 | ||||
| 
 | ||||
| class TestPurgeEmailSettings(TestCase): | ||||
| 
 | ||||
|     def test_basic(self): | ||||
|         c = MagicMock() | ||||
|         sql = MagicMock() | ||||
|         postgres = MagicMock(sql=sql) | ||||
|         with patch.object(mod, 'postgres', new=postgres): | ||||
|             mod.purge_email_settings(c, 'testy', appname='wuttatest') | ||||
|             sql.assert_has_calls([ | ||||
|                 call(c, "delete from setting where name like 'wuttatest.email.%.sender';", | ||||
|                      database='testy'), | ||||
|                 call(c, "delete from setting where name like 'wuttatest.email.%.to';", | ||||
|                      database='testy'), | ||||
|                 call(c, "delete from setting where name like 'wuttatest.email.%.cc';", | ||||
|                      database='testy'), | ||||
|                 call(c, "delete from setting where name like 'wuttatest.email.%.bcc';", | ||||
|                      database='testy'), | ||||
|             ]) | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue