Skip to content

Commit

Permalink
Fix #185
Browse files Browse the repository at this point in the history
  • Loading branch information
dougppaz committed Jul 19, 2018
1 parent f4b3474 commit 05f9a0d
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bothub/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def examples(self):
models.Q(deleted_in=self) |
models.Q(deleted_in__training_started_at__lt=t_started_at))
else:
examples = examples.exclude(deleted_in=self)
examples = examples.exclude(deleted_in__isnull=False)
return examples

@property
Expand Down
70 changes: 70 additions & 0 deletions bothub/common/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,11 @@ def setUp(self):
repository_update=self.repository.current_update(),
text='hi',
intent='greet')
example = RepositoryExample.objects.create(
repository_update=self.repository.current_update(),
text='hello1',
intent='greet')
example.delete()

self.update = self.repository.current_update()
self.update.start_training(self.owner)
Expand Down Expand Up @@ -604,6 +609,71 @@ def test_okay(self):
new_update_2.examples.count(),
3)

def test_examples_deleted_consistency(self):
new_update_1 = self.repository.current_update()
RepositoryExample.objects.create(
repository_update=new_update_1,
text='hello',
intent='greet')
RepositoryExample.objects.create(
repository_update=new_update_1,
text='hello d1',
intent='greet').delete()
examples_1_count = new_update_1.examples.count()
new_update_1.start_training(self.owner)

new_update_2 = self.repository.current_update()
RepositoryExample.objects.create(
repository_update=new_update_2,
text='hellow',
intent='greet')
examples_2_count = new_update_2.examples.count()
new_update_2.start_training(self.owner)

new_update_3 = self.repository.current_update()
RepositoryExample.objects.create(
repository_update=new_update_3,
text='hellow',
intent='greet')
RepositoryExample.objects.create(
repository_update=new_update_3,
text='hello d2',
intent='greet').delete()
RepositoryExample.objects.create(
repository_update=new_update_3,
text='hello d3',
intent='greet').delete()
RepositoryExample.objects.create(
repository_update=new_update_3,
text='hello d4',
intent='greet').delete()
examples_3_count = new_update_3.examples.count()
new_update_3.start_training(self.owner)

new_update_4 = self.repository.current_update()
RepositoryExample.objects.create(
repository_update=new_update_4,
text='hellow',
intent='greet')
examples_4_count = new_update_4.examples.count()
new_update_4.start_training(self.owner)

self.assertEqual(
examples_1_count,
new_update_1.examples.count())

self.assertEqual(
examples_2_count,
new_update_2.examples.count())

self.assertEqual(
examples_3_count,
new_update_3.examples.count())

self.assertEqual(
examples_4_count,
new_update_4.examples.count())


class RepositoryReadyForTrain(TestCase):
def setUp(self):
Expand Down

0 comments on commit 05f9a0d

Please sign in to comment.