Fakultas Ilmu Komputer UI

tests.py 80.2 KB
Newer Older
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
        self.client.get(self.download_url1)
        sleep(1)
        self.client.get(self.download_url2)
		
        response = self.client.get(self.history_url)
        resp_html = response.content.decode('utf8')
		
        table_html = ("<table" + resp_html.split("<table")[1]).split("</table>")[0] + "</table>"
        soup = BeautifulSoup(table_html, 'html.parser')
        histories_html = soup.find('tbody').find_all('tr')
        prev_timestamp = None
		
        for riwayat_html in histories_html:
            materi_data = riwayat_html.find_all("td")
            date_format = "%d %B %Y %H:%M:%S"
            materi_timestamp = datetime.strptime(materi_data[2].get_text(), date_format)
            if prev_timestamp:
                self.assertTrue(prev_timestamp > materi_timestamp)
            prev_timestamp = materi_timestamp
			
    def test_no_history_display_message(self):
        no_history_msg = "Anda belum mengunduh materi. Silahkan unduh materi yang anda butuhkan"
        response = self.client.get(self.history_url)
        resp_html = response.content.decode('utf8')
        self.assertIn(no_history_msg, resp_html)
For faster browsing, not all history is shown. View entire blame