def setup(self): self.churn = Churn('/tmp')
class ChumpTest(UnitTestCase): def setup(self): self.churn = Churn('/tmp') def tear_down(self): # Optional. Will be executed after each test method. print def test_updatetime(self): time1 = self.churn.updatetime label = self.churn.add_item("http://test.com","mattb") time2 = self.churn.updatetime self.assert_condition(time1 < time2, "update didn't change time") time1 = time2 self.churn.title_item(label,'testing') time2 = self.churn.updatetime self.assert_condition(time1 < time2, "update didn't change time") time1 = time2 self.churn.comment_item(label,'testing','testuser') time2 = self.churn.updatetime self.assert_condition(time1 < time2, "update didn't change time") time1 = time2 def test_get_set_entry(self): self.assert_condition(self.churn.get_entry('A') == None,'tried to get non-existant entry and got something back') def test_get_set_entry(self): label = self.churn.add_item("http://test.com","mattb") self.assert_condition(self.churn.get_entry(label) != None) self.assert_equals("http://test.com",self.churn.get_entry(label).item) def test_labels(self): self.assert_equals('A',self.churn.get_next_label()) for x in range(1,25): self.churn.get_next_label() self.assert_equals('Z',self.churn.get_next_label()) for x in range(1,28): self.churn.get_next_label() self.assert_equals('BB',self.churn.get_next_label()) def test_view(self): self.assert_equals('Label A not found.',self.churn.view_item('A')) label = self.churn.add_item("http://test.com","mattb") self.assert_equals('A: http://test.com',self.churn.view_item(label)) self.churn.title_item(label,'testing') self.assert_equals('A: testing (http://test.com)',self.churn.view_item(label)) def test_view_recent(self): label = self.churn.add_item("http://test.com","mattb") self.churn.title_item(label,'testing') self.assert_equals('A: testing (http://test.com)\n',self.churn.view_recent_items(3)) label = self.churn.add_item("http://test2.com","mattb") label = self.churn.add_item("http://test3.com","mattb") self.assert_equals('A: testing (http://test.com)\nB: http://test2.com\nC: http://test3.com\n',self.churn.view_recent_items())
class ChumpTest(UnitTestCase): def setup(self): self.churn = Churn('/tmp') def tear_down(self): # Optional. Will be executed after each test method. print def test_updatetime(self): time1 = self.churn.updatetime label = self.churn.add_item("http://test.com", "mattb") time2 = self.churn.updatetime self.assert_condition(time1 < time2, "update didn't change time") time1 = time2 self.churn.title_item(label, 'testing') time2 = self.churn.updatetime self.assert_condition(time1 < time2, "update didn't change time") time1 = time2 self.churn.comment_item(label, 'testing', 'testuser') time2 = self.churn.updatetime self.assert_condition(time1 < time2, "update didn't change time") time1 = time2 def test_get_set_entry(self): self.assert_condition( self.churn.get_entry('A') == None, 'tried to get non-existant entry and got something back') def test_get_set_entry(self): label = self.churn.add_item("http://test.com", "mattb") self.assert_condition(self.churn.get_entry(label) != None) self.assert_equals("http://test.com", self.churn.get_entry(label).item) def test_labels(self): self.assert_equals('A', self.churn.get_next_label()) for x in range(1, 25): self.churn.get_next_label() self.assert_equals('Z', self.churn.get_next_label()) for x in range(1, 28): self.churn.get_next_label() self.assert_equals('BB', self.churn.get_next_label()) def test_view(self): self.assert_equals('Label A not found.', self.churn.view_item('A')) label = self.churn.add_item("http://test.com", "mattb") self.assert_equals('A: http://test.com', self.churn.view_item(label)) self.churn.title_item(label, 'testing') self.assert_equals('A: testing (http://test.com)', self.churn.view_item(label)) def test_view_recent(self): label = self.churn.add_item("http://test.com", "mattb") self.churn.title_item(label, 'testing') self.assert_equals('A: testing (http://test.com)\n', self.churn.view_recent_items(3)) label = self.churn.add_item("http://test2.com", "mattb") label = self.churn.add_item("http://test3.com", "mattb") self.assert_equals( 'A: testing (http://test.com)\nB: http://test2.com\nC: http://test3.com\n', self.churn.view_recent_items())
def end_churn(self): self._entries.reverse() for a in self._entries: if a['blurb'] == 1: a['item'] = "blurb" label = self.churn.add_item(a['item'], a['nick'], 0) if a['title'] != '': self.churn.title_item(label, a['title'], 0) if a['keywords'] != '': self.churn.keywords_item(label, a['keywords'], 0) for c in a['comments']: self.churn.comment_item(label, c[0], c[1], 0) self.churn.set_time_item(label, a['time'], 0) self.churn.set_update_time(self._last_updated) def handle_data(self, text): if self._in_a == 1: self._a_title = self._a_title + text else: self._data = self._data + text if __name__ == "__main__": from dailychump import Churn c = ChurnParser() c.set_churn(Churn('')) xml.sax.parse("/home/fez/edmundd/tmp/chump/index.xml", c)