def test_get_key_api(self, client): gen_key = KeyHelper._create_key() key_service.save(gen_key) response = client.get('/key') self.assertEqual(response.status_code, status.HTTP_200_OK) decoded_json = json.loads(response.data.decode()) self.assertEqual(len(decoded_json), 1) self.assertEqual(decoded_json[0], gen_key.to_json())
def test_get_all(self): gen_key = KeyHelper._create_key() gen_key.save() retrieved_gen_key = Key.get(gen_key.id) self.assertIn(retrieved_gen_key, Key.all()) Key.delete(gen_key.id) self.assertNotIn(retrieved_gen_key, Key.all())
def test_get_all(self): gen_key = KeyHelper._create_key() key_service.save(gen_key) retrieved_gen_key = key_service.get(gen_key.id) self.assertIn(retrieved_gen_key, key_service.all()) key_service.delete(gen_key.id) self.assertNotIn(retrieved_gen_key, key_service.all())
def test_get_and_delete(self): gen_key = KeyHelper._create_key() retrieved_gen_key = Key.get(gen_key.id) self.assertIsNone(retrieved_gen_key) gen_key.save() reretrieved_gen_key = Key.get(gen_key.id) self.assertEqual(reretrieved_gen_key, gen_key) Key.delete(gen_key.id) retrieved_no_gen_key = Key.get(gen_key.id) self.assertIsNone(retrieved_no_gen_key)
def test_get_and_delete(self): gen_key = KeyHelper._create_key() retrieved_gen_key = key_service.get(gen_key.id) self.assertIsNone(retrieved_gen_key) key_service.save(gen_key) reretrieved_gen_key = key_service.get(gen_key.id) self.assertEqual(reretrieved_gen_key, gen_key) key_service.delete(gen_key.id) retrieved_no_gen_key = key_service.get(gen_key.id) self.assertIsNone(retrieved_no_gen_key)