Пример #1
0
    def test_tc03a(self):
        """
        ref. https://docs.google.com/document/d/1spaSZlvmHTDarW6OnKvrKgJKRdbS-mKc/edit#bookmark=id.1a6jj95xd435
        """
        tc_file = get_tc_file(self)

        #region make input file
        valid_input = f'{tc_file}.input'
        write2file(
            filename=valid_input,
            lines=textwrap.dedent('''
                1
                22
                333 
                44 
                555
                a
            ''').strip(),
        )
        #endregion

        with self.assertRaises(Exception) as ec:  # ec aka. exception context
            actual_output = f'{tc_file}.out'
            find_min(input=valid_input, output=actual_output)
        assert str(ec.exception
                   ) == f'Invalid input: The item in the list must be a number'
Пример #2
0
    def test_tc00(self):
        """
        ref. https://docs.google.com/document/d/1v1FcxCLvVGZcAIKy1Q6aPCq3bevR64igyLG4O60JptE/edit#bookmark=id.q1lpunwc78v8
        """
        tc_file = get_tc_file(self)

        #region make input file
        valid_input = f'{tc_file}.input'
        write2file(
            filename=valid_input,
            lines=textwrap.dedent('''
                nricfin first_name middle_name last_name date_of_birth premium claim_count
                0
            ''').strip(),
        )
        #endregion

        #region make expected output
        expected_output = f'{tc_file}.expected.out'
        write2file(
            filename=expected_output,
            lines=textwrap.dedent('').strip(),
        )
        #endregion

        # run testee code
        actual_output = f'{tc_file}.out'
        insurance_policies(valid_input, actual_output)

        # check for expected values
        assert filecmp.cmp(actual_output, expected_output) is True
Пример #3
0
    def test_tc01(self):
        """
        ref. https://docs.google.com/document/d/1spaSZlvmHTDarW6OnKvrKgJKRdbS-mKc/edit#bookmark=id.ej3k2ud0bk6m
        """
        tc_file = get_tc_file(self)

        #region make input file
        valid_input = f'{tc_file}.input'
        write2file(
            filename=valid_input,
            lines=textwrap.dedent('''
            1 
            22
            333
            44 
            55
            66
            ''').strip(),
        )
        #endregion

        #region make expected output
        expected_output = f'{tc_file}.expected.out'
        write2file(
            filename=expected_output,
            lines=textwrap.dedent('1').strip(),
        )
        #endregion

        # run testee code
        actual_output = f'{tc_file}.out'
        find_min(valid_input, actual_output)

        # check for expected values
        assert filecmp.cmp(actual_output, expected_output)
Пример #4
0
    def test_tc01(self):
        """
        ref. https://docs.google.com/document/d/1SMjeNNPntRFNPrDqngh304hUh9P4cD0L/edit#bookmark=id.c94ptzuqqtop
        """
        tc_file = get_tc_file(self)

        #region make input file
        valid_input = f'{tc_file}.input'
        write2file(
            filename=valid_input,
            lines=textwrap.dedent('''
                0
            ''').strip(),
        )
        #endregion

        #region make expected output
        expected_output = f'{tc_file}.expected.out'
        write2file(
            filename=expected_output,
            lines=textwrap.dedent('').strip(),
        )
        #endregion

        # run testee code
        actual_output = f'{tc_file}.out'
        find_max_claim(valid_input, actual_output)

        # check for expected values
        assert filecmp.cmp(actual_output, expected_output)
Пример #5
0
    def test_tc03b(self):
        """
        ref. https://docs.google.com/document/d/1spaSZlvmHTDarW6OnKvrKgJKRdbS-mKc/edit#bookmark=id.r0torxrmg9uh
        """
        tc_file = get_tc_file(self)

        #region make input file
        valid_input = f'{tc_file}.input'
        write2file(
            filename=valid_input,
            lines=textwrap.dedent('').strip(),
        )
        #endregion

        with self.assertRaises(Exception) as ec:  # ec aka. exception context
            find_min(input=valid_input, output='any/thing')
        assert str(
            ec.exception) == f'Invalid input: Empty file with empty String'
Пример #6
0
    def test_tc02(self):
        """
        ref. https://docs.google.com/document/d/1spaSZlvmHTDarW6OnKvrKgJKRdbS-mKc/edit#bookmark=id.bn49fls8npyl
        """
        tc_file = get_tc_file(self)

        #region make input file
        valid_input = f'{tc_file}.input'
        write2file(
            filename=valid_input,
            lines=textwrap.dedent('1, 22, 333').strip(),
        )
        #endregion

        with self.assertRaises(Exception) as ec:  # ec aka. exception context
            actual_output = '/any/thing/'
            find_min(input=valid_input, output=actual_output)
        assert str(ec.exception
                   ) == f'Invalid input: List of numbers should have 6 numbers'
Пример #7
0
    def test_tc04b(self):
        """
        ref. https://docs.google.com/document/d/1SMjeNNPntRFNPrDqngh304hUh9P4cD0L/edit#bookmark=id.bfnsn71ffq4t
        """
        tc_file = get_tc_file(self)

        #region make input file
        valid_input = f'{tc_file}.input'
        write2file(
            filename=valid_input,
            lines=textwrap.dedent('''
                4
            ''').strip(),
        )
        #endregion

        with self.assertRaises(Exception) as ec:  # ec aka. exception context
            actual_output = f'{tc_file}.out'
            find_max_claim(valid_input, actual_output)
        assert str(ec.exception) == f'Claim-count is empty'
Пример #8
0
    def test_tc03a(self):
        """
        ref. https://docs.google.com/document/d/1SMjeNNPntRFNPrDqngh304hUh9P4cD0L/edit#bookmark=id.e3cieiz84v1i
        """
        tc_file = get_tc_file(self)

        #region make input file
        valid_input = f'{tc_file}.input'
        write2file(
            filename=valid_input,
            lines=textwrap.dedent('''
               abc
            ''').strip(),
        )
        #endregion

        with self.assertRaises(Exception) as ec:  # ec aka. exception context
            actual_output = f'{tc_file}.out'
            find_max_claim(valid_input, actual_output)
        assert str(ec.exception) == f'N must be an integer number'
Пример #9
0
    def test_tc01(self):
        """
        ref. https://docs.google.com/document/d/1spaSZlvmHTDarW6OnKvrKgJKRdbS-mKc/edit#bookmark=id.ej3k2ud0bk6m
        """
        tc_file = get_tc_file(self)

        #region make input file
        valid_input = f'{tc_file}.input'
        write2file(
            filename=valid_input,
            lines=textwrap.dedent('1, 22, 333, 44, 55, 66').strip(),
        )
        #endregion

        #region make expected output
        actual_output = f'{tc_file}.out'
        expected_output = f'{tc_file}.expected.out'
        find_min(input=valid_input, output=actual_output)
        write2file(
            filename=expected_output,
            lines=textwrap.dedent('1').strip(),
        )
Пример #10
0
    def test_tc09b(self):
        """
        ref. https://docs.google.com/document/d/1v1FcxCLvVGZcAIKy1Q6aPCq3bevR64igyLG4O60JptE/edit#bookmark=id.g2o57ezfn79p
        """
        tc_file = get_tc_file(self)

        # region make input file
        valid_input = f'{tc_file}.input'
        write2file(
            filename=valid_input,
            lines=textwrap.dedent('''
                nricfin first_name middle_name last_name date_of_birth premium claim_count
                1
                S122333bG trinh do cao 2000-02-11 500 empty
            ''').strip(),
        )
        #endregion

        with self.assertRaises(Exception) as ec:  # ec aka. exception context
            actual_output = f'{tc_file}.out'
            insurance_policies(valid_input, actual_output)
        assert str(ec.exception) == f'c must have a value'
Пример #11
0
    def test_tc08a(self):
        """
        ref. https://docs.google.com/document/d/1v1FcxCLvVGZcAIKy1Q6aPCq3bevR64igyLG4O60JptE/edit#bookmark=id.79gt5un0wtc2
        """
        tc_file = get_tc_file(self)

        #region make input file
        valid_input = f'{tc_file}.input'
        write2file(
            filename=valid_input,
            lines=textwrap.dedent('''
                nricfin first_name middle_name last_name date_of_birth premium claim_count
                1
                S122333bG binh thi tran 1990-02-11 -500 0
            ''').strip(),
        )
        #endregion

        with self.assertRaises(Exception) as ec:  # ec aka. exception context
            actual_output = f'{tc_file}.out'
            insurance_policies(valid_input, actual_output)
        assert str(ec.exception) == f'p must be a positive float number'
Пример #12
0
    def test_tc07a(self):
        """
        ref. https://docs.google.com/document/d/1v1FcxCLvVGZcAIKy1Q6aPCq3bevR64igyLG4O60JptE/edit#bookmark=id.aptazpl02c30
        """
        tc_file = get_tc_file(self)

        #region make input file
        valid_input = f'{tc_file}.input'
        write2file(
            filename=valid_input,
            lines=textwrap.dedent('''
                nricfin first_name middle_name last_name date_of_birth premium claim_count
                1
                S122333bG trinh do cao abcd-12-34 500 2
            ''').strip(),
        )
        #endregion

        with self.assertRaises(Exception) as ec:  # ec aka. exception context
            actual_output = f'{tc_file}.out'
            insurance_policies(valid_input, actual_output)
        assert str(ec.exception) == f'd must be a date i.e. yyyy-mm-dd'
Пример #13
0
    def test_tc06a(self):
        """
        ref. https://docs.google.com/document/d/1v1FcxCLvVGZcAIKy1Q6aPCq3bevR64igyLG4O60JptE/edit#bookmark=id.avsqnj1qeba3
        """
        tc_file = get_tc_file(self)

        #region make input file
        valid_input = f'{tc_file}.input'
        write2file(
            filename=valid_input,
            lines=textwrap.dedent('''
                nricfin first_name middle_name last_name date_of_birth premium claim_count
                1
                S122333bG 0 @@ thai$ 1990-02-11 500 0
            ''').strip().replace("empty", ''),
        )
        #endregion

        with self.assertRaises(Exception) as ec:  # ec aka. exception context
            actual_output = f'{tc_file}.out'
            insurance_policies(valid_input, actual_output)
        assert str(ec.exception) == f's must be a string'
Пример #14
0
    def test_tc05b(self):
        """
        ref. https://docs.google.com/document/d/1v1FcxCLvVGZcAIKy1Q6aPCq3bevR64igyLG4O60JptE/edit#bookmark=id.4or02ub25guj
        """
        tc_file = get_tc_file(self)

        #region make input file
        valid_input = f'{tc_file}.input'
        write2file(
            filename=valid_input,
            lines=textwrap.dedent('''
                nricfin first_name middle_name last_name date_of_birth premium claim_count
                1
                empty an van nguyen 1999-01-22 500 0
            ''').strip().replace("empty", ''),
        )
        #endregion

        with self.assertRaises(Exception) as ec:  # ec aka. exception context
            actual_output = f'{tc_file}.out'
            insurance_policies(valid_input, actual_output)
        assert str(ec.exception) == f'n must have a value'
Пример #15
0
    def test_tc03_tc04(self):
        """
        ref. https://docs.google.com/document/d/1v1FcxCLvVGZcAIKy1Q6aPCq3bevR64igyLG4O60JptE/edit#bookmark=id.7r8ck1i20run
        """
        tc_file = get_tc_file(self)

        #region make input file
        valid_input = f'{tc_file}.input'
        write2file(
            filename=valid_input,
            lines=textwrap.dedent('''
                nricfin first_name middle_name last_name date_of_birth premium claim_count
                2
                S122333aG thuOnG bInh vU 2000-01-23 500 1   
                S122333aG triNH Do CAO 2000-04-23 500 2
            ''').strip(),
        )
        #endregion

        #region make expected output
        expected_output = f'{tc_file}.expected.out'
        write2file(
            filename=expected_output,
            lines=textwrap.dedent('''
                nricfin first_name middle_name last_name date_of_birth premium claim_count
                S122333aG, Thuong B. VU, 19, 1000
                S122333aG, Trinh D. CAO, 19, 1500
            ''').strip(),
        )
        #endregion

        # run testee code
        actual_output = f'{tc_file}.out'
        insurance_policies(valid_input, actual_output)

        # check for expected values
        assert filecmp.cmp(actual_output, expected_output) is True
Пример #16
0
    def test_tc01_tc02(self):
        """
        ref. https://docs.google.com/document/d/1v1FcxCLvVGZcAIKy1Q6aPCq3bevR64igyLG4O60JptE/edit#bookmark=id.4g8u3yvsoc7f
        """
        tc_file = get_tc_file(self)

        #region make input file
        valid_input = f'{tc_file}.input'
        write2file(
            filename=valid_input,
            lines=textwrap.dedent('''
                nricfin first_name middle_name last_name date_of_birth premium claim_count
                2
                S122333aG aN vaN nguyeN 1985-01-24 500 2   
                S122333aG binh thi tran 1986-01-23 500 0
            ''').strip(),
        )
        #endregion

        #region make expected output
        expected_output = f'{tc_file}.expected.out'
        write2file(
            filename=expected_output,
            lines=textwrap.dedent('''
                nricfin first_name middle_name last_name date_of_birth premium claim_count
                S122333aG, An V. NGUYEN, 34, 1500
                S122333aG, Binh T. TRAN, 33, 500
            ''').strip(),
        )
        #endregion

        # run testee code
        actual_output = f'{tc_file}.out'
        insurance_policies(valid_input, actual_output)

        # check for expected values
        assert filecmp.cmp(actual_output, expected_output) is True