def test_emails_correct_size(self, mock_path): mock_path.return_value.glob.return_value = [ MockPath('src/locale1/name1.xml'), MockPath('src/locale2/name2.xml')] actual = list(fs.emails('dummy_path', 'src/{locale}/{name}.xml')) self.assertEqual(2, len(actual))
def test_emails_fail_on_missing_name(self, mock_path): mock_path.return_value.glob.return_value = [ MockPath('src/locale1.xml') ] with self.assertRaises(errors.MissingPatternParamError): list(fs.emails('dummy_path', 'src/{locale}.xml'))
def test_emails_ignore_global_by_default(self): self.mock_path.return_value.glob.return_value = [ MockPath('locale1/name1.xml'), MockPath('locale1/global.xml') ] actual = list(fs.emails('.')) self.assertEqual(1, len(actual))
def test_emails_happy_path(self, mock_path): expected = fs.Email('name1', 'locale1', 'src/locale1/name1.xml', 'src/locale1/name1.xml') mock_path.return_value.glob.return_value = [MockPath(expected.path)] actual = list(fs.emails('dummy_path', 'src/{locale}/{name}.xml')) self.assertEqual([expected], actual)
def test_emails_ignore_dirs(self): self.mock_path.return_value.glob.return_value = [ MockPath('locale1/name1.xml'), MockPath('locale1', True) ] actual = list(fs.emails('.')) self.assertEqual(1, len(actual))
def test_emails_correct_size(self): self.mock_path.return_value.glob.return_value = [ MockPath('locale1/name1.xml'), MockPath('locale2/name2.xml') ] actual = list(fs.emails('.')) self.assertEqual(2, len(actual))
def test_emails_happy_path(self): expected = Email('name1', 'locale1', 'locale1/name1.xml') self.mock_path.return_value.glob.return_value = [ MockPath(expected.path) ] actual = list(fs.emails('.')) self.assertEqual([expected], actual)
def test_emails_ignore_dirs(self, mock_path): mock_path.return_value.glob.return_value = [ MockPath('src/locale1/name1.xml'), MockPath('src/locale1', True) ] actual = list(fs.emails('dummy_path', 'src/{locale}/{name}.xml')) self.assertEqual(1, len(actual))
def test_emails_correct_size(self, mock_path): mock_path.return_value.glob.return_value = [ MockPath('src/locale1/name1.xml'), MockPath('src/locale2/name2.xml') ] actual = list(fs.emails('dummy_path', 'src/{locale}/{name}.xml')) self.assertEqual(2, len(actual))
def test_emails_ignore_dirs(self, mock_path): mock_path.return_value.glob.return_value = [MockPath('src/locale1/name1.xml'), MockPath('src/locale1', True)] actual = list(fs.emails('dummy_path', 'src/{locale}/{name}.xml')) self.assertEqual(1, len(actual))
def test_emails_fail_on_missing_name(self, mock_path): mock_path.return_value.glob.return_value = [MockPath('src/locale1.xml')] with self.assertRaises(errors.MissingPatternParamError): list(fs.emails('dummy_path', 'src/{locale}.xml'))
def test_emails_ignore_global_by_default(self): self.mock_path.return_value.glob.return_value = [MockPath('locale1/name1.xml'), MockPath('locale1/global.xml')] actual = list(fs.emails('.')) self.assertEqual(1, len(actual))
def test_emails_ignore_dirs(self): self.mock_path.return_value.glob.return_value = [MockPath('locale1/name1.xml'), MockPath('locale1', True)] actual = list(fs.emails('.')) self.assertEqual(1, len(actual))
def test_emails_correct_size(self): self.mock_path.return_value.glob.return_value = [MockPath('locale1/name1.xml'), MockPath('locale2/name2.xml')] actual = list(fs.emails('.')) self.assertEqual(2, len(actual))
def test_emails_happy_path(self): expected = Email('name1', 'locale1', 'locale1/name1.xml') self.mock_path.return_value.glob.return_value = [MockPath(expected.path)] actual = list(fs.emails('.')) self.assertEqual([expected], actual)