def test_new_no_delete(self, public_mock, private_mock): public_mock.listdir.return_value = (['dirlol'], ['lol']) public_mock.modified_time.return_value = self.days_ago(1) mkt_gc() assert not public_mock.delete.called assert not private_mock.delete.called
def test_old_no_path(self, rm_mock, ls_mock, stat_mock): fu_old = FileUpload.objects.create(path='', name='foo') fu_old.update(created=self.days_ago(91)) mkt_gc() eq_(FileUpload.objects.count(), 0) assert not rm_mock.called
def test_dump_delete_private(self, public_mock, private_mock): private_mock.listdir.return_value = (['dirlol'], ['lol']) private_mock.modified_time.return_value = self.days_ago(1000) mkt_gc() assert private_mock.delete.called assert not public_mock.delete.called assert private_mock.delete.call_args_list[0][0][0].endswith('lol')
def test_old_no_path(self, public_mock, private_mock): fu_old = FileUpload.objects.create(path='', name='foo') fu_old.update(created=self.days_ago(91)) mkt_gc() eq_(FileUpload.objects.count(), 0) assert not private_mock.delete.called assert not public_mock.delete.called
def test_old_and_new(self, rm_mock, ls_mock, stat_mock): fu_new = FileUpload.objects.create(path='/tmp/bar', name='bar') fu_new.created = self.days_ago(5) fu_old = FileUpload.objects.create(path='/tmp/foo', name='foo') fu_old.update(created=self.days_ago(91)) mkt_gc() eq_(FileUpload.objects.count(), 1) assert rm_mock.called eq_(rm_mock.call_args[0][0], fu_old.path)
def test_old_and_new(self, public_mock, private_mock): fu_new = FileUpload.objects.create(path='/tmp/bar', name='bar') fu_new.created = self.days_ago(5) fu_old = FileUpload.objects.create(path='/tmp/foo', name='foo') fu_old.update(created=self.days_ago(91)) mkt_gc() eq_(FileUpload.objects.count(), 1) assert private_mock.delete.called assert not public_mock.delete.called eq_(private_mock.delete.call_args[0][0], fu_old.path)
def test_nonce(self, rm_mock, ls_mock, stat_mock): nonce = Nonce.objects.create(nonce='a', timestamp=1, client_key='b') nonce.update(created=self.days_ago(2)) eq_(Nonce.objects.count(), 1) mkt_gc() eq_(Nonce.objects.count(), 0)
def test_garbage_collection(self, rm_mock, ls_mock, stat_mock): eq_(ActivityLog.objects.all().count(), 1) mkt_gc() eq_(ActivityLog.objects.all().count(), 0)
def test_dump_delete(self, rm_mock, ls_mock, stat_mock): ls_mock.return_value = ['lol'] stat_mock.return_value = StatMock(days_ago=1000) mkt_gc() assert rm_mock.call_args_list[0][0][0].endswith('lol')
def test_new_no_delete(self, rm_mock, ls_mock, stat_mock): ls_mock.return_value = ['lol'] stat_mock.return_value = StatMock(days_ago=1) mkt_gc() assert not rm_mock.called
def test_garbage_collection(self, public_mock, private_mock): eq_(ActivityLog.objects.all().count(), 1) mkt_gc() eq_(ActivityLog.objects.all().count(), 0)
def test_nonce(self, public_mock, private_mock): nonce = Nonce.objects.create(nonce='a', timestamp=1, client_key='b') nonce.update(created=self.days_ago(2)) eq_(Nonce.objects.count(), 1) mkt_gc() eq_(Nonce.objects.count(), 0)