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())