Skip to content

Commit

Permalink
restructued, some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
blaklaybul committed May 18, 2018
1 parent 7773a3b commit fdacf88
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 2 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion anonymize-it/readers.py → anonymize_it/readers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from abc import ABCMeta, abstractmethod
from elasticsearch import Elasticsearch, helpers
from elasticsearch import Elasticsearch
from elasticsearch_dsl import Search, A


Expand Down
1 change: 1 addition & 0 deletions anonymize-it/utils.py → anonymize_it/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import collections


def flatten(d, parent_key='', sep='.'):
items = []
for k, v in d.items():
Expand Down
2 changes: 1 addition & 1 deletion anonymize-it/writers.py → anonymize_it/writers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from abc import abstractmethod, ABCMeta
import json

class BaseWriter():
class BaseWriter(metaclass=ABCMeta):
def __init__(self, params):
self.params = params

Expand Down
File renamed without changes.
Empty file added test_anonymize_it/conftest.py
Empty file.
14 changes: 14 additions & 0 deletions test_anonymize_it/run_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import sys
import pytest


def run_all(argv=None):
if argv is None:
argv = ['--cov', 'anonymize_it', '--verbose', '--junitxml', 'junit.xml', '--cov-report', 'xml']
else:
argv = argv[1:]

sys.exit(pytest.main(argv))

if __name__ == "__main__":
run_all(sys.argv)
Empty file.
Binary file added test_anonymize_it/test_output/.DS_Store
Binary file not shown.
4 changes: 4 additions & 0 deletions test_anonymize_it/test_readers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from anonymize_it import readers

def test_esreader():
pass
17 changes: 17 additions & 0 deletions test_anonymize_it/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from anonymize_it import utils


def test_flatten():
old = {
"this": {
"is": {
"a": {
"test": True
}
}
}
}

flattened = utils.flatten(old)
new = {"this.is.a.test": True}
assert new == flattened
27 changes: 27 additions & 0 deletions test_anonymize_it/test_writers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from anonymize_it import writers
import json
import os


def test_fswriter():
params = {
"directory": "test_output"
}

data = {
"test": "this is a test".split()
}

fswriter = writers.FSWriter(params)
fswriter.write_data(data)
file_name = "test_output/output.json"
with open(file_name, 'r') as f:
in_data = json.load(f)

os.remove(file_name)

assert data == in_data


def test_ESWriter():
pass

0 comments on commit fdacf88

Please sign in to comment.