-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #217 from dyvenia/dev
Release 0.2.13 PR
- Loading branch information
Showing
14 changed files
with
292 additions
and
115 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
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
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 |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
|
||
|
||
def test_version(): | ||
assert __version__ == "0.2.12" | ||
assert __version__ == "0.2.13" |
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,36 @@ | ||
from viadot.sources import CloudForCustomers | ||
|
||
import os | ||
import numpy | ||
import pytest | ||
|
||
|
||
TEST_FILE_1 = "tests_out.csv" | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def cloud_for_customers(): | ||
url = "http://services.odata.org/V2/Northwind/Northwind.svc/" | ||
endpoint = "Employees" | ||
cloud_for_customers = CloudForCustomers( | ||
url=url, endpoint=endpoint, params={"$top": "2"} | ||
) | ||
yield cloud_for_customers | ||
os.remove(TEST_FILE_1) | ||
|
||
|
||
def test_to_records(cloud_for_customers): | ||
data = cloud_for_customers.to_records() | ||
assert "EmployeeID" in data[0].keys() | ||
|
||
|
||
def test_to_df(cloud_for_customers): | ||
df = cloud_for_customers.to_df(fields=["EmployeeID", "FirstName", "LastName"]) | ||
assert type(df["EmployeeID"][0]) == numpy.int64 | ||
|
||
|
||
def test_csv(cloud_for_customers): | ||
csv = cloud_for_customers.to_csv( | ||
path=TEST_FILE_1, fields=["EmployeeID", "FirstName", "LastName"] | ||
) | ||
assert os.path.isfile(TEST_FILE_1) == True |
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,121 @@ | ||
import pytest | ||
from viadot.sources import Supermetrics | ||
|
||
RESPONSE_PIVOTED = { | ||
"meta": { | ||
"query": { | ||
"fields": [ | ||
{ | ||
"id": "Date", | ||
"field_id": "Date", | ||
"field_name": "Date", | ||
"field_type": "dim", | ||
"field_split": "row", | ||
}, | ||
{ | ||
"id": "profile", | ||
"field_id": "profile", | ||
"field_name": "View", | ||
"field_type": "dim", | ||
"field_split": "row", | ||
}, | ||
{ | ||
"id": "segment", | ||
"field_id": "segment", | ||
"field_name": "Segment", | ||
"field_type": "dim", | ||
"field_split": "column", | ||
}, | ||
{ | ||
"id": "Sessions", | ||
"field_id": "Sessions", | ||
"field_name": "Sessions", | ||
"field_type": "met", | ||
"field_split": "row", | ||
}, | ||
] | ||
}, | ||
"result": {"total_columns": 6, "total_rows": 700}, | ||
}, | ||
"data": [ | ||
[ | ||
"Date", | ||
"View", | ||
"M-site_TOTAL: Bounces Landing", | ||
"M-site_TOTAL: Click to EDSP", | ||
"M-site_TOTAL: MQL Conversion Page Sessions", | ||
"M-site_TOTAL: Click to RWS", | ||
], | ||
["2020-01-01", "REDACTED", 123, 456, 78, 9], | ||
], | ||
} | ||
|
||
RESPONSE_PIVOTED_NO_DATA = { | ||
"meta": { | ||
"query": { | ||
"fields": [ | ||
{ | ||
"id": "Date", | ||
"field_id": "Date", | ||
"field_name": "Date", | ||
"field_type": "dim", | ||
"field_split": "row", | ||
}, | ||
{ | ||
"id": "profileID", | ||
"field_id": "profileID", | ||
"field_name": "View ID", | ||
"field_type": "dim", | ||
"field_split": "row", | ||
}, | ||
{ | ||
"id": "Hostname", | ||
"field_id": "Hostname", | ||
"field_name": "Hostname", | ||
"field_type": "dim", | ||
"field_split": "row", | ||
}, | ||
{ | ||
"id": "profile", | ||
"field_id": "profile", | ||
"field_name": "View", | ||
"field_type": "dim", | ||
"field_split": "row", | ||
}, | ||
{ | ||
"id": "segment", | ||
"field_id": "segment", | ||
"field_name": "Segment", | ||
"field_type": "dim", | ||
"field_split": "column", | ||
}, | ||
{ | ||
"id": "Sessions", | ||
"field_id": "Sessions", | ||
"field_name": "Sessions", | ||
"field_type": "met", | ||
"field_split": "row", | ||
}, | ||
] | ||
}, | ||
"result": {"total_columns": 0, "total_rows": 0}, | ||
}, | ||
"data": [], | ||
} | ||
|
||
|
||
def test___get_col_names_google_analytics_pivoted(): | ||
columns = Supermetrics._get_col_names_google_analytics(response=RESPONSE_PIVOTED) | ||
assert columns == [ | ||
"Date", | ||
"View", | ||
"M-site_TOTAL: Bounces Landing", | ||
"M-site_TOTAL: Click to EDSP", | ||
"M-site_TOTAL: MQL Conversion Page Sessions", | ||
"M-site_TOTAL: Click to RWS", | ||
] | ||
|
||
|
||
def test___get_col_names_google_analytics_pivoted_no_data(): | ||
with pytest.raises(ValueError): | ||
Supermetrics._get_col_names_google_analytics(response=RESPONSE_PIVOTED_NO_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 |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.2.12" | ||
__version__ = "0.2.13" |
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 |
---|---|---|
|
@@ -4,3 +4,7 @@ class ValidationError(Exception): | |
|
||
class APIError(Exception): | ||
pass | ||
|
||
|
||
class CredentialError(Exception): | ||
pass |
Oops, something went wrong.