def testGetClosestStrings(self): """ Type check """ cept = Cept() response = cept.getBitmap("snake") result = cept.getClosestStrings(response['positions']) self.assertTrue(type(result), 'list')
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']))
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")
def testExceptionIfAPIKeyNotPresent(self, mockOS): with self.assertRaises(Exception) as e: cept = Cept() self.assertIn("Missing API key.", e.exception)
def testAPIKeyPresent(self): with patch.dict('os.environ', {'CEPT_API_KEY': 'apikey123'}): cept = Cept()
def __init__(self): self.bitmap = None self.cept = Cept()
def __init__(self): self.bitmap = None self.sparsity = None self.width = None self.height = None self.cept = Cept()