Example #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
Example #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
Example #3
0
 def _bases(self, seed):
     return BaseDataProvider(seed=seed), BaseDataProvider(seed=seed)
Example #4
0
 def test_get_current_locale(self, locale):
     base = BaseDataProvider(locale=locale)
     assert locale == base.get_current_locale()
Example #5
0
 def base_data_provider(self):
     return BaseDataProvider()
Example #6
0
 def test_load_datafile_raises(self, locale):
     data_provider = BaseDataProvider(locale=locale)
     with pytest.raises(FileNotFoundError):
         data_provider._load_datafile("something.json")
Example #7
0
 def test_setup_locale_unsupported_locale(self):
     with pytest.raises(LocaleError):
         BaseDataProvider(locale="nil")
Example #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"]
Example #9
0
 def test_setup_locale(self, base_data_provider, inp, out):
     result = BaseDataProvider(locale=inp)
     assert result.locale == out
Example #10
0
 def test_pull_raises(self, locale):
     data_provider = BaseDataProvider(locale=locale)
     with pytest.raises(FileNotFoundError):
         data_provider._pull('something.json')
Example #11
0
 def test_pull(self, locale, city):
     data_provider = BaseDataProvider(locale)
     data_provider._pull('address.json')
     assert city in data_provider._data['city']
Example #12
0
 def test_setup_locale_unsupported_locale(self):
     with pytest.raises(UnsupportedLocale):
         BaseDataProvider(locale='nil')
Example #13
0
def seeded_base_data_provider():
    return BaseDataProvider(seed=42)