@@ -0,0 +1,2865 @@
+# Copyright 2020 Google LLC%0A#%0A# Licensed under the Apache License, Version 2.0 (the %22License%22);%0A# you may not use this file except in compliance with the License.%0A# You may obtain a copy of the License at%0A#%0A#     https://www.apache.org/licenses/LICENSE-2.0%0A#%0A# Unless required by applicable law or agreed to in writing, software%0A# distributed under the License is distributed on an %22AS IS%22 BASIS,%0A# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A# See the License for the specific language governing permissions and%0A# limitations under the License.%0A%0A%22%22%22Testing for custom_predict.py%22%22%22%0A%0Aimport csv%0Aimport os%0Aimport unittest%0Afrom unittest import TestCase%0A%0Afrom custom_predict import __preprocess_input as preprocess_input%0Aimport preprocess_utils%0A%0ATEMP_TESTING_FILE = %22./temp_file_for_testing_custom_predict.tsv%22%0A%0Aclass CustomPredictTest(TestCase):    %0A    def test_preprocess_input_with_scoring_and_two_rows(self):%0A        with open(TEMP_TESTING_FILE, %22wt%22) as f:%0A            tsv_writer = csv.writer(f, delimiter='%5Ct')%0A            for i in range(10):%0A                tsv_writer.writerow(%5B%22Sample%22 + str(i), %22Summary%22 + str(i)%5D)%0A        %0A        sentences,summaries = preprocess_input(input_file_path=TEMP_TESTING_FILE,%0A                                              whether_score=True)%0A        %0A        preprocess_utils.validate_dataset(sentences, summaries)%0A        for i in range(10):%0A            self.assertEqual(sentences%5Bi%5D, %22Sample%22 + str(i))%0A            self.assertEqual(summaries%5Bi%5D, %22Summary%22 + str(i))%0A            %0A        os.remove(TEMP_TESTING_FILE)%0A    %0A    %0A    def test_preprocess_input_with_scoring_and_only_one_row(self):%0A        with open(TEMP_TESTING_FILE, %22wt%22) as f:%0A            tsv_writer = csv.writer(f, delimiter='%5Ct')%0A            for i in range(10):%0A                tsv_writer.writerow(%5B%22Sample%22 + str(i)%5D)%0A        %0A        with self.assertRaises(Exception):%0A            sentences,summaries = preprocess_input(input_file_path=TEMP_TESTING_FILE,%0A                                                  whether_score=True)%0A        %0A        os.remove(TEMP_TESTING_FILE)%0A    %0A    %0A    def test_preprocess_input_without_scoring_and_only_one_rows(self):%0A        with open(TEMP_TESTING_FILE, %22wt%22) as f:%0A            tsv_writer = csv.writer(f, delimiter='%5Ct')%0A            for i in range(10):%0A                tsv_writer.writerow(%5B%22Sample%22 + str(i)%5D)%0A        %0A        sentences,summaries = preprocess_input(input_file_path=TEMP_TESTING_FILE,%0A                                              whether_score=False)%0A        %0A        preprocess_utils.validate_dataset(sentences, summaries)%0A        for i in range(10):%0A            self.assertEqual(sentences%5Bi%5D, %22Sample%22 + str(i))%0A            self.assertEqual(summaries%5Bi%5D, %22Sample%22 + str(i))%0A            %0A        os.remove(TEMP_TESTING_FILE)%0A%0Aif __name__ == '__main__':%0A    unittest.main()%0A

Create custom_predict_test.py