diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..9a5d65a --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,52 @@ +version: 2.1 + +orbs: + python: circleci/python@0.2.1 + +jobs: + test-template: &test-template + test-py37: + docker: + - image: circleci/python:3.7 + executor: python/default + working_directory: ~/src + steps: + - checkout: + path: ~/src/mesures + - run: + command: | + export ROOT_DIR_SRC=~/src + name: Install requirements + - restore_cache: + keys: + - v1-dependencies-{{ checksum "~/src/mesures/requirements.txt"}} + - run: + command: | + cd ~/src/ + virtualenv venv + . venv/bin/activate + cd mesures + pip install -r requirements.txt + name: Install dependencies + - save_cache: + paths: + - ~/src/venv + key: v1-dependencies-{{ checksum "~/src/mesures/requirements.txt"}} + - run: + command: | + cd ~/src/ + . venv/bin/activate + cd mesures + mamba --enable-coverage + coverage report + coverage html + name: Test + - store_artifacts: + path: ~/src/mesures/htmlcov + destination: coverage + name: store_artifacts + +workflows: + main: + jobs: + - test-py37 diff --git a/requirements.txt b/requirements.txt index f35610e..b433a80 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,3 @@ pandas==0.23.4 +mamba<0.11.0 +expects diff --git a/spec/__init__.py b/spec/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/spec/generation_files/files_spec.py b/spec/generation_files/files_spec.py new file mode 100644 index 0000000..29d2816 --- /dev/null +++ b/spec/generation_files/files_spec.py @@ -0,0 +1,43 @@ +from mamba import description, context, it +from expects import expect, equal +from mesures.f1 import F1 +from mesures.p1 import P1 +from mesures.p1d import P1D +from spec.sample_data import get_sample_data + + +with description('An F1') as self: + with it('is instance of F1 Class'): + data = get_sample_data() + f = F1(data) + assert isinstance(f, F1) + + with it('a zip of raw Files'): + data = get_sample_data() + f = F1(data) + res = f.writer() + import zipfile + assert zipfile.is_zipfile(res) + + with it('has its class methods'): + data = get_sample_data() + f = F1(data) + res = f.writer() + import numpy as np + assert isinstance(f.total, (int, np.int64)) + assert f.ai == f.total + assert isinstance(f.cups, list) + assert isinstance(f.number_of_cups, int) + + +with description('An P1') as self: + with it('instance of P1 Class'): + data = get_sample_data() + f = P1(data) + assert isinstance(f, P1) + +with description('An P1D') as self: + with it('instance of P1D Class'): + data = get_sample_data() + f = P1D(data) + assert isinstance(f, P1D) diff --git a/tests/sample_data.py b/spec/sample_data.py similarity index 100% rename from tests/sample_data.py rename to spec/sample_data.py diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index da2e6ba..0000000 --- a/tests/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# -*- coding: utf-8 -*- -import test_f1 -import test_p1 \ No newline at end of file diff --git a/tests/test_f1.py b/tests/test_f1.py deleted file mode 100644 index 61a0647..0000000 --- a/tests/test_f1.py +++ /dev/null @@ -1,14 +0,0 @@ -import unittest -from mesures.f1 import F1 -from sample_data import get_sample_data - -class TestF1(unittest.TestCase): - - def test_gen_f1(self): - data = get_sample_data() - f = F1(data) - f.writer() - self.assertIsInstance(f, F1, 'F1 test fail') - -if __name__ == '__main__': - unittest.main() diff --git a/tests/test_p1.py b/tests/test_p1.py deleted file mode 100644 index 822de8b..0000000 --- a/tests/test_p1.py +++ /dev/null @@ -1,21 +0,0 @@ -import unittest -from mesures.p1 import P1 -from mesures.p1d import P1D -from sample_data import get_sample_data - -class TestF1(unittest.TestCase): - - def test_gen_p1(self): - data = get_sample_data() - f = P1(data) - f.writer() - self.assertIsInstance(f, P1, 'P1 test fail') - - def test_gen_p1d(self): - data = get_sample_data() - f = P1D(data) - f.writer() - self.assertIsInstance(f, P1D, 'P1D test fail') - -if __name__ == '__main__': - unittest.main()