Ejemplo n.º 1
0
    def testGetClosestStrings(self):
        """ Type check """
        cept = Cept()
        response = cept.getBitmap("snake")

        result = cept.getClosestStrings(response['positions'])
        self.assertTrue(type(result), 'list')
Ejemplo n.º 2
0
    def testSamePositions(self):
        """ Test that the SDR we get from the server hasn't changed,
          using default settings
     """

        cept = Cept()
        httpResponse = cept.getBitmap("fox")

        self.assertEqual(set(httpResponse['positions']),
                         set(foxHardCodedResponse['positions']))
Ejemplo n.º 3
0
    def testGetBitmap(self):
        """ Type check what we get back from the cept object """
        cept = Cept()
        response = cept.getBitmap("fox")

        self.assertLessEqual(set(("width", "positions", "sparsity", "height")),
                             set(response))

        self.assertIsInstance(response['positions'], list,
                              "Positions field is not a list")
        self.assertIsInstance(response['sparsity'], float,
                              "Sparsity field is not a list")
        self.assertIsInstance(response['width'], int,
                              "Width field is not an int")
        self.assertIsInstance(response['height'], int,
                              "Height field is not an int")
Ejemplo n.º 4
0
 def testExceptionIfAPIKeyNotPresent(self, mockOS):
   with self.assertRaises(Exception) as e:
     cept = Cept()
   self.assertIn("Missing API key.", e.exception)
Ejemplo n.º 5
0
 def testAPIKeyPresent(self):
   with patch.dict('os.environ', {'CEPT_API_KEY': 'apikey123'}):
       cept = Cept()
Ejemplo n.º 6
0
 def __init__(self):
     self.bitmap = None
     self.cept = Cept()
Ejemplo n.º 7
0
 def __init__(self):
     self.bitmap = None
     self.sparsity = None
     self.width = None
     self.height = None
     self.cept = Cept()