def test_get_last_row_with_same_data_returns_the_exact_one(self): """Test that get_last_row returns the row for the exact txlog ID in the table, if the worker name is found for that.""" txlog1 = self.factory.make_transaction_log() txlog2 = self.factory.make_transaction_log() txlog3 = self.factory.make_transaction_log() worker_name = self.factory.get_unique_unicode() self._create_db_worker_last_row_entry(worker_name, txlog3) self._create_db_worker_last_row_entry( self.factory.get_unique_unicode(), txlog1) self._create_db_worker_last_row_entry( self.factory.get_unique_unicode(), txlog2) self.assertEqual( (txlog3.id, txlog3.timestamp), utils.get_last_row(worker_name))
def test_get_last_row_with_other_data_returns_the_oldest_one(self): """get_last_row returns the row for the oldest txlog ID in the table, if the worker name is not found for that.""" txlog1 = self.factory.make_transaction_log() txlog2 = self.factory.make_transaction_log() txlog3 = self.factory.make_transaction_log() self._create_db_worker_last_row_entry( self.factory.get_unique_unicode(), txlog3) self._create_db_worker_last_row_entry( self.factory.get_unique_unicode(), txlog1) self._create_db_worker_last_row_entry( self.factory.get_unique_unicode(), txlog2) self.assertEqual( (txlog1.id, txlog1.timestamp), utils.get_last_row('some worker'))
def test_get_last_row_with_same_data_returns_the_exact_one(self): """Test that get_last_row returns the row for the exact txlog ID in the table, if the worker name is found for that.""" txlog1 = self.factory.make_transaction_log() txlog2 = self.factory.make_transaction_log() txlog3 = self.factory.make_transaction_log() worker_name = self.factory.get_unique_string() self._create_db_worker_last_row_entry(worker_name, txlog3) self._create_db_worker_last_row_entry(self.factory.get_unique_string(), txlog1) self._create_db_worker_last_row_entry(self.factory.get_unique_string(), txlog2) self.assertEqual((txlog3.id, txlog3.timestamp), utils.get_last_row(worker_name))
def test_get_last_row_with_other_data_returns_the_oldest_one(self): """get_last_row returns the row for the oldest txlog ID in the table, if the worker name is not found for that.""" txlog1 = self.factory.make_transaction_log() txlog2 = self.factory.make_transaction_log() txlog3 = self.factory.make_transaction_log() self._create_db_worker_last_row_entry(self.factory.get_unique_string(), txlog3) self._create_db_worker_last_row_entry(self.factory.get_unique_string(), txlog1) self._create_db_worker_last_row_entry(self.factory.get_unique_string(), txlog2) self.assertEqual((txlog1.id, txlog1.timestamp), utils.get_last_row('some worker'))
def test_get_last_row_with_no_data(self): """Test the get_last_row function when no data is present.""" worker_count = DBWorkerLastRow.objects.all().count() assert worker_count == 0, worker_count self.assertEqual( utils.NEW_WORKER_LAST_ROW, utils.get_last_row('some worker'))
def test_get_last_row_with_no_data(self): """Test the get_last_row function when no data is present.""" worker_count = DBWorkerLastRow.objects.all().count() assert worker_count == 0, worker_count self.assertEqual(utils.NEW_WORKER_LAST_ROW, utils.get_last_row('some worker'))