Esempio n. 1
0
    def test_get_note_img_invalid_note(self):

        # create note
        collection_name = "col_name"
        StorageServer.add_collection(self.__account_id, collection_name, callback=self.stop)
        response = self.wait()
        self.assertEqual(StorageResponse.OK, response)

        StorageServer.get_note_image(self.__account_id, collection_name, "dummy", callback=self.stop)
        response = self.wait()
        self.assertTrue(response is None)

        # clean up
        StorageServer.remove_collection(self.__account_id, collection_name, callback=self.stop)
        self.wait()
Esempio n. 2
0
    def test_get_note_img_a_note_with_no_img(self):

        collection_name = "col_name"
        note_name = "noteName"
        note_file = open("../test_resources/note.xml")
        StorageServer.add_note_to_collection(
            self.__account_id, collection_name, note_name, note_file, callback=self.stop
        )
        response = self.wait()
        self.assertEqual(StorageResponse.OK, response)

        StorageServer.get_note_image(self.__account_id, collection_name, note_name, callback=self.stop)
        response = self.wait()
        self.assertTrue(response is None)

        # clean up
        StorageServer.remove_collection(self.__account_id, collection_name, callback=self.stop)
        self.wait()
Esempio n. 3
0
    def test_get_note_img(self):

        # add image
        img_file = open("../test_resources/note_img.jpg")
        collection_name = "dummyCol"
        note_name = "dummyNote"
        StorageServer.add_image_to_note(self.__account_id, collection_name, note_name, img_file, callback=self.stop)
        response = self.wait()
        self.assertEqual(StorageResponse.OK, response)

        # get image

        StorageServer.get_note_image(self.__account_id, collection_name, note_name, callback=self.stop)
        response = self.wait()
        self.assertTrue(response is not None)

        # clean up
        StorageServer.remove_collection(self.__account_id, collection_name, callback=self.stop)
        self.wait()
Esempio n. 4
0
    def test_update_note_image(self):

        collection_name = str(uuid.uuid4())
        subscriber_list = [self.__subscriber_id]
        sharing_secret, subscribers_collections =\
        self.__create_sharing_record(subscriber_list, collection_name)


        joker = JokerHelper.get_instance()
        joker.get_sharing_space_server(sharing_secret, callback=self.stop)
        server_adrs = self.wait(timeout=10000)
        self.assertIn(server_adrs, Properties.sharing_space_servers)

        img_file = open('../test_resources/note_img.jpg')
        note_name = str(uuid.uuid4())
        joker.update_note_image(server_adrs, sharing_secret, self.__account_id,
            collection_name, note_name, img_file, callback=self.stop)
        response = self.wait()
        self.assertEqual(StorageResponse.OK, response)

        #wait for a while
        self.__wait(10)

        #try to retreive the note
        StorageServer.get_note_image(self.__account_id,
            collection_name, note_name, callback=self.stop)
        response = self.wait()
        self.assertTrue(response is not None)

        #cleanup
        SharingController.remove_sharing_record_by_secret(sharing_secret, callback =self.stop)
        self.wait()
        StorageServer.remove_collection(self.__account_id, collection_name,
            callback=self.stop)
        for subscriber_id in subscribers_collections:
            subscriber_collection = subscribers_collections[subscriber_id]
            StorageServer.remove_collection(subscriber_id, subscriber_collection,
               callback=self.stop)
            self.wait()
Esempio n. 5
0
    def test_get_note_img_invalid_collection(self):

        StorageServer.get_note_image(self.__account_id, "dummy", "dummy", callback=self.stop)
        response = self.wait()
        self.assertTrue(response is None)