def test_valid_mutant_dna_vertical_diagonal(self):
        '''Ensures the MutantChecker algorithm returns true when a valid mutant
        dna is checked.'''

        checker = MutantChecker()
        self.assertTrue(
            checker.isMutant(self.valid_mutant_dna_vertical_diagonal))
    def test_valid_mutant_dna_double_horizontal(self):
        '''Ensures the MutantChecker algorithm returns true when a valid mutant
        dna is checked.'''

        checker = MutantChecker()
        self.assertTrue(
            checker.isMutant(self.valid_mutant_dna_double_horizontal))
def check_mutant():
    post_data = request.get_json()
    dna = post_data.get('dna')
    try:
        checker = MutantChecker()
        isMutant = checker.isMutant(dna)
        req = MutantRequest(dna, isMutant)
        if not mongo.db.mutant.find_one(req.to_json()):
            mongo.db.mutant.insert(req.to_json())
        if isMutant:
            return jsonify({'isMutant': True}), 200
        else:
            return jsonify({'isMutant': False}), 403
    except ValueError as e:
        return jsonify({'error_message': str(e)}), 400
    def test_check_invalid_mutant_one_match_only_diagonal(self):
        '''Ensures the MutantChecker algorithm returns false when a DNA containing only one mutant chain is checked.'''

        checker = MutantChecker()
        self.assertFalse(
            checker.isMutant(self.invalid_mutant_dna_single_diagonal))
    def test_invalid_size_dna_matrix(self):
        '''Ensures the MutantChecker algorithm raises an exception when the matrix is
        not square.'''

        checker = MutantChecker()
        self.assertRaises(ValueError, checker.isMutant, self.invalid_size_dna)
    def test_invalid_chars_dna(self):
        '''Ensures the MutantChecker algorithm raises an exception when invalid
        chars are used in the DNA matrix.'''

        checker = MutantChecker()
        self.assertRaises(ValueError, checker.isMutant, self.invalid_chars_dna)
    def test_valid_human_dna(self):
        '''Ensures the MutantChecker algorithm returns false when a valid human
        (not mutant) dna is checked'''

        checker = MutantChecker()
        self.assertFalse(checker.isMutant(self.valid_human_dna))