Skip to content

Commit

Permalink
#55 remove update_vocabularies_related tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aanersc committed Mar 4, 2021
1 parent c0fa8c5 commit daf8458
Showing 1 changed file with 0 additions and 61 deletions.
61 changes: 0 additions & 61 deletions geospaas/vocabularies/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@ def setUp(self):
def tearDown(self):
self.patcher.stop()

def test_create_from_vocabularies(self):
""" Test shared with all vocabularies """
self.model.objects.create_from_vocabularies(force=True)
self.model.objects.create_from_vocabularies()
self.model.objects.get_list.assert_called()
self.model.objects.update.assert_called()
self.assertIn('Successfully added', self.mock_print.call_args[0][0])

def _insert_twice(self, attributes):
"""Test that an object of the given model class can't be inserted twice"""
object1 = self.model(**attributes)
Expand Down Expand Up @@ -415,56 +407,3 @@ def test_unique_constraint(self):
"""Check that the same VerticalDataResolution can't be inserted twice"""
with self.assertRaises(django.db.utils.IntegrityError):
self._insert_twice({'range': 'test'})


class CommandsTests(TestCase):
"""Unit tests for the custom commands of the vocabularies app"""

def setUp(self):
return_value = [{'Revision': '2019-02-13 08:48:55'}]
models = [
Parameter,
DataCenter,
HorizontalDataResolution,
Instrument,
ISOTopicCategory,
Location,
Platform,
Project,
ScienceKeyword,
TemporalDataResolution,
VerticalDataResolution,
]
# mock get_list in all managers
self.get_list_mocks = [
patch.object(model.objects, 'get_list', return_value=return_value).start()
for model in models]
# mock update in all managers
self.update_mocks = [
patch.object(model.objects, 'update', return_value=return_value).start()
for model in models]

def test_command_update_vocabularies(self):
"""Check that the command does not update the vocabularies if they are present"""

call_command('update_vocabularies')
# check that get_list was called only once
for mock in self.get_list_mocks:
mock.assert_called()
# check that update was never called
for mock in self.update_mocks:
mock.assert_not_called()

def test_command_update_vocabularies_force(self):
"""
Check that the command updates the vocabularies even if they are present when --force is
specified
"""

call_command('update_vocabularies', '--force')
# check that get_list was called only once
for mock in self.get_list_mocks:
mock.assert_called()
# check that update was called
for mock in self.update_mocks:
mock.assert_called()

0 comments on commit daf8458

Please sign in to comment.