예제 #1
0
    def test_sync_with_tethys_db(self, mock_te):
        mock_te.objects.filter().all.return_value = []

        tethys_app_base.TethysExtensionBase().sync_with_tethys_db()

        mock_te.assert_called_with(description='', name='', package='', root_url='')
        mock_te().save.assert_called()
예제 #2
0
    def test_sync_with_tethys_db_exists_log_error(self, mock_te, mock_log):
        mock_error = mock_log.error
        ext = tethys_app_base.TethysExtensionBase()
        ext.root_url = 'test_url'
        mock_te.objects.filter().all.side_effect = Exception('test_error')
        ext.sync_with_tethys_db()

        # Check_result
        rts_call_args = mock_error.call_args_list
        self.assertEqual('test_error', rts_call_args[0][0][0].args[0])
예제 #3
0
    def test_sync_with_tethys_db_exists(self, mock_te, mock_ds):
        mock_ds.DEBUG = True
        ext = tethys_app_base.TethysExtensionBase()
        ext.root_url = 'test_url'
        mock_te2 = mock.MagicMock()
        mock_te.objects.filter().all.return_value = [mock_te2]
        ext.sync_with_tethys_db()

        # Check_result
        self.assertTrue(mock_te2.save.call_count == 2)
예제 #4
0
    def test_sync_with_tethys_db_exists_progamming_error(
            self, mock_te, mock_log):
        mock_warning = mock_log.warning
        ext = tethys_app_base.TethysExtensionBase()
        ext.root_url = 'test_url'
        mock_te.objects.filter().all.side_effect = ProgrammingError(
            'test_error')
        ext.sync_with_tethys_db()

        # Check_result
        mock_warning.assert_called_with(
            "Unable to sync extension with database. "
            "tethys_apps_tethysextension table does not exist")
예제 #5
0
 def test_url_maps(self):
     result = tethys_app_base.TethysExtensionBase().url_maps()
     self.assertEqual([], result)
예제 #6
0
 def test__repr__(self):
     result = tethys_app_base.TethysExtensionBase().__repr__()
     self.assertEqual('<TethysApp: >', result)