def test_wrong_check_dtype(self):
     """
     Tests that get_listings_dataframe will not run if datatypes are incorrect
     :param self:
     :return boolean:
     """
     with self.assertRaises(ValueError):
         get_cleaned_listings.get_listings_dataframe('Incorrect', constants.LISTING_COLUMNS)
 def test_listings_col(self):
     """
     Test cleaned_listings data has all 40 columns
     :param self:
     :return boolean:
     """
     listings = get_cleaned_listings.get_listings_dataframe(DATA, constants.LISTING_COLUMNS)
     self.assertTrue(listings.shape[1] == 40)
 def test_clean_listings_row(self):
     """
     Tests cleaned_listings data for more than one row
     :param self:
     :return boolean:
     """
     listings = get_cleaned_listings.get_listings_dataframe(DATA, constants.LISTING_COLUMNS)
     self.assertTrue(listings.shape[0] >= 1)
 def test_listings_col_types(self):
     """
     Test cleaned_listings data has the correct data column types
     :param self:
     :return boolean:
     """
     valid_types = ['int', 'O', 'O', 'float', 'float', 'O', 'O', 'int',
                    'int', 'int', 'float', 'float', 'float', 'float', 'float',
                    'float', 'float', 'float', 'float', 'float', 'float',
                    'float', 'float', 'float', 'float', 'float', 'float',
                    'float', 'float', 'float', 'float', 'float', 'float',
                    'float', 'float', 'float', 'float', 'float', 'float', 'float']
     listings = get_cleaned_listings.get_listings_dataframe(DATA, constants.LISTING_COLUMNS)
     types = listings.dtypes
     self.assertTrue((types == valid_types).all())
Ejemplo n.º 5
0
This module runs unit test for training the machine learning model.
"""

import unittest

import zillowbnb.test.submodule_path

import constants as co
import convert_to_matrix as cm
import get_data as gd
import get_cleaned_listings as gcl
import train_model as tm

DATA = gd.download_dataset(co.DATASET_PROPERTIES, co.LISTINGS_DATA)

DATAFRAME = gcl.get_listings_dataframe(DATA, co.LISTING_COLUMNS)

X_VAR, Y_VAR = cm.to_matrix(DATAFRAME, co.LISTING_COLUMNS)


class TrainModelTest(unittest.TestCase):
    """
    This class runs unit tests for the train_model module.
    """
    def test_input_size(self):
        """
        Tests that train_model will not run if sizes of x_var and y_var
        do not match.
        :params self:
        :returns boolean:
        """