def setUp(self) -> None: super().setUp() temp_fd, self._tmp_json_file = tempfile.mkstemp(suffix='.json') os.close(temp_fd) airtablemock.create_empty_table('appkEc8N0Bw4Uok43', 'translations')
def test_get_empty_table(self, mock_warning: mock.MagicMock) -> None: """Test getting an empty table.""" base = airtable.Airtable('base', '') airtablemock.create_empty_table('base', 'table') base.get('table') mock_warning.assert_not_called()
def setUp(self) -> None: super().setUp() airtablemock.create_empty_table('appkEc8N0Bw4Uok43', 'translations') for base_id, table, view in _TABLES_TO_MOCK: airtablemock.create_empty_table(base_id, table) if view: airtablemock.Airtable(base_id, '').create_view(table, view, 'unused != 3')
def test_creating_view_twice(self) -> None: """Test creating a view twice.""" airtablemock.create_empty_table('base', 'table') airtablemock.create_view('base', 'table', 'filtered view', 'filter = "yes"') airtablemock.create_view('base', 'table', 'other view', 'filter = "yes"') with self.assertRaises(ValueError): airtablemock.create_view('base', 'table', 'filtered view', 'filter = "yes"')
def test_strings_from_pot_with_context(self) -> None: """Upload translatable strings from POT file with their context.""" airtablemock.create_empty_table('appkEc8N0Bw4Uok43', 'translations') upload_strings_to_translate.main( (path.join(path.dirname(__file__), 'testdata/strings/frontend-server-strings-context.pot'), '--api-key', 'api-key'), ) translations = \ list(airtable.Airtable('appkEc8N0Bw4Uok43', '').iterate('translations')) self.assertEqual( ['Another message_with context'], sorted(t.get('fields', {}).get('string') for t in translations))
def test_creating_empty_table_twice(self) -> None: """Test creating an empty table twice.""" airtablemock.create_empty_table('base', 'table') airtablemock.create_empty_table('base', 'table2') airtablemock.create_empty_table('base2', 'table') with self.assertRaises(ValueError): airtablemock.create_empty_table('base', 'table')
def setUp(self) -> None: super().setUp() self._base = airtablemock.Airtable(self._base_name, 'apikey42') self._table = self.converter_id airtablemock.create_empty_table(self._base_name, self._table) translation._TRANSLATION_TABLE = [] # pylint: disable=protected-access airtablemock.create_empty_table('appkEc8N0Bw4Uok43', 'tblQL7A5EgRJWhQFo') if self.must_check_translations: self._translation_base = airtablemock.Airtable( 'appkEc8N0Bw4Uok43', 'apikey42') else: patcher = mock.patch(translation.__name__ + '.fetch_missing_translation_locales') mock_translate = patcher.start() mock_translate.return_value = {} self.addCleanup(patcher.stop)
def test_upload_same_translation(self) -> None: """Do not upload translations that are the same as the key.""" airtablemock.create_empty_table('appkEc8N0Bw4Uok43', 'translations') upload_strings_to_translate.main( (path.join(path.dirname(__file__), 'testdata/same-translation/actionTemplates.json'), '--api-key', 'api-key', '--lang', 'fr'), ) translations = \ list(airtable.Airtable('appkEc8N0Bw4Uok43', '').iterate('translations')) self.assertEqual( ['apprenticeship:resource_content'], sorted(t.get('fields', {}).get('string') for t in translations)) new_message = next( t for t in translations if t['fields']['string'] == 'apprenticeship:resource_content') self.assertFalse(new_message['fields'].get('fr'))
def setUp(self) -> None: super().setUp() airtablemock.create_empty_table('appkEc8N0Bw4Uok43', 'translations') airtablemock.create_empty_table('appXmyc7yYj0pOcae', 'skills_for_future') airtablemock.create_view('appXmyc7yYj0pOcae', 'skills_for_future', 'viwfJ3L3qKPMVV2wp', 'unused != 3') for base_id, table, view in _TABLES_TO_MOCK: try: airtablemock.create_empty_table(base_id, table) except ValueError: # It's OK if the table exist already. pass if view: airtablemock.create_view(base_id, table, view, 'unused != 3')
def setUp(self) -> None: super().setUp() airtablemock.create_empty_table('appABCD', 'my-table')
def setUp(self) -> None: super().setUp() self.client = airtablemock.Airtable('appXmyc7yYj0pOcae', 'key42') airtablemock.create_empty_table('appXmyc7yYj0pOcae', 'tblJYesuqUHrcISMe')