Esempio n. 1
0
class TestClientCompareApi(unittest.TestCase):
    def setUp(self):
        self.compareApi = CompareApi(testConfiguration.client)

    def testCompare(self):
        resultMetric = self.compareApi.compare(testConfiguration.RETINA_NAME,
                                               inputJSONarray)
        self.assertGreater(resultMetric.cosineSimilarity, 0.1)
        self.assertGreater(resultMetric.euclideanDistance, 0.1)
        self.assertGreater(resultMetric.jaccardDistance, 0.1)
        self.assertGreater(resultMetric.weightedScoring, 0.1)
        self.assertGreater(resultMetric.sizeRight, 10)
        self.assertGreater(resultMetric.sizeLeft, 10)
        self.assertGreater(resultMetric.overlappingLeftRight, 0.1)
        self.assertGreater(resultMetric.overlappingAll, 10)
        self.assertGreater(resultMetric.overlappingRightLeft, 0.1)

    def testCompareBulk(self):
        resultMetricList = self.compareApi.compareBulk(
            testConfiguration.RETINA_NAME, bulkJSONarray)
        self.assertEqual(len(resultMetricList), 2)
        for resultMetric in resultMetricList:
            self.assertGreater(resultMetric.cosineSimilarity, 0.1)
            self.assertGreater(resultMetric.euclideanDistance, 0.1)
            self.assertGreater(resultMetric.jaccardDistance, 0.1)
            self.assertGreater(resultMetric.weightedScoring, 0.1)
            self.assertGreater(resultMetric.sizeRight, 10)
            self.assertGreater(resultMetric.sizeLeft, 10)
            self.assertGreater(resultMetric.overlappingLeftRight, 0.1)
            self.assertGreater(resultMetric.overlappingAll, 10)
            self.assertGreater(resultMetric.overlappingRightLeft, 0.1)

    def testException(self):
        # testing using only one input element in the array
        expectedException = False
        try:
            self.compareApi.compare(testConfiguration.RETINA_NAME,
                                    oneTermInputJSONarray)
        except Exception:
            expectedException = True
        self.assertTrue(expectedException)

        # testing JSON parse exception in the input
        expectedException = False
        try:
            self.compareApi.compare(testConfiguration.RETINA_NAME,
                                    syntaxErrorJSONarray)
        except Exception:
            expectedException = True
        self.assertTrue(expectedException)
Esempio n. 2
0
class TestClientCompareApi(unittest.TestCase):
 

    def setUp(self):
        self.compareApi = CompareApi(testConfiguration.client)

    def testCompare(self):
        resultMetric = self.compareApi.compare(testConfiguration.RETINA_NAME, inputJSONarray)
        self.assertGreater(resultMetric.cosineSimilarity, 0.1)
        self.assertGreater(resultMetric.euclideanDistance, 0.1)
        self.assertGreater(resultMetric.jaccardDistance, 0.1)
        self.assertGreater(resultMetric.weightedScoring, 0.1)
        self.assertGreater(resultMetric.sizeRight, 10)
        self.assertGreater(resultMetric.sizeLeft, 10)
        self.assertGreater(resultMetric.overlappingLeftRight, 0.1)
        self.assertGreater(resultMetric.overlappingAll, 10)
        self.assertGreater(resultMetric.overlappingRightLeft, 0.1)

    def testCompareBulk(self):
        resultMetricList = self.compareApi.compareBulk(testConfiguration.RETINA_NAME, bulkJSONarray)
        self.assertEqual(len(resultMetricList), 2)
        for resultMetric in resultMetricList:
            self.assertGreater(resultMetric.cosineSimilarity, 0.1)
            self.assertGreater(resultMetric.euclideanDistance, 0.1)
            self.assertGreater(resultMetric.jaccardDistance, 0.1)
            self.assertGreater(resultMetric.weightedScoring, 0.1)
            self.assertGreater(resultMetric.sizeRight, 10)
            self.assertGreater(resultMetric.sizeLeft, 10)
            self.assertGreater(resultMetric.overlappingLeftRight, 0.1)
            self.assertGreater(resultMetric.overlappingAll, 10)
            self.assertGreater(resultMetric.overlappingRightLeft, 0.1)
        

    def testException(self):
        # testing using only one input element in the array
        expectedException = False
        try:
            self.compareApi.compare(testConfiguration.RETINA_NAME, oneTermInputJSONarray)
        except Exception:
            expectedException = True
        self.assertTrue(expectedException)
        
        # testing JSON parse exception in the input
        expectedException = False
        try:
            self.compareApi.compare(testConfiguration.RETINA_NAME, syntaxErrorJSONarray)
        except Exception:
            expectedException = True
        self.assertTrue(expectedException)
Esempio n. 3
0
 def setUp(self):
     self.compareApi = CompareApi(testConfiguration.client)
Esempio n. 4
0
 def setUp(self):
     self.compareApi = CompareApi(testConfiguration.client)