Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Natalie Caruana authored and Natalie-Caruana committed Jan 10, 2019
1 parent 390d106 commit 7f0b7d5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ def test_random_dataset_attrs(self):
self.assertTrue(isinstance(dataset, GordoBaseDataset))
self.assertTrue(isinstance(dataset, RandomDataset))
self.assertTrue(hasattr(dataset, 'get_data'))
self.assertTrue(hasattr(dataset, 'get_metadata'))

X, y = dataset.get_data()
self.assertTrue(isinstance(X, np.ndarray))

# y can either be None or an numpy array
self.assertTrue(isinstance(y, np.ndarray) or y is None)

metadata = dataset.get_metadata()
self.assertTrue(isinstance(metadata,dict))
25 changes: 25 additions & 0 deletions tests/test_influx_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from click.testing import CliRunner

from gordo_components.dataset._datasets import InfluxBackedDataset
from gordo_components.dataset import get_dataset

import pytest

Expand Down Expand Up @@ -146,3 +147,27 @@ def test__list_of_tags_from_influx_validate_tag_names(self):
tags = set(list_of_tags)
self.assertTrue(expected_tags==tags,msg=f'Expected tags = {expected_tags}'
f'outputted {tags}')

def test_influx_dataset_attrs(self):
"""
Test expected attributes
"""
from_ts = '2016-01-01T09:11:00+00:00'
to_ts = '2016-01-01T10:30:00+00:00'
from_ts = dateutil.parser.isoparse(from_ts)
to_ts = dateutil.parser.isoparse(to_ts)
influx_config = self.influx_config
tag_list = ['TRC-FIQ -23-0453N', 'TRC-FIQ -80-0303N',
'TRC-FIQ -80-0703N', 'TRC-FIQ -80-0704N']
config = {
'type': 'influx',
'from_ts': from_ts,
'to_ts': to_ts,
'influx_config': influx_config,
'tag_list': tag_list
}
dataset = get_dataset(config)
self.assertTrue(hasattr(dataset, 'get_metadata'))

metadata = dataset.get_metadata()
self.assertTrue(isinstance(metadata, dict))

0 comments on commit 7f0b7d5

Please sign in to comment.