def test_addRetrieveWebsite(self): ra = F.addResearchGroup("Beer drinkers anonymous") db.put(ra) auth1 = F.addName("Author", "One") auth2 = F.addName("Author", "Two") auth1_key = db.put(auth1) auth2_key = db.put(auth2) auths = [auth1, auth2] w = F.addWebsite("http://beer.com", ra, auths) self.assert_(w.address == "http://beer.com") self.assert_(w.group.name == "Beer drinkers anonymous") # self.assert_(len(w.authors) == 2) self.assert_(auth1_key in w.authors and auth2_key in w.authors) w_key = db.put(w) w = db.get(w_key) self.assert_(w.address == "http://beer.com") self.assert_(w.group.name == "Beer drinkers anonymous") # self.assert_(len(w.authors) == 2) self.assert_(auth1_key in w.authors and auth2_key in w.authors)
def put_websites(websites): """ adds Website records to DB from a list of xml website tags Keyword arguments: websites -- list of website xml tags no return """ group_list = [] website_list = [] if websites is not None: for website in websites: url = get_text(website.find('url')) group = get_text(website.find('group')) group = Faculty3.addResearchGroup(group) group_list.append(group) authors = website.findall('author') author_list = put_names(authors) website_list.append( Faculty3.addWebsite(url, group, author_list)) for g in group_list: db.put(g) return website_list
def put_websites(websites): """ adds Website records to DB from a list of xml website tags Keyword arguments: websites -- list of website xml tags no return """ group_list = [] website_list = [] if websites is not None: for website in websites: url = get_text(website.find('url')) group = get_text(website.find('group')) group = Faculty3.addResearchGroup(group) group_list.append(group) authors = website.findall('author') author_list = put_names(authors) website_list.append(Faculty3.addWebsite(url, group, author_list)) for g in group_list: db.put(g) return website_list
def test_addRetrieveResearchGroup(self): ra = F.addResearchGroup("Beer drinkers anonymous") self.assert_(ra.name == "Beer drinkers anonymous") key = db.put(ra) ra = db.get(key) self.assert_(ra.name == "Beer drinkers anonymous")
def put_research_groups(research_groups): """ makes DB ResearchGroup objects, associating them with their person Keyword arguments: research_groups -- list of research_area xml tags Return: list of objects """ l = [] if research_groups is not None: for research_group in research_groups: l.append(Faculty3.addResearchGroup(get_text(research_group))) return l
def put_research_groups(research_groups): """ makes DB ResearchGroup objects, associating them with their person Keyword arguments: research_groups -- list of research_area xml tags Return: list of objects """ l = [] if research_groups is not None: for research_group in research_groups: l.append( Faculty3.addResearchGroup(get_text(research_group))) return l