def test_create_chunks(self):
     filename = 'images/cat.png'
     blob_size = os.stat(filename).st_size  # File size in bytes
     chunk_count = 10
     chunk_size = math.ceil(blob_size / chunk_count)
     blob_id = binary_data_pb2.BlobId(id=42)
     chunks = device.create_chunks(filename, chunk_count, chunk_size,
                                   blob_id)
     self.assertEqual(len(chunks), chunk_count)
     sample_chunk = chunks[2]
     sample_payload = sample_chunk.payload
     self.assertEqual(sample_chunk.blob_id, blob_id)
Ejemplo n.º 2
0
 def setUpClass(cls):
     cls.id = 42
     cls.payload = b"bag of bits"
     cls.blob_id = binary_data_pb2.BlobId(id=cls.id)
     cls.index = 2
     cls.test_path = "tests/"
     cls.chunk = binary_data_pb2.Chunk(blob_id=cls.blob_id,
                                       index=cls.index,
                                       payload=cls.payload)
     cls.chunk1 = binary_data_pb2.Chunk(blob_id=cls.blob_id,
                                        index=cls.index + 1,
                                        payload=cls.payload)
Ejemplo n.º 3
0
 def setUpClass(cls):
     cls.server_size = 100
     cls.blob_spec = binary_data_pb2.BlobSpec(size=1, chunk_count=1)
     cls.context = None
     cls.default_filename = 'tests/test_empty.json'
     cls.server = FileServerServicer(cls.server_size, cls.default_filename)
     cls.blob_id = binary_data_pb2.BlobId(id=42)
     cls.chunk_index = 0
     cls.payload = b"bag of bits"
     cls.chunk_spec = binary_data_pb2.ChunkSpec(blob_id=cls.blob_id,
                                                index=cls.chunk_index)
     cls.chunk = binary_data_pb2.Chunk(blob_id=cls.blob_id,
                                       index=cls.chunk_index,
                                       payload=cls.payload)
 def setUpClass(cls):
     cls.server = get_grpc_server()
     cls.server_size = 1500000
     cls.blob_spec = binary_data_pb2.BlobSpec(size=2, chunk_count=1)
     cls.context = None
     cls.device_filename = 'tests/test_store_blob_info.json'
     cls.default_filename = 'tests/test_empty.json'
     start_file_server(cls.server, cls.server_size, cls.default_filename)
     cls.stub = get_file_server_stub()
     cls.servicer = UploadServicer(cls.stub, cls.device_filename)
     cls.blob_id = binary_data_pb2.BlobId(id=42)
     cls.chunk_index = 0
     cls.payload = b"bag of bits"
     cls.chunk = binary_data_pb2.Chunk(blob_id=cls.blob_id,
                                       index=cls.chunk_index,
                                       payload=cls.payload)
    def setUpClass(cls):
        cls.blob_spec = binary_data_pb2.BlobSpec(size=1, chunk_count=1)
        cls.default_filename = 'tests/test_empty.json'
        cls.blob_id = binary_data_pb2.BlobId(id=42)
        cls.valid_until = file_server.get_expiration_time()
        cls.blob_info = binary_data_pb2.BlobInfo(id=cls.blob_id,
                                                 valid_until=cls.valid_until,
                                                 spec=cls.blob_spec)

        cls.server = get_grpc_server()
        cls.server_size = 1500000
        cls.default_filename = 'tests/test_empty.json'
        cls.device_filename = 'tests/test_store_blob_info.json'
        start_file_server(cls.server, cls.server_size, cls.default_filename)
        cls.stub = get_file_server_stub()
        cls.upload_servicer = UploadServicer(cls.stub, cls.device_filename)
        cls.download_servicer = DownloadServicer(get_file_server_stub(),
                                                 cls.device_filename)
Ejemplo n.º 6
0
 def test_Delete_on_non_existant_blob(self):
     blob_id = binary_data_pb2.BlobId(id=23892)
     error = self.server.Delete(blob_id, self.context)
     self.assertFalse(error.has_occured)
 def test_DeleteBlob_non_existant_id(self):
     blob_id = binary_data_pb2.BlobId(id=38302)
     response = self.servicer.DeleteBlob(blob_id, self.context)
     self.assertFalse(response.error.has_occured)
 def test_test_GetBlobInfo_of_non_existant_blob(self):
     blob_id = binary_data_pb2.BlobId(id=-1)
     response = self.download_servicer.GetBlobInfo(blob_id, self.context)
     self.assertTrue(response.error.has_occured)
 def test_GetAverageBrightness_on_non_existant_blob(self):
     blob_id = binary_data_pb2.BlobId(id=-1)
     response = self.servicer.GetAverageBrightness(blob_id, self.context)
     self.assertTrue(response.error.has_occured)