-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement draft functionality and some tests
- Loading branch information
1 parent
16f270c
commit 26b3884
Showing
17 changed files
with
174 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture(scope='package') | ||
def test_data() -> Path: | ||
"""Test data directory.""" | ||
return Path(__file__).parent / 'data' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
columns: | ||
firstname: first_name | ||
lastname: last_name | ||
birthday: date | ||
address: street_address | ||
city: city | ||
state: state | ||
country: country | ||
email: email | ||
phone: phone_number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CustomerName,CustomerLastName,OrderID | ||
Darth,Wader,1254 | ||
Darth,Wader,1255 | ||
,Yoda,1256 | ||
Luke,Skywalker,1257 | ||
Leia,Skywalker,1258 | ||
,Yoda,1259 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
columns: | ||
CustomerName: first_name | ||
CustomerLastName: last_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
firstname,lastname,birthday,address,city,state,country,email,phone | ||
Someone,LastName,,,city,state,country,x,y | ||
SomeoneElse,LastName,,,city,state,country,y,x |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import csv | ||
from typing import TextIO, List | ||
|
||
from vendetta.models import Row | ||
|
||
|
||
def parse_csv(input_data: TextIO) -> List[Row]: | ||
"""Parse text CSV data for test purposes.""" | ||
return list(csv.DictReader(input_data)) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import subprocess | ||
import tempfile | ||
from pathlib import Path | ||
|
||
from tests.parse_csv import parse_csv | ||
|
||
|
||
def test_cli(test_data: Path): | ||
"""Run the project's CLI and test it.""" | ||
with tempfile.TemporaryDirectory() as temp: | ||
config = test_data / 'config.yaml' | ||
source = test_data / 'people.csv' | ||
destination = Path(temp) / 'output.csv' | ||
|
||
subprocess.call([ | ||
'vendetta', | ||
str(config), | ||
str(source), | ||
str(destination) | ||
]) | ||
|
||
with destination.open() as test_result: | ||
test_result_data = parse_csv(test_result) | ||
|
||
first, second = test_result_data | ||
assert first['lastname'] == second['lastname'] | ||
assert first['city'] == second['city'] | ||
|
||
assert first['email'] != second['email'] | ||
assert first['phone'] != second['phone'] | ||
assert first['firstname'] != second['firstname'] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from pathlib import Path | ||
|
||
from io import StringIO | ||
|
||
from tests.parse_csv import parse_csv | ||
from vendetta import Config, Vendetta | ||
|
||
|
||
def test_vendetta_single(test_data: Path): | ||
config = Config(columns={ | ||
'firstname': 'first_name', | ||
'lastname': 'last_name', | ||
'birthday': 'date', | ||
'address': 'street_address', | ||
'city': 'city', | ||
'state': 'state', | ||
'country': 'country', | ||
'email': 'email', | ||
'phone': 'phone_number', | ||
}) | ||
|
||
v = Vendetta(config=config) | ||
|
||
output_file = StringIO() | ||
with (test_data / 'people.csv').open('r') as input_file: | ||
v(input_file, output_file) | ||
|
||
output_file.seek(0) | ||
output_data = parse_csv(output_file) | ||
|
||
first, second = output_data | ||
assert first['lastname'] == second['lastname'] | ||
assert first['city'] == second['city'] | ||
|
||
assert first['email'] != second['email'] | ||
assert first['phone'] != second['phone'] | ||
assert first['firstname'] != second['firstname'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
# -*- coding: utf-8 -*- | ||
from vendetta.models import Config, FakerConfig | ||
from vendetta.vendetta import Vendetta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters