def test_add(self): with vcr.use_cassette("fixtures/ac.cnstrc.com/add-success.yaml"): constructor = ConstructorIO(**HTTPS_ARGS) resp = constructor.add( item_name="boinkamoinka", autocomplete_section="Search Suggestions" ) assert resp is True
def test_add(self): with vcr.use_cassette("fixtures/ac.cnstrc.com/add-success.yaml"): constructor = ConstructorIO(api_token="apiToken", autocomplete_key="autocompleteKey", protocol="http", host="ac.cnstrc.com") resp = constructor.add(item_name="boinkamoinka", autocomplete_section="Search Suggestions") assert resp == True
def test_add_remove_metadata(self): with my_vcr.use_cassette( "fixtures/ac.cnstrc.com/add-metadata-success.yaml"): constructor = ConstructorIO(**HTTPS_ARGS) resp = constructor.add(item_name="Metadata Example", autocomplete_section="Products", url="https://metadata.example", metadata={"this_key": "this_value"}) assert resp is True resp = constructor.remove(item_name="Metadata Example", autocomplete_section="Products") assert resp is True
def test_add(self): with vcr.use_cassette("fixtures/ac.cnstrc.com/add-success.yaml"): constructor = ConstructorIO( api_token = "apiToken", autocomplete_key = "autocompleteKey", protocol = "http", host = "ac.cnstrc.com" ) resp = constructor.add( item_name = "boinkamoinka", autocomplete_section = "Search Suggestions" ) assert resp == True
def test_modify(self): with my_vcr.use_cassette("fixtures/ac.cnstrc.com/modify-success.yaml"): constructor = ConstructorIO(**HTTPS_ARGS) resp = constructor.add(item_name="Stanley_Steamer", autocomplete_section="Search Suggestions") assert resp is True resp = constructor.modify( item_name="Stanley_Steamer", new_item_name="Newer_Stanley_Steamer", suggested_score=100, autocomplete_section="Search Suggestions") assert resp is True # clean things up so that when we re-run the test we don't # get an error when we add it resp = constructor.remove( item_name="Newer_Stanley_Steamer", autocomplete_section="Search Suggestions") assert resp is True
api_token = raw_input("enter api token (enter q to quit) : ") if api_token == "q": print "toodles!" sys.exit(0) autocomplete_key = raw_input("enter autocomplete key (enter q to quit) : ") if autocomplete_key == "q": print "toodles!" sys.exit(0) autocomplete_section = raw_input( "enter autocomplete section (enter q to quit) : ") if autocomplete_section == "q": print "toodles!" sys.exit(0) constructor = ConstructorIO(api_token=api_token, autocomplete_key=autocomplete_key) with open("example.csv") as csv_file: example_csv = csv.DictReader(csv_file) for row in example_csv: print "row: ", row print "sending this row over to your Constructor.io account..." constructor.add(row["term"], autocomplete_section, score=row["score"]) print "let's go see the terms you added!" webbrowser_resp = raw_input("Go to constructor.io right now? (y/n) (n)") if webbrowser_resp == "y": print "ok! let's go!" webbrowser.open("http://constructor.io/dashboard") else: print "ok, then just go to constructor.io/dashboard some other time"
def test_add(self): with my_vcr.use_cassette("fixtures/ac.cnstrc.com/add-success.yaml"): constructor = ConstructorIO(**HTTPS_ARGS) resp = constructor.add(item_name="boinkamoinka", autocomplete_section="Search Suggestions") assert resp is True
if __name__ == "__main__": api_token = raw_input("enter api token (enter q to quit) : ") if api_token == "q": print "toodles!" sys.exit(0) autocomplete_key = raw_input("enter autocomplete key (enter q to quit) : ") if autocomplete_key == "q": print "toodles!" sys.exit(0) autocomplete_section = raw_input("enter autocomplete section (enter q to quit) : ") if autocomplete_section == "q": print "toodles!" sys.exit(0) constructor = ConstructorIO(api_token, autocomplete_key) # is that right? with open("example.csv") as csv_file: example_csv = csv.DictReader(csv_file) for row in example_csv: print "row: ", row print "sending this row over to your Constructor.io account..." constructor.add(row["term"], autocomplete_section, score=row["score"]) print "let's go see the terms you added!" webbrowser_resp = raw_input("Go to constructor.io right now? (y/n) (n)") if webbrowser_resp == "y": print "ok! let's go!" webbrowser.open("http://constructor.io/dashboard") else: print "ok, then just go to constructor.io/dashboard some other time"