tortoise-orm icon indicating copy to clipboard operation
tortoise-orm copied to clipboard

add test for accessing a query

Open spacemanspiff2007 opened this issue 3 years ago • 15 comments

This is the first attempt to reproduce issue #780 with a test case

spacemanspiff2007 avatar Dec 08 '21 13:12 spacemanspiff2007

Pull Request Test Coverage Report for Build 1554372017

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 91.763%

Totals Coverage Status
Change from base Build 1547330232: 0.0%
Covered Lines: 4821
Relevant Lines: 5148

💛 - Coveralls

coveralls avatar Dec 08 '21 13:12 coveralls

@long2ice I have a mistake in the test case

self.assertEqual(await query.all(), [team_2])

should be

self.assertEqual(await query.all(), [event_2])

but all the tests are green. Is the testcase not executed in ci?

spacemanspiff2007 avatar Dec 08 '21 14:12 spacemanspiff2007

What's the result in local?

long2ice avatar Dec 20 '21 08:12 long2ice

I can't run the test locally since I am on a windows machine and the instructions in the readme won't work. But here I start the query:

query = Event.filter(pk__in=sub_query_team_1) 

and you see it should yield an Event instance, not a Team instance since I filter on the Events. So this should definitely fail:

self.assertEqual(await query.all(), [team_2])

spacemanspiff2007 avatar Dec 20 '21 09:12 spacemanspiff2007

Try merge develop first

long2ice avatar Dec 24 '21 02:12 long2ice

Try merge develop first

I'm sorry I don't understand. Should I merge the PR into the Tortoise branch "develop"? Should I merge the Tortoise branch "develop" into my branch and rebase?

spacemanspiff2007 avatar Dec 24 '21 04:12 spacemanspiff2007

Yes, rebase develop to your develop branch

long2ice avatar Dec 24 '21 04:12 long2ice

Like this?

spacemanspiff2007 avatar Dec 24 '21 04:12 spacemanspiff2007

@long2ice After pulling the latest develop changes locally I could run the tests locally, too. That helped a lot. Thank you!

The test now fails as expected since the query changes which it should not (bug). This is good to be merged.

spacemanspiff2007 avatar Dec 24 '21 05:12 spacemanspiff2007

@long2ice do I still have to do something so this can get merged?

spacemanspiff2007 avatar Jan 01 '22 13:01 spacemanspiff2007

Yes, just make ci pass

long2ice avatar Jan 01 '22 13:01 long2ice

Yes, just make ci pass

It won't pass because it's a bug in tortoise-orm and I don't know how to fix the bug. This just adds a test case so someone else with more knowledge can fix it. See issue #780 for details.

spacemanspiff2007 avatar Jan 01 '22 14:01 spacemanspiff2007

Can we get this merged?

spacemanspiff2007 avatar Jan 13 '22 08:01 spacemanspiff2007

@long2ice : I added some comments - could you merge this?

spacemanspiff2007 avatar Jan 26 '22 09:01 spacemanspiff2007

@abondar Could you merge this please?

spacemanspiff2007 avatar Feb 15 '22 07:02 spacemanspiff2007