def isMutant(): content = request.json usebase = 'nobase' not in content #print( content ) stats = Stats(dna=request.data) if usebase: stat = stats.getByDNA() else: print('ignoring base') stat = None if stat is None: if 'dna' not in content: stats.isMutant = False else: stats.isMutant = ADN.isMutant(content['dna']) if usebase: stats.saveStat() else: #print('already exists') stats = stat if stats.isMutant: response = app.response_class(response=json.dumps({'mutante': True}), status=200, mimetype='application/json') else: response = app.response_class(response=json.dumps({'mutante': False}), status=403, mimetype='application/json') return response
def testDiagonal2(self): data = { "dna": [ "TAGCTAGCTA", "AGCTAGCTAT", "GCTAGCTATC", "CTAGCTATCG", "TAGCTATCGA", "AGCTATCGAT", "GCTATCGATC", "CTATCGATCG", "TATCGATCGA", "ATCGATCGAT" ] } assert True == ADN.isMutant(data['dna'])
def testVertical(self): data = { "dna": [ "ATCGATCGAT", "ATCGATCGAT", "ATCGATCGAT", "ATCGATCGAT", "ATCGATCGAT", "ATCGATCGAT", "ATCGATCGAT", "ATCGATCGAT", "ATCGATCGAT", "ATCGATCGAT" ] } assert True == ADN.isMutant(data['dna'])
def testHorizontal(self): data = { "dna": [ "AAAAAAAAAA", "TTTTTTTTTT", "CCCCCCCCCC", "GGGGGGGGGG", "AAAAAAAAAA", "TTTTTTTTTT", "CCCCCCCCCC", "GGGGGGGGGG", "AAAAAAAAAA", "TTTTTTTTTT" ] } assert True == ADN.isMutant(data['dna'])
def testmissmatch(self): data = {"dna": ["AAAAAA", "AAAAA", "AAAA", "AAA", "AA", "A"]} assert False == ADN.isMutant(data['dna'])
def testNonAllowed(self): data = {"dna": ["ATzG", "CAxG", "TTcA", "AGvA", "GhCG", "TyCA"]} assert False == ADN.isMutant(data['dna'])
def testMin(self): data = {"dna": ["ATG", "CAG", "TTA", "AGA", "GCG", "TCA"]} assert False == ADN.isMutant(data['dna'])
def testEmpty(self): assert False == ADN.isMutant([])
def testNull(self): assert False == ADN.isMutant(None)
def testEnunciadoNoMutante(self): data = { "dna": ["ATGCGA", "CAGTGC", "TTATTT", "AGACGG", "GCGTCA", "TCACTG"] } assert False == ADN.isMutant(data['dna'])
def testEjemploMutante(self): data = { "dna": ["ATGCGA", "CAGTGC", "TTATGT", "AGAAGG", "CCCCTA", "TCACTG"] } assert True == ADN.isMutant(data['dna'])