def testBadUpload(self):
        "Tests missing ID"
        doc = {"idd": "123", "title": "red dress"}
        adder = Add()

        adder.add_doc(doc)
        with self.uploader(adder) as results:
            self.assert_(not results.success, "Should have failed!")
    def testSimpleUpload(self):
        "Tests simple uploader"
        doc = {"id": "123", "title": "red dress"}
        adder = Add()

        adder.add_doc(doc)
        with self.uploader(adder) as results:
            self.assert_(results.success, "Failed!")
Exemple #3
0
    def testBadUpload(self):
        "Tests missing ID"
        doc = {"idd": "123", "title": "red dress"}
        adder = Add()

        adder.add_doc(doc)
        with self.uploader(adder) as results:
            self.assert_(not results.success, "Should have failed!")
Exemple #4
0
    def testSimpleUpload(self):
        "Tests simple uploader"
        doc = {"id": "123", "title": "red dress"}
        adder = Add()

        adder.add_doc(doc)
        with self.uploader(adder) as results:
            self.assert_(results.success, "Failed!")
Exemple #5
0
 def testUploadUrl(self):
     noops = [Add(), Update(), Delete()]
     for noop, ep in zip(noops, ['add', 'update', 'delete']):
         res = self.uploader(noop)
         self.assertEquals(res._build_url(),
             "https://upload-dev.search.blackbird.am/%s?" % ep +
             "user="******"*****@*****.**") + "&token=123&company_id=blackbird&env=dev&"\
             "instance_name=client_test")
company = "yoursite"
env = "dev"
instance = "myinstance"
username = "******"

# Authtoken can be found on the Admin API dashboard
authtoken = "1234567890ABCDEF"

# Instantiate an uploader engine
engine = Uploader(company, env, instance,
    username=username,
    authtoken=authtoken
)

# To add documents
add = Add()
add += {"id": "123", "title": "red dress"}
add += {"id": "456", "title": "blue shoes"}

with engine(add) as results:
    print(results.msg)

# To delete documents
delete = Delete()
delete += {"id": "123"}

# Can also use straight ids
delete += "456"

with engine(delete) as results:
    print(results.msg)