示例#1
0
    def test_dognames_count(self):
        """Test if dognames_count works"""
        dognames = student_submission.read_csv('./dognames.csv')

        count = student_submission.dognames_count(dognames)
        self.assertTrue(isinstance(count, dict),
                        'The return type of dognames_count seems wrong')

        self.assertEqual(count['Rocky'], 10, 'The counting seems to be wrong')
示例#2
0
    def test_is_valid_row(self):
        """Test if is_valid_row works"""
        dognames = student_submission.read_csv('./dognames.csv')

        self.assertTrue(
            student_submission.is_valid_row(dognames[999], year=2007, sex='m'),
            'Your implementation seems wrong')
        self.assertFalse(
            student_submission.is_valid_row(dognames[999], year=2006, sex='w'),
            'Your implementation seems wrong')
示例#3
0
    def test_top_n_dognames(self):
        """Test if top_n_dognames works"""
        dognames = student_submission.read_csv('./dognames.csv')

        top_1 = student_submission.top_n_dognames(dognames, 1)
        self.assertTrue(isinstance(top_1, list),
                        'The return type of top_n_dognames seems wrong')

        self.assertEqual(top_1[0][0], 'Luna',
                         'The top used dog name seems wrong')
示例#4
0
    def test_filter_dognames(self):
        """Test if filter_dognames works"""
        dognames = student_submission.read_csv('./dognames.csv')

        unfiltered = student_submission.filter_dognames(dognames)
        self.assertTrue(isinstance(unfiltered, list),
                        'The return type of filter_dognames seems wrong')

        self.assertEqual(
            len(student_submission.filter_dognames(dognames, year=2004)), 98,
            'Your implementation seems wrong')
示例#5
0
    def test_preview_dognames(self):
        """Test if preview_dognames works"""
        dognames = student_submission.read_csv('./dognames.csv')

        preview = student_submission.preview_dognames(dognames, 1)
        self.assertTrue(isinstance(preview, list),
                        'The return type of preview_dognames seems wrong')

        preview_all = student_submission.preview_dognames(dognames, 1396)
        self.assertEqual(len(preview_all), 1122,
                         'The length of the result list seems wrong')

        all_strings = all(isinstance(name, str) for name in preview_all)
        self.assertTrue(all_strings,
                        'The result list should contain only strings')
示例#6
0
    def test_read_csv(self):
        """Reads csv file"""
        dognames = student_submission.read_csv('./dognames.csv')

        number_of_lines = len(dognames)
        self.assertEqual(number_of_lines, 1396, 'Unexpected number of lines')