def test_init_by_data(self): pd = ProgressData(func_name='test_func_3', unique_id='ghi789') pd.total = 100 self.assertEqual(pd.key, ':1:SEED:test_func_3:PROG:ghi789') pd2 = ProgressData.from_key(pd.key) self.assertDictEqual(pd.data, pd2.data)
def test_status_message(self): pd = ProgressData(func_name='test_func_5', unique_id='plokij') pd.total = 42 pd.step('Stepping') self.assertEqual(pd.result()['total'], 42) self.assertEqual(pd.result()['status_message'], 'Stepping')
def test_delete_cache(self): pd = ProgressData(func_name='test_func_4', unique_id='1q2w3e') pd.total = 525600 pd.data['status'] = 'doing-something' pd.save() self.assertEqual(pd.result()['total'], 525600) self.assertEqual(pd.data['status'], 'doing-something') self.assertEqual(pd.delete()['total'], None)
def test_status_message(self): pd = ProgressData(func_name='test_func_5', unique_id='plokij') pd.total = 42 pd.step('Stepping') self.assertEqual(pd.result()['total'], 42) self.assertEqual(pd.result()['status_message'], 'Stepping') # if we call step again, then the status message should not change pd.step() self.assertEqual(pd.result()['status_message'], 'Stepping') # Now passing in empty string will reset pd.step('') self.assertEqual(pd.result()['status_message'], '')
def test_total_progress(self): pd = ProgressData(func_name='test_func_2', unique_id='def456') pd.total = 10 self.assertEqual(pd.increment_value(), 10)