def test_parse_result_python_for(self): self.l = "Python" self.t = TranslationEngine(self.l) url = self.t.url_search("for", "keyword") la = LanguagesAPI() result, code = la.http_request_using_urlfetch(http_url=url) res = self.t.parse_result(result) self.assertEqual(res.split('\n')[0], '<div class="col-md-7 middle-col">')
def test_parse_result_unknown_url(self): self.l = "Ruby" self.t = TranslationEngine(self.l) la = LanguagesAPI() url = "http://ruby-doc.org/docs/ruby-doc-bundle/Manual/man-1.4/function.html" result, code = la.http_request_using_urlfetch(http_url=url) res = self.t.parse_result(result) self.assertEqual(res, result)
def test_strip_text_from_html__for_statement_python(self): a = LanguagesAPI() result, code = a.http_request_using_urlfetch( "https://docs.python.org/2/reference/compound_stmts.html#the-for-statement", {}) b = ResultParser("Python") res = b.strip_text_from_html(result) self.assertNotIn("<", res, "The result contains tags!")
def test_find_by_id_get_for_statement_python(self): """ Test getting translation for "for statement" in python from html by given id """ a = LanguagesAPI() result, code = a.http_request_using_urlfetch("https://docs.python.org/2/reference/compound_stmts.html#the-for-statement", {}) b = ResultParser("Python") res = b.find_by_id(result, 'the-for-statement') self.assertNotEqual(res, "", "The result is empty string!")
def test_parse_result_python_for(self): self.l = "Python" self.t = TranslationEngine(self.l) url = self.t.url_search("for", "keyword") la = LanguagesAPI() result, code = la.http_request_using_urlfetch(http_url=url) res = self.t.parse_result(result) self.assertEqual( res.split('\n')[0], '<div class="col-md-7 middle-col">')
def test__find_by_p_get_for_statement_c(self): """ Test getting translation for "for statement" in c from html by given p """ a = LanguagesAPI() cntb = "for" # code needed to be translated result, code = a.http_request_using_urlfetch("http://www.tutorialspoint.com/cprogramming/c_for_loop.htm", {}) b = ResultParser("c") res = b.find_by_p(result) print res self.assertTrue(cntb in res)
def test_find_by_id_get_for_statement_python(self): """ Test getting translation for "for statement" in python from html by given id """ a = LanguagesAPI() result, code = a.http_request_using_urlfetch( "https://docs.python.org/2/reference/compound_stmts.html#the-for-statement", {}) b = ResultParser("Python") res = b.find_by_id(result, 'the-for-statement') self.assertNotEqual(res, "", "The result is empty string!")
def test__find_by_p_get_for_statement_c(self): """ Test getting translation for "for statement" in c from html by given p """ a = LanguagesAPI() cntb = "for" # code needed to be translated result, code = a.http_request_using_urlfetch( "http://www.tutorialspoint.com/cprogramming/c_for_loop.htm", {}) b = ResultParser("c") res = b.find_by_p(result) print res self.assertTrue(cntb in res)
def test_strip_text_from_html__for_statement_python(self): a = LanguagesAPI() result, code = a.http_request_using_urlfetch("https://docs.python.org/2/reference/compound_stmts.html#the-for-statement", {}) b = ResultParser("Python") res = b.strip_text_from_html(result) self.assertNotIn("<", res, "The result contains tags!")