Skip to content

Commit

Permalink
Refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
V1NAY8 committed Nov 10, 2020
1 parent 789f895 commit 96f0e2a
Show file tree
Hide file tree
Showing 91 changed files with 123 additions and 100 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Compiled python modules.
*.pyc
__pycache__/

# Setuptools distribution folder.
dist/
Expand All @@ -11,18 +12,19 @@ build/
docs/build/

# pytest results
eland/tests/dataframe/results/
test_eland/test_dataframe/results/*csv
result_images/


# Python egg metadata, regenerated from source files by setuptools.
/*.egg-info
eland.egg-info/

# PyCharm files
.idea/

# vscode files
.vscode/*
.vscode/

# pytest files
.pytest_cache/
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ Once your changes and tests are ready to submit for review:
$ nox -s format

# Run the test suite
$ pytest --doctest-modules eland/tests/
$ pytest --nbval eland/tests/tests_notebook/
$ pytest --doctest-modules test_eland/
$ pytest --nbval test_eland/tests_notebook/

```

Expand Down Expand Up @@ -182,7 +182,7 @@ currently using a minimum version of PyCharm 2019.2.4.
* To setup test environment:

``` bash
> python -m eland.tests.setup_tests
> python -m test_eland.setup_tests
```

(Note this modifies Elasticsearch indices)
Expand Down
6 changes: 3 additions & 3 deletions docs/sphinx/development/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,13 @@ Configuring PyCharm And Running Tests
- To setup test environment -*note this modifies Elasticsearch indices* run
.. code-block:: bash
python -m eland.tests.setup_tests
python -m test_eland.setup_tests
- To validate installation, open python console and run
.. code-block:: bash
import eland as ed
ed_df = ed.DataFrame('localhost', 'flights')
import eland as ed
ed_df = ed.DataFrame('localhost', 'flights')
- To run the automatic formatter and check for lint issues
.. code-block:: bash
Expand Down
22 changes: 9 additions & 13 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@
import nox

BASE_DIR = Path(__file__).parent
SOURCE_FILES = (
"setup.py",
"noxfile.py",
"eland/",
"docs/",
"utils/",
)
SOURCE_FILES = ("setup.py", "noxfile.py", "eland/", "docs/", "utils/", "test_eland/")

# Whenever type-hints are completed on a file it should
# be added here so that this file will continue to be checked
Expand Down Expand Up @@ -98,15 +92,17 @@ def lint(session):
@nox.session(python=["3.6", "3.7", "3.8"])
def test(session):
session.install("-r", "requirements-dev.txt")
session.run("python", "-m", "eland.tests.setup_tests")
session.run("python", "-m", "test_eland.setup_tests")
session.install(".")
session.run(
"pytest",
"--cov=eland",
"--cov-report",
"term-missing",
"--cov=eland/",
"--doctest-modules",
*(session.posargs or ("eland/",)),
*(session.posargs or ("eland/", "test_eland/")),
"--nbval",
"eland/tests/tests_notebook/",
"test_eland/tests_notebook/",
)

session.run(
Expand All @@ -119,7 +115,7 @@ def test(session):
"xgboost",
"lightgbm",
)
session.run("pytest", "eland/tests/ml/")
session.run("pytest", "test_eland/test_ml/")


@nox.session(reuse_venv=True)
Expand All @@ -138,7 +134,7 @@ def docs(session):
es = elasticsearch.Elasticsearch("localhost:9200")
es.info()
if not es.indices.exists("flights"):
session.run("python", "-m", "eland.tests.setup_tests")
session.run("python", "-m", "test_eland.setup_tests")
es_active = True
except Exception:
es_active = False
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion eland/tests/common.py → test_eland/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))

# Create pandas and eland data frames
from eland.tests import (
from test_eland import (
ECOMMERCE_DF_FILE_NAME,
ECOMMERCE_INDEX_NAME,
ES_TEST_CLIENT,
Expand Down
File renamed without changes.
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 eland/tests/setup_tests.py → test_eland/setup_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from elasticsearch import helpers

from eland.common import es_version
from eland.tests import (
from test_eland import (
ECOMMERCE_FILE_NAME,
ECOMMERCE_INDEX_NAME,
ECOMMERCE_MAPPING,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import pytest
from pandas.testing import assert_frame_equal, assert_series_equal

from eland.tests.common import TestData
from test_eland.common import TestData


class TestDataFrameAggs(TestData):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# File called _pytest for PyCharm compatability

import eland as ed
from eland.tests.common import ES_TEST_CLIENT, TestData
from test_eland.common import ES_TEST_CLIENT, TestData


class TestDataFrameBigMapping(TestData):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# File called _pytest for PyCharm compatability
from pandas.testing import assert_series_equal

from eland.tests.common import TestData
from test_eland.common import TestData


class TestDataFrameCount(TestData):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import eland as ed
from eland.field_mappings import FieldMappings
from eland.tests.common import (
from test_eland.common import (
ES_TEST_CLIENT,
TestData,
assert_pandas_eland_frame_equal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from pandas.testing import assert_frame_equal

from eland.tests.common import TestData
from test_eland.common import TestData


class TestDataFrameDescribe(TestData):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# File called _pytest for PyCharm compatibility


from eland.tests.common import TestData
from test_eland.common import TestData


class TestDataFrameDir(TestData):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import numpy as np
import pandas as pd

from eland.tests.common import assert_series_equal
from test_eland.common import assert_series_equal


class TestDataFrameDtypes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# File called _pytest for PyCharm compatability

from eland.tests.common import TestData
from test_eland.common import TestData


class TestEsMatch(TestData):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import pytest

from eland.tests.common import TestData, assert_eland_frame_equal
from test_eland.common import TestData, assert_eland_frame_equal


class TestDataEsQuery(TestData):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import pytest

from eland.tests.common import TestData
from test_eland.common import TestData


class TestDataFrameFilter(TestData):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import pytest
from pandas.testing import assert_frame_equal, assert_index_equal, assert_series_equal

from eland.tests.common import TestData
from test_eland.common import TestData


class TestGroupbyDataFrame(TestData):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# File called _pytest for PyCharm compatability

from eland.tests.common import TestData, assert_pandas_eland_frame_equal
from test_eland.common import TestData, assert_pandas_eland_frame_equal


class TestDataFrameHeadTail(TestData):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import pandas as pd
from pandas.testing import assert_frame_equal

from eland.tests.common import TestData
from test_eland.common import TestData


class TestDataFrameHist(TestData):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
from io import StringIO

import eland as ed
from eland.tests import ES_TEST_CLIENT
from eland.tests.common import TestData
from test_eland import ES_TEST_CLIENT
from test_eland.common import TestData


class TestDataFrameInfo(TestData):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import eland as ed
from eland.query_compiler import QueryCompiler
from eland.tests import ES_TEST_CLIENT, FLIGHTS_INDEX_NAME
from test_eland import ES_TEST_CLIENT, FLIGHTS_INDEX_NAME


class TestDataFrameInit:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from pandas.testing import assert_index_equal

from eland.tests.common import TestData
from test_eland.common import TestData


class TestDataFrameKeys(TestData):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import pytest
from pandas.testing import assert_frame_equal, assert_series_equal

from eland.tests.common import TestData
from test_eland.common import TestData


class TestDataFrameMetrics(TestData):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from pandas.testing import assert_series_equal

from eland.tests.common import TestData
from test_eland.common import TestData


class TestDataFrameNUnique(TestData):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import pandas as pd

import eland as ed
from eland.tests.common import ES_TEST_CLIENT, TestData, assert_pandas_eland_frame_equal
from test_eland.common import ES_TEST_CLIENT, TestData, assert_pandas_eland_frame_equal


class TestDataFrameQuery(TestData):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import pytest

from eland.dataframe import DEFAULT_NUM_ROWS_DISPLAYED
from eland.tests.common import TestData, assert_pandas_eland_series_equal
from test_eland.common import TestData, assert_pandas_eland_series_equal


class TestDataFrameRepr(TestData):
Expand Down Expand Up @@ -161,6 +161,9 @@ def test_empty_dataframe_repr(self):
ed_ecom_r = repr(ed_ecom[ed_ecom["currency"] == "USD"])
pd_ecom_r = repr(pd_ecom[pd_ecom["currency"] == "USD"])

print(ed_ecom_r)
print(pd_ecom_r)

assert ed_ecom_r == pd_ecom_r

"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from pandas.testing import assert_frame_equal

from eland import eland_to_pandas
from eland.tests.common import TestData
from test_eland.common import TestData


class TestDataFrameSample(TestData):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# File called _pytest for PyCharm compatability
import numpy as np

from eland.tests.common import TestData, assert_pandas_eland_frame_equal
from test_eland.common import TestData, assert_pandas_eland_frame_equal


class TestDataFrameSelectDTypes(TestData):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

# File called _pytest for PyCharm compatability

from eland.tests.common import TestData
from test_eland.common import TestData


class TestDataFrameShape(TestData):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
from pandas.testing import assert_frame_equal

import eland as ed
from eland.tests import ES_TEST_CLIENT, FLIGHTS_INDEX_NAME
from eland.tests.common import ROOT_DIR, TestData
from test_eland import ES_TEST_CLIENT, FLIGHTS_INDEX_NAME
from test_eland.common import ROOT_DIR, TestData


class TestDataFrameToCSV(TestData):
def test_to_csv_head(self):
results_file = ROOT_DIR + "/dataframe/results/test_to_csv_head.csv"
results_file = ROOT_DIR + "/test_dataframe/results/test_to_csv_head.csv"

ed_flights = self.ed_flights().head()
pd_flights = self.pd_flights().head()
Expand All @@ -50,7 +50,7 @@ def test_to_csv_head(self):
assert_frame_equal(pd_flights, pd_from_csv)

def test_to_csv_full(self):
results_file = ROOT_DIR + "/dataframe/results/test_to_csv_full.csv"
results_file = ROOT_DIR + "/test_dataframe/results/test_to_csv_full.csv"

# Test is slow as it's for the full dataset, but it is useful as it goes over 10000 docs
ed_flights = self.ed_flights()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import eland as ed
from eland.field_mappings import FieldMappings
from eland.tests.common import ES_TEST_CLIENT, TestData, assert_pandas_eland_frame_equal
from test_eland.common import ES_TEST_CLIENT, TestData, assert_pandas_eland_frame_equal


class TestDataFrameUtils(TestData):
Expand Down
File renamed without changes.

0 comments on commit 96f0e2a

Please sign in to comment.