Beispiel #1
0
    def test_seisPorSeis_letraInvalida(self):
        adn = ["actggt", "ggcact", "catrta", "ttatcg", "catcaa", "aggatc"]

        with self.assertRaises(ADNException) as cm:
            esMutante(adn)

        the_exception = cm.exception
        self.assertEqual(str(the_exception), "Letra inválida: «r»")
Beispiel #2
0
    def test_adn_inconsistente(self):
        adn = ["atct", "gattt", "acga", "aatc"]

        with self.assertRaises(ADNException) as cm:
            esMutante(adn)

        the_exception = cm.exception
        self.assertEqual(str(the_exception), "Secuencia de dimensiones inválidas (esperaba 4 y la 1-ésima fila mide 5)")
Beispiel #3
0
    def test_adn_chico(self):
        adn = ["atc", "gat", "cga"]

        with self.assertRaises(ADNException) as cm:
            esMutante(adn)

        the_exception = cm.exception
        self.assertEqual(str(the_exception), "Secuencia de ADN demasiado chica (N = 3)")
Beispiel #4
0
def post_mutant():
    dna = request.json['dna']
    adn_db = ADNDb()

    try:
        es_mutante = None

        if adn_db.existe_adn(dna):
            es_mutante = bool(adn_db.get_test(dna)['esMutante'])
        else:
            es_mutante = esMutante(dna)
            adn_db.guardar_test(dna, es_mutante)

        return jsonify({"esMutante" : es_mutante}), (200 if es_mutante else 403)
    except ADNException as adn_ex:
        return jsonify({"error_text" : str(adn_ex)}), 400
    except ClientError as ce:
        return jsonify({"error_text" : ce.response['Error']['Message']}), 500
    except Exception as ex:
        return jsonify({"error_text" : str(ex)}), 500
Beispiel #5
0
    def test_ejemplo1_noMutante(self):
        adn = ["atgcga", "cagtgc", "ttattt", "agacgg", "gcgtca", "tcactg"]

        self.assertFalse(esMutante(adn))
Beispiel #6
0
    def test_cuatroPorCuatro_mutante(self):
        adn = ["atca", "tcaa", "caat", "gatc"]

        self.assertFalse(esMutante(adn))
Beispiel #7
0
    def test_cincoPorCinco_no_mutante(self):
        adn = ["atcag", "tcaat", "caatg", "gatct", "cgcct"]

        self.assertFalse(esMutante(adn))
Beispiel #8
0
    def test_seisPorSeis_mayusculasValen(self):
        adn = ["actgag", "gGagtt", "attacc", "agcAca", "AATGCC", "actact"]

        self.assertTrue(esMutante(adn))
Beispiel #9
0
    def test_seisPorSeis_dobleHorizontal(self):
        adn = ["aaaaaa", "cagtgc", "ttctat", "agaagg", "ctccta", "tcactg"]

        self.assertFalse(esMutante(adn))
Beispiel #10
0
    def test_seisPorSeis_dosDiagonalesDerIzq_bis(self):
        adn = ["acgtta", "tactcg", "acttct", "ttacgg", "accgga", "gctata"]

        self.assertTrue(esMutante(adn))
Beispiel #11
0
    def test_seisPorSeis_dosDiagonalesDerIzq(self):
        adn = ["actggt", "ggcact", "catata", "ttatcg", "catcaa", "aggatc"]

        self.assertTrue(esMutante(adn))
Beispiel #12
0
    def test_seisPorSeis_dosDiagonalesIzqDer(self):
        adn = ["actcga", "gatagc", "gtatct", "actaag", "tactcg", "cagatt"]

        self.assertTrue(esMutante(adn))
Beispiel #13
0
    def test_seisPorSeis_dosVerticales_bis(self):
        adn = ["actgcg", "ggagct", "attacc", "agcaca", "aatgac", "actatt"]

        self.assertTrue(esMutante(adn))
Beispiel #14
0
    def test_seisPorSeis_dosHorizontales_bis(self):
        adn = ["aaaaga", "cagtgc", "ttctat", "agaagg", "tacccc", "tcactg"]

        self.assertTrue(esMutante(adn))
Beispiel #15
0
    def test_ejemplo2_mutante(self):
        adn = ["atgcga", "cagtgc", "ttatgt", "agaagg", "ccccta", "tcactg"]

        self.assertTrue(esMutante(adn))