How to use get_links method in Kiwi

Best Python code snippet using Kiwi_python

test_data.py

Source:test_data.py Github

copy

Full Screen

...143 assert d1.links == {d2.identity, d3.identity}144 assert d2.links == {d1.identity}145 assert d3.links == {d1.identity}146 # Test the get_links method.147 print "Testing Data.get_links()..."148 assert d1.get_links(d1.data_type) == set()149 assert d1.get_links(d1.data_type, d1.resource_type) == set()150 assert d1.get_links(d2.data_type) == {d2.identity}151 assert d1.get_links(d2.data_type, d2.information_type) == {d2.identity}152 assert d1.get_links(d3.data_type) == {d3.identity}153 assert d1.get_links(d3.data_type, d3.vulnerability_type) == {d3.identity}154 assert d2.get_links(d2.data_type) == set()155 assert d2.get_links(d2.data_type, d2.information_type) == set()156 assert d2.get_links(d1.data_type) == {d1.identity}157 assert d2.get_links(d1.data_type, d1.resource_type) == {d1.identity}158 assert d2.get_links(d3.data_type) == set()159 assert d2.get_links(d3.data_type, d3.vulnerability_type) == set()160 assert d3.get_links(d3.data_type) == set()161 assert d3.get_links(d3.data_type, d3.vulnerability_type) == set()162 assert d3.get_links(d1.data_type) == {d1.identity}163 assert d3.get_links(d1.data_type, d1.resource_type) == {d1.identity}164 assert d3.get_links(d2.data_type) == set()165 assert d3.get_links(d2.data_type, d2.information_type) == set()166 # Test the linked_data property.167 # There should be no accesses to the database since all data is local.168 print "Testing Data.linked_data..."169 assert {x.identity for x in d1.linked_data} == {d2.identity, d3.identity}170 assert {x.identity for x in d2.linked_data} == {d1.identity}171 assert {x.identity for x in d3.linked_data} == {d1.identity}172 # Test the get_linked_data() method.173 # There should be no accesses to the database since all data is local.174 print "Testing Data.get_linked_data()..."175 assert {x.identity for x in d1.find_linked_data(d1.data_type)} == set()176 assert {x.identity for x in d1.find_linked_data(d1.data_type, d1.resource_type)} == set()177 assert {x.identity for x in d1.find_linked_data(d2.data_type)} == {d2.identity}178 assert {x.identity for x in d1.find_linked_data(d2.data_type, d2.information_type)} == {d2.identity}179 assert {x.identity for x in d1.find_linked_data(d3.data_type)} == {d3.identity}180 assert {x.identity for x in d1.find_linked_data(d3.data_type, d3.vulnerability_type)} == {d3.identity}181 assert {x.identity for x in d2.find_linked_data(d2.data_type)} == set()182 assert {x.identity for x in d2.find_linked_data(d2.data_type, d2.information_type)} == set()183 assert {x.identity for x in d2.find_linked_data(d1.data_type)} == {d1.identity}184 assert {x.identity for x in d2.find_linked_data(d1.data_type, d1.resource_type)} == {d1.identity}185 assert {x.identity for x in d2.find_linked_data(d3.data_type)} == set()186 assert {x.identity for x in d2.find_linked_data(d3.data_type, d3.vulnerability_type)} == set()187 assert {x.identity for x in d3.find_linked_data(d3.data_type)} == set()188 assert {x.identity for x in d3.find_linked_data(d3.data_type, d3.vulnerability_type)} == set()189 assert {x.identity for x in d3.find_linked_data(d1.data_type)} == {d1.identity}190 assert {x.identity for x in d3.find_linked_data(d1.data_type, d1.resource_type)} == {d1.identity}191 assert {x.identity for x in d3.find_linked_data(d2.data_type)} == set()192 assert {x.identity for x in d3.find_linked_data(d2.data_type, d2.information_type)} == set()193 # Test the associated_* properties.194 # There should be no accesses to the database since all data is local.195 print "Testing Data.associated_*..."196 assert {x.identity for x in d1.associated_resources} == set()197 assert {x.identity for x in d1.associated_informations} == {d2.identity}198 assert {x.identity for x in d1.associated_vulnerabilities} == {d3.identity}199 assert {x.identity for x in d2.associated_informations} == set()200 assert {x.identity for x in d2.associated_resources} == {d1.identity}201 assert {x.identity for x in d2.associated_vulnerabilities} == set()202 assert {x.identity for x in d3.associated_vulnerabilities} == set()203 assert {x.identity for x in d3.associated_resources} == {d1.identity}204 assert {x.identity for x in d3.associated_informations} == set()205 # Test the get_associated_*_by_category() methods.206 # There should be no accesses to the database since all data is local.207 print "Testing Data.get_associated_*_by_category()..."208 assert {x.identity for x in d1.get_associated_resources_by_category(d1.resource_type)} == set()209 assert {x.identity for x in d1.get_associated_informations_by_category(d2.information_type)} == {d2.identity}210 assert {x.identity for x in d1.get_associated_vulnerabilities_by_category(d3.vulnerability_type)} == {d3.identity}211 assert {x.identity for x in d2.get_associated_informations_by_category(d2.information_type)} == set()212 assert {x.identity for x in d2.get_associated_resources_by_category(d1.resource_type)} == {d1.identity}213 assert {x.identity for x in d2.get_associated_vulnerabilities_by_category(d3.vulnerability_type)} == set()214 assert {x.identity for x in d3.get_associated_vulnerabilities_by_category(d3.vulnerability_type)} == set()215 assert {x.identity for x in d3.get_associated_resources_by_category(d1.resource_type)} == {d1.identity}216 assert {x.identity for x in d3.get_associated_informations_by_category(d2.information_type)} == set()217 # Test TempDataStorage.on_finish().218 print "Testing LocalDataCache.on_finish() on ideal conditions..."219 result = LocalDataCache.on_finish([d2, d3], d1)220 assert set(result) == set([d1, d2, d3])221 d1.validate_link_minimums()222 d2.validate_link_minimums()223 d3.validate_link_minimums()224 assert d1.links == {d2.identity, d3.identity}225 assert d2.links == {d1.identity}226 assert d3.links == {d1.identity}227 assert d1.get_links(d1.data_type) == set()228 assert d1.get_links(d1.data_type, d1.resource_type) == set()229 assert d1.get_links(d2.data_type) == {d2.identity}230 assert d1.get_links(d2.data_type, d2.information_type) == {d2.identity}231 assert d1.get_links(d3.data_type) == {d3.identity}232 assert d1.get_links(d3.data_type, d3.vulnerability_type) == {d3.identity}233 assert d2.get_links(d2.data_type) == set()234 assert d2.get_links(d2.data_type, d2.information_type) == set()235 assert d2.get_links(d1.data_type) == {d1.identity}236 assert d2.get_links(d1.data_type, d1.resource_type) == {d1.identity}237 assert d2.get_links(d3.data_type) == set()238 assert d2.get_links(d3.data_type, d3.vulnerability_type) == set()239 assert d3.get_links(d3.data_type) == set()240 assert d3.get_links(d3.data_type, d3.vulnerability_type) == set()241 assert d3.get_links(d1.data_type) == {d1.identity}242 assert d3.get_links(d1.data_type, d1.resource_type) == {d1.identity}243 assert d3.get_links(d2.data_type) == set()244 assert d3.get_links(d2.data_type, d2.information_type) == set()245 # XXX TODO: more tests!!!246# Run all tests from the command line.247if __name__ == "__main__":248 test_data_types_have_id()...

Full Screen

Full Screen

cache_tester.py

Source:cache_tester.py Github

copy

Full Screen

1#tests the caching2import sys3import time4from os import path5#adds the repo to the sys paths. Gets abs path, gets parent directory, then the parent directory of that to get repo directory.6sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))7sys.path.append(path.dirname(path.dirname(path.abspath(__file__)))+ "/app")8#imports from ../app/get_links.py9from app import get_links10from app.api_calls import get_random_word11print(get_links.get_definition("throw"))12print(get_links.get_synonyms("throw"))13print(get_links.get_wikipedia_links("throw"))14'''For caching check at most 100 api calls should be made.'''15for i in range(10):16 #time.sleep(5)17 #gens random word18 word = get_random_word()19 print(word)20 #gets attributes that matter21 defn = get_links.get_definition(word)22 syn = get_links.get_synonyms(word)23 wiki = get_links.get_wikipedia_links(word)24 for j in range(10):25 if defn != get_links.get_definition(word):26 print("error in caching: defn")27 exit(1)28 elif syn != get_links.get_synonyms(word):29 print("error in caching: syns")30 exit(1)31 elif wiki != get_links.get_wikipedia_links(word):32 print("error in caching: wiki")...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Kiwi automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful