def testParseOk(self): url = 'https://github.com/search?q=Tensorflow&type=Repositories' response = requests.get(url) self.soup = BeautifulSoup(response.text, "html.parser") strategy = Respositories() strategyType = Type(strategy) response =strategyType.search_params(response.text) self.assertEqual(len(response),10)
class RepositoriesTest(unittest.TestCase): def setUp(self) -> None: url = 'https://github.com/search?q=Tensorflow&type=Repositories' response = requests.get(url) self.soup = BeautifulSoup(response.text, "html.parser") self.repositories = Respositories() def testRepositoriesParseOk(self): self.setUp() r = self.repositories.search_gh_data(self.soup) self.assertEqual(r[0]["url"],"https://github.com/tensorflow/tensorflow") self.assertEqual(len(r),10) def testRepositoriesBonus(self): self.setUp() url = "https://github.com/tensorflow/tensorflow" r = self.repositories.get_repo_data(url) self.assertEqual(r["extra"]["owner"],"tensorflow")
class GHTypes(ABC): """ GitHub types to select """ factory = {} factory["Repositories"] = Respositories() factory["Issues"] = Issues() factory["Wikis"] = Wikis() @classmethod def factory_method(self, gh_types): if gh_types in GHTypes.factory.keys(): return GHTypes.factory[gh_types] else: return None
def setUp(self) -> None: url = 'https://github.com/search?q=Tensorflow&type=Repositories' response = requests.get(url) self.soup = BeautifulSoup(response.text, "html.parser") self.repositories = Respositories()