Esempio n. 1
0
    def __dir__(self) -> List[str]:
        """Available data providers.

        :return: List of attributes.
        """
        attributes = []
        exclude = BaseDataProvider().__dict__.keys()

        for a in self.__dict__:
            if a not in exclude:
                if a.startswith('_'):
                    attribute = a.replace('_', '', 1)
                    attributes.append(attribute)
                else:
                    attributes.append(a)
        return attributes
Esempio n. 2
0
    def __dir__(self) -> List[str]:
        """Available data providers.

        The list of result will be used in AbstractField to
        determine method's class.

        :return: List of attributes.
        """
        attributes = []
        exclude = BaseDataProvider().__dict__.keys()

        for a in self.__dict__:
            if a not in exclude:
                if a.startswith('_'):
                    attribute = a.replace('_', '', 1)
                    attributes.append(attribute)
                else:
                    attributes.append(a)
        return attributes
Esempio n. 3
0
 def _bases(self, seed):
     return BaseDataProvider(seed=seed), BaseDataProvider(seed=seed)
Esempio n. 4
0
 def test_get_current_locale(self, locale):
     base = BaseDataProvider(locale=locale)
     assert locale == base.get_current_locale()
Esempio n. 5
0
 def base_data_provider(self):
     return BaseDataProvider()
Esempio n. 6
0
 def test_load_datafile_raises(self, locale):
     data_provider = BaseDataProvider(locale=locale)
     with pytest.raises(FileNotFoundError):
         data_provider._load_datafile("something.json")
Esempio n. 7
0
 def test_setup_locale_unsupported_locale(self):
     with pytest.raises(LocaleError):
         BaseDataProvider(locale="nil")
Esempio n. 8
0
 def test_load_datafile(self, locale, city):
     data_provider = BaseDataProvider(locale)
     data_provider._load_datafile("address.json")
     assert city in data_provider._data["city"]
Esempio n. 9
0
 def test_setup_locale(self, base_data_provider, inp, out):
     result = BaseDataProvider(locale=inp)
     assert result.locale == out
Esempio n. 10
0
 def test_pull_raises(self, locale):
     data_provider = BaseDataProvider(locale=locale)
     with pytest.raises(FileNotFoundError):
         data_provider._pull('something.json')
Esempio n. 11
0
 def test_pull(self, locale, city):
     data_provider = BaseDataProvider(locale)
     data_provider._pull('address.json')
     assert city in data_provider._data['city']
Esempio n. 12
0
 def test_setup_locale_unsupported_locale(self):
     with pytest.raises(UnsupportedLocale):
         BaseDataProvider(locale='nil')
Esempio n. 13
0
def seeded_base_data_provider():
    return BaseDataProvider(seed=42)