def test_str(self): language = LanguageFactory.create( name='pt-BR', full_name='Portuguese - Brasil') actual = str(language) expected = 'Portuguese - Brasil (pt-BR)' self.assertEquals(actual, expected)
def setUp(self): self.translate_pt_BR = LanguageFactory.create( name='pt-BR', full_name='Portuguese - Brasil') self.translate_us_EN = LanguageFactory.create( name='en-US', full_name='English - United States') self.sentence = SentenceFactory.create( phrase='You can do anything, but not everything.', translation='Você pode fazer qualquer coisa, mas não tudo.', comments='', translate_to=self.translate_us_EN, translate_from=self.translate_pt_BR) self.url = '/api/sentence/' self.url_detail = '{}{}/'.format(self.url, self.sentence.id)
def test_slug(self): language = LanguageFactory.create( name='en-US', full_name='English - United States') actual = language.slug expected = 'en-us' self.assertEquals(actual, expected)
def test_get_all_languages(self): LanguageFactory.create(name='pt-BR', full_name='Portuguese - Brazil') response = self.client.get(self.url, format='json') self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(len(response.data), 2) self.assertEqual(response.data[0]['slug'], 'en-us') self.assertEqual(response.data[0]['name'], 'en-US') self.assertEqual( response.data[0]['full_name'], 'English - United States') self.assertEqual(response.data[1]['slug'], 'pt-br') self.assertEqual(response.data[1]['name'], 'pt-BR') self.assertEqual(response.data[1]['full_name'], 'Portuguese - Brazil')
def setUp(self): self.language = LanguageFactory.create( name='en-US', full_name='English - United States') self.url = '/api/language/' self.url_detail = '{}{}/'.format(self.url, self.language.id)