Skip to content

Commit

Permalink
Merge 05f9a0d into c5114e9
Browse files Browse the repository at this point in the history
  • Loading branch information
Douglas Paz committed Jul 19, 2018
2 parents c5114e9 + 05f9a0d commit 5febebd
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ test:
@make check_environment
@make migrate CHECK_ENVIRONMENT=false
@make collectstatic CHECK_ENVIRONMENT=false
@SUPPORTED_LANGUAGES="en|pt" pipenv run python manage.py test && pipenv run coverage report -m
@PIPENV_DONT_LOAD_ENV=1 SECRET_KEY=SK SUPPORTED_LANGUAGES="en|pt" pipenv run coverage run manage.py test
@PIPENV_DONT_LOAD_ENV=1 pipenv run coverage report -m

migrate:
@make check_environment
Expand Down
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
72 changes: 71 additions & 1 deletion bothub/common/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def test_language(self):
self.example.language,
self.language)

def teste_delete(self):
def test_delete(self):
self.example.delete()
self.assertEqual(
self.example.deleted_in,
Expand Down 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 5febebd

Please sign in to comment.