-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixed CSV import * Ignoring editor files * Added permission check on csv import/export * Adding code coverage * Added codecov badge * Fixed coverage command * Fixing coverage tests * Passing commit sha to codecov * Fixing test build * Fixed line endings * Reverted tests
- Loading branch information
Showing
17 changed files
with
263 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.vscode/ | ||
database.db |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
.DS_Store | ||
node_modules | ||
/dist | ||
.coverage | ||
coverage.xml | ||
|
||
tuber.json | ||
database.db | ||
|
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,4 +1,4 @@ | ||
[pytest] | ||
testpaths=tests | ||
filterwarnings = | ||
ignore::DeprecationWarning | ||
ignore::DeprecationWarning |
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,2 +1,3 @@ | ||
. | ||
pytest | ||
pytest | ||
coverage |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
from unittest.mock import patch | ||
from util import * | ||
import json | ||
|
||
@patch('tuber.api.hotels.requests.post') | ||
|
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,48 @@ | ||
import datetime | ||
import json | ||
import io | ||
|
||
def test_csv_export(client): | ||
"""Try exporting a table and make sure it matches the expected contents.""" | ||
badge = client.post("/api/events/1/badges", json={ | ||
"legal_name": "Test User", | ||
"departments": [] | ||
}).json | ||
assert(badge['legal_name'] == "Test User") | ||
|
||
export = client.get("/api/importer/csv", query_string={"csv_type": "Badge"}).data.decode('UTF-8').strip() | ||
assert(len(export.split("\n")) == 2) | ||
header, exported_badge = export.split("\n") | ||
header = header.split(",") | ||
exported_badge = exported_badge.split(",") | ||
badge_dict = {k:v for k,v in zip(header, exported_badge)} | ||
assert(badge_dict['legal_name'] == "Test User") | ||
|
||
def test_csv_import(client): | ||
client.post("/api/importer/csv", content_type="multipart/form-data", data={ | ||
"csv_type": "Badge", | ||
"raw_import": False, | ||
"full_import": False, | ||
"files": (io.BytesIO(b"legal_name,event\nTest User 1,1"), 'badge.csv') | ||
}) | ||
badges = client.get("/api/events/1/badges").json | ||
assert(len(badges) == 1) | ||
|
||
client.post("/api/importer/csv", content_type="multipart/form-data", data={ | ||
"csv_type": "Badge", | ||
"raw_import": False, | ||
"full_import": False, | ||
"files": (io.BytesIO(b"legal_name,event\nTest User 2,1"), 'badge.csv') | ||
}) | ||
badges = client.get("/api/events/1/badges").json | ||
assert(len(badges) == 2) | ||
|
||
client.post("/api/importer/csv", content_type="multipart/form-data", data={ | ||
"csv_type": "Badge", | ||
"raw_import": False, | ||
"full_import": True, | ||
"files": (io.BytesIO(b"legal_name,event\nTest User 3,1"), 'badge.csv') | ||
}) | ||
badges = client.get("/api/events/1/badges", query_string={"full": True}).json | ||
assert(len(badges) == 1) | ||
assert(badges[0]['legal_name'] == "Test User 3") |
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,4 +1,3 @@ | ||
from util import * | ||
import datetime | ||
import json | ||
|
||
|
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,4 +1,4 @@ | ||
from util import * | ||
from conftest import csrf | ||
import json | ||
|
||
def test_csrf(client_fresh): | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#!/bin/bash | ||
pip install pytest | ||
pip install coverage | ||
cd frontend | ||
npm install --only=dev |
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
Oops, something went wrong.