def test_parse_time(db): cmd = Command() cmd.parse_time('1y 2m 3d 5h 4min 2s ago') assert cmd.td == timedelta(days=365 + 60 + 3, hours=5, minutes=4, seconds=2)
def test_wall_post(db, sents): cmd = Command() cmd.handle(wall=True) assert Wall.objects.all().count() == 2 w = Wall.objects.all().order_by('-lft') assert w[0].lft == 3 and w[0].rght == 4 assert w[1].lft == 1 and w[1].rght == 2
def test_comment_post(db, sents): cmd = Command() cmd.handle(cmnt=True) assert SentenceComments.objects.filter( text__contains='This sentence has been deleted').count() == 11 assert SentenceComments.objects.filter( text__contains='Duplicates of this sentence have been deleted' ).count() == 5
def test_dry_run(db, sents): cmd = Command() cmd.handle(dry=True, cmnt=True, wall=True) assert Sentences.objects.all().count() == 21 assert Contributions.objects.all().count() == 5 assert SentenceComments.objects.all().count() == 3 assert Users.objects.all().count() == 0 assert Wall.objects.all().count() == 1
def test_suppress_incremental(db, sents): assert Sentences.objects.all().count() == 21 cmd = Command() cmd.handle(since='2014-1-4', suppress=True) assert Sentences.objects.all().count() == 16 assert len(cmd.all_dups) == 5 assert len(cmd.all_mains) == 2 assert cmd.ver_dups assert cmd.ver_audio assert cmd.ver_mains
def test_full_scan(db, sents): assert Sentences.objects.all().count() == 21 cmd = Command() cmd.handle() assert Sentences.objects.all().count() == 10 assert len(cmd.all_dups) == 11 assert len(cmd.all_mains) == 5 assert cmd.ver_dups assert cmd.ver_audio assert cmd.ver_mains
def test_incremental_scan(db, sents): assert Sentences.objects.all().count() == 21 assert ReindexFlags.objects.all().count() == 0 cmd = Command() cmd.handle(since='2014-1-4') assert Sentences.objects.all().count() == 16 assert ReindexFlags.objects.filter(type='removal', indexed=0).count() == 5 assert len(cmd.all_dups) == 5 assert len(cmd.all_mains) == 2 assert cmd.ver_dups assert cmd.ver_audio assert cmd.ver_mains