Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
hkage committed Jan 2, 2020
2 parents 2b5970b + e78b2e2 commit cb84302
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 48 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/python_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test

on: [push]

jobs:
build:

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [2.7, 3.5, 3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements/test.txt
- name: Lint with flake8
run: |
make flake8
- name: Test with pytest
run: |
pytest
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Development

## 0.2.3 (2020-01-02)

* Fixed the wrong cStringIO import for Python 3
* Removed Travis-CI file in favor of the Github actions

## 0.2.2 (2020-01-02)

* Hide the progressbar completely if verbose is set to ``False``
Expand Down
8 changes: 5 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
PostgreSQL Anonymizer
=====================

.. image:: https://travis-ci.org/rheinwerk-verlag/postgresql-anonymizer.svg?branch=master
:target: https://travis-ci.org/rheinwerk-verlag/postgresql-anonymizer

.. image:: https://img.shields.io/badge/license-MIT-green.svg
:target: https://github.com/rheinwerk-verlag/postgresql-anonymizer/blob/master/LICENSE.rst

.. image:: https://badge.fury.io/py/pganonymize.svg
:target: https://badge.fury.io/py/pganonymize


This commandline tool makes PostgreSQL database anonymization easy. It uses a YAML definition file
to define which tables and fields should be anonymized and provides various methods of anonymization
(e.g. masking, faking or truncating complete tables).

Installation
------------

Expand Down Expand Up @@ -319,6 +320,7 @@ the ``BROWSER`` make variable, e.g.::

TODOs
-----
* Better schema validation / error handling
* Add more tests
* Add option to create a database dump
* Add a commandline argument to list all available providers
Expand Down
2 changes: 1 addition & 1 deletion pganonymizer/utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import csv
import logging
import re
from cStringIO import StringIO

import psycopg2
import psycopg2.extras
from progress.bar import IncrementalBar
from psycopg2.errors import BadCopyFileFormat, InvalidTextRepresentation
from six import StringIO

from pganonymizer.constants import COPY_DB_DELIMITER, DATABASE_ARGS, DEFAULT_PRIMARY_KEY
from pganonymizer.exceptions import BadDataFormat
Expand Down
2 changes: 1 addition & 1 deletion pganonymizer/version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-

__version__ = '0.2.2'
__version__ = '0.2.3'
2 changes: 1 addition & 1 deletion requirements/base.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
faker==3.0.0
progress==1.5
psycopg2==2.8.4
psycopg2-binary==2.8.4
pyyaml==5.2
six==1.13.0
5 changes: 2 additions & 3 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile --output-file base.txt base.in
# pip-compile --output-file=base.txt base.in
#
#--index-url https://devpi.rheinwerk-verlag.de/rheinwerk/prod/
#--trusted-host devpi.rheinwerk-verlag.de

faker==3.0.0
ipaddress==1.0.23 # via faker
progress==1.5
psycopg2==2.8.4
psycopg2-binary==2.8.4
python-dateutil==2.8.1 # via faker
pyyaml==5.2
six==1.13.0
Expand Down
25 changes: 9 additions & 16 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile --output-file dev.txt dev.in
# pip-compile --output-file=dev.txt dev.in
#
#--index-url https://devpi.rheinwerk-verlag.de/rheinwerk/prod/
#--trusted-host devpi.rheinwerk-verlag.de
Expand All @@ -13,26 +13,20 @@ astroid==1.6.6 # via pylint
atomicwrites==1.3.0 # via pytest
attrs==19.1.0
babel==2.8.0 # via sphinx
backports.functools-lru-cache==1.6.1 # via astroid, pylint
backports.shutil-get-terminal-size==1.0.0 # via ipython
certifi==2019.11.28 # via requests
chardet==3.0.4 # via requests
click==7.0 # via pip-tools
commonmark==0.5.4 # via recommonmark
configparser==4.0.2 # via flake8, pydocstyle, pylint
coverage==4.5.1
decorator==4.4.1 # via ipython, traitlets
docutils==0.15.2 # via recommonmark, sphinx
enum34==1.1.6 # via astroid, flake8, traitlets
entrypoints==0.3 # via flake8
execnet==1.7.1 # via pytest-cache
faker==3.0.0
first==2.0.2 # via pip-tools
flake8==3.5.0
funcsigs==1.0.2 # via mock, pytest
futures==3.3.0 # via isort
flake8==3.7.9
idna==2.8 # via requests
imagesize==1.2.0 # via sphinx
ipaddress==1.0.23 # via faker
ipdb==0.12.3
ipython-genutils==0.2.0 # via traitlets
ipython==5.8.0
Expand All @@ -44,7 +38,6 @@ mccabe==0.6.1 # via flake8, pylint
mock==2.0.0
more-itertools==5.0.0
packaging==19.2 # via sphinx
pathlib2==2.3.5 # via ipython, pickleshare
pbr==5.4.4 # via mock
pep8==1.7.1
pexpect==4.7.0 # via ipython
Expand All @@ -53,12 +46,12 @@ pip-tools==1.11.0
pluggy==0.6.0 # via pytest
progress==1.5
prompt-toolkit==1.0.18 # via ipython
psycopg2==2.8.4
psycopg2-binary==2.8.4
ptyprocess==0.6.0 # via pexpect
py==1.8.1 # via pytest
pycodestyle==2.3.1 # via flake8
pycodestyle==2.5.0 # via flake8
pydocstyle==2.1.1
pyflakes==1.6.0 # via flake8
pyflakes==2.1.1 # via flake8
pygments==2.5.2 # via ipython, sphinx
pylint==1.8.2
pyparsing==2.4.6 # via packaging
Expand All @@ -72,17 +65,17 @@ pytz==2019.3 # via babel
pyyaml==5.2
recommonmark==0.4.0
requests==2.22.0
scandir==1.10.0 # via pathlib2
simplegeneric==0.8.1 # via ipython
singledispatch==3.4.0.3 # via astroid, pylint
six==1.13.0
snowballstemmer==2.0.0 # via pydocstyle, sphinx
sphinx-rtd-theme==0.4.0
sphinx==1.7.1
sphinxcontrib-websupport==1.1.2 # via sphinx
text-unidecode==1.3 # via faker
traitlets==4.3.3 # via ipython
typing==3.7.4.1 # via sphinx
urllib3==1.25.7 # via requests
wcwidth==0.1.8 # via prompt-toolkit
wrapt==1.11.2 # via astroid

# The following packages are considered to be unsafe in a requirements file:
# setuptools==44.0.0 # via ipdb, ipython, pip-tools, pytest, sphinx
5 changes: 2 additions & 3 deletions requirements/production.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile --output-file production.txt production.in
# pip-compile --output-file=production.txt production.in
#
#--index-url https://devpi.rheinwerk-verlag.de/rheinwerk/prod/
#--trusted-host devpi.rheinwerk-verlag.de

faker==3.0.0
ipaddress==1.0.23 # via faker
progress==1.5
psycopg2==2.8.4
psycopg2-binary==2.8.4
python-dateutil==2.8.1 # via faker
pyyaml==5.2
six==1.13.0
Expand Down
13 changes: 5 additions & 8 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,27 @@
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile --output-file test.txt test.in
# pip-compile --output-file=test.txt test.in
#
#--index-url https://devpi.rheinwerk-verlag.de/rheinwerk/prod/
#--trusted-host devpi.rheinwerk-verlag.de

apipkg==1.5 # via execnet
atomicwrites==1.3.0 # via pytest
attrs==19.1.0
configparser==4.0.2 # via entrypoints, flake8
coverage==5.0.1 # via pytest-cov
entrypoints==0.3 # via flake8
enum34==1.1.6 # via flake8
execnet==1.7.1 # via pytest-cache
faker==3.0.0
flake8==3.7.9
funcsigs==1.0.2 # via mock, pytest
functools32==3.2.3.post2 ; python_version == "2.7"
ipaddress==1.0.23 # via faker
mccabe==0.6.1 # via flake8
mock==2.0.0
more-itertools==5.0.0
pbr==5.4.4 # via mock
pep8==1.7.1 # via pytest-pep8
pluggy==0.6.0 # via pytest
progress==1.5
psycopg2==2.8.4
psycopg2-binary==2.8.4
py==1.8.1 # via pytest
pycodestyle==2.5.0 # via flake8
pyflakes==2.1.1 # via flake8
Expand All @@ -40,4 +35,6 @@ python-dateutil==2.8.1 # via faker
pyyaml==5.2
six==1.13.0
text-unidecode==1.3 # via faker
typing==3.7.4.1 # via flake8

# The following packages are considered to be unsafe in a requirements file:
# setuptools==44.0.0 # via pytest
20 changes: 20 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from mock import patch, Mock

from pganonymizer.utils import get_connection


class TestGetConnection:

@patch('pganonymizer.utils.psycopg2.connect')
def test(self, mock_connect):
connection_data = {
'dbname': 'test',
'user': 'user',
'password': 'password',
'host': 'localhost',
'port': 5432
}
mock_args = Mock()
mock_args.configure_mock(**connection_data)
get_connection(mock_args)
mock_connect.assert_called_once_with(**connection_data)

0 comments on commit cb84302

Please sign in to comment.