コード例 #1
0
 def test_analize_should_return_true(self, mock_dnaanalizer):
     mock_dnaanalizer.save_dna.return_value = True
     mock_dnaanalizer.analyze_dna.return_value = 1
     result = DNAAnalizer(
         mock_dnaanalizer,
         ["CTGCCA", "CCCCTG", "CTCCTG", "CCTCCG"]).analize()
     self.assertEqual(True, result)
コード例 #2
0
def is_mutant():
    try:
        if not 'dna' in request.json:
            json.dumps({'success': True}), 403, {
                'ContentType': 'application/json'
            }

        analizer = DNAAnalizer(MutantsAnalizer, request.json["dna"])
        is_mutant = analizer.analize()

        if is_mutant:
            return json.dumps(None), 200, {'ContentType': 'application/json'}
        return json.dumps(None), 403, {'ContentType': 'application/json'}
    except Exception as e:
        return json.dumps(e.__str__()), 403, {
            'ContentType': 'application/json'
        }
コード例 #3
0
 def test_analize_should_return_false_when_none_dna_found(
         self, mock_dnaanalizer):
     mock_dnaanalizer.save_dna.return_value = True
     mock_dnaanalizer.analyze_dna.return_value = 0
     result = DNAAnalizer(
         mock_dnaanalizer,
         ["CTGCCA", "CCCCTG", "CTCCTG", "CCTCCG"]).analize()
     self.assertEqual(False, result)
コード例 #4
0
 def test_find_oblique_should_return_0(self, mock_dnaanalizer):
     result = DNAAnalizer(MutantsAnalizer, []).find_oblique(
         ["ATGCCA", "CTCGTG", "CTGCTG", "CCTCTG"])
     self.assertEqual(0, result)
コード例 #5
0
 def test_find_vertical_should_return_1(self, mock_dnaanalizer):
     result = DNAAnalizer(MutantsAnalizer, []).find_vertical(
         ["CTGCCA", "CTCGTG", "CTGCTG", "CCTCTG"])
     self.assertEqual(1, result)
コード例 #6
0
 def test_find_horizontal_should_return_0(self, mock_dnaanalizer):
     result = DNAAnalizer(MutantsAnalizer, []).find_horizontal(["CCTCTG"])
     self.assertEqual(0, result)