Пример #1
0
 def test_reset_app(self):
     default_name = AppSettings.name
     AppSettings(name='test-name')
     AppSettings()
     self.assertEqual(AppSettings.name, default_name)
     AppSettings.name = 'test-name-2'
     AppSettings(name='test-name-2', reset=False)
     self.assertNotEqual(AppSettings.name, default_name)
Пример #2
0
 def test_prefix_vars(self):
     AppSettings(prefix='')
     self.assertEqual(AppSettings.cdn_bucket_name, 'cdn.door43.org')
     # self.assertEqual(AppSettings.api_url, 'https://api.door43.org')
     AppSettings(prefix='test-')
     self.assertEqual(AppSettings.cdn_bucket_name, 'test-cdn.door43.org')
     # self.assertEqual(AppSettings.api_url, 'https://test-api.door43.org')
     AppSettings(prefix='test2-')
     self.assertEqual(AppSettings.cdn_bucket_name, 'test2-cdn.door43.org')
     # self.assertEqual(AppSettings.api_url, 'https://test2-api.door43.org')
     AppSettings(prefix='')
     self.assertEqual(AppSettings.cdn_bucket_name, 'cdn.door43.org')
Пример #3
0
 def test_db(self):
     AppSettings(db_connection_string='sqlite:///:memory:')
     AppSettings.db_create_tables([User.__table__])
     user = User(name='ed',
                 fullname='Edward Scissorhands',
                 password='******')
     user.insert()
     user_from_db = User.get(name='ed')
     self.assertIsNotNone(user_from_db)
     self.assertEqual(user_from_db.password, '12345')
 def setUp(self):
     """Runs before each test."""
     AppSettings(prefix=f'{self._testMethodName}-')
     AppSettings.cdn_s3_handler().create_bucket()
     AppSettings.door43_s3_handler().create_bucket()
     self.temp_dir = tempfile.mkdtemp(prefix='Door43_test_project_deployer')
     self.deployer = ProjectDeployer(self.temp_dir)
     TdLanguage.language_list = {
         'aa':
         TdLanguage({
             'gw': False,
             'ld': 'ltr',
             'ang': 'Afar',
             'lc': 'aa',
             'ln': 'Afaraf',
             'lr': 'Africa',
             'pk': 6
         }),
         'en':
         TdLanguage({
             'gw': True,
             'ld': 'ltr',
             'ang': 'English',
             'lc': 'en',
             'ln': 'English',
             'lr': 'Europe',
             'pk': 1747
         }),
         'es':
         TdLanguage({
             'gw': True,
             'ld': 'ltr',
             'ang': 'Spanish',
             'lc': 'es',
             'ln': 'espa\xf1ol',
             'lr': 'Europe',
             'pk': 1776
         }),
         'fr':
         TdLanguage({
             'gw': True,
             'ld': 'ltr',
             'ang': 'French',
             'lc': 'fr',
             'ln': 'fran\xe7ais, langue fran\xe7aise',
             'lr': 'Europe',
             'pk': 1868
         })
     }
Пример #5
0
 def test_construction_connection_string(self):
     """
     Test the construction of the connection string with multiple attributes
     """
     AppSettings(db_protocol='protocol',
                 db_user='******',
                 db_pass='******',
                 db_end_point='my.endpoint.url',
                 db_port='9999',
                 db_name='db',
                 db_connection_string_params='charset=utf8',
                 auto_setup_db=False)
     expected = "protocol://*****:*****@my.endpoint.url:9999/db?charset=utf8"
     connection_str = AppSettings.construct_connection_string()
     self.assertEqual(connection_str, expected)
Пример #6
0
 def test_setup_db_with_connection_string_parts(self):
     AppSettings(db_protocol='sqlite',
                 db_user=None,
                 db_pass=None,
                 db_end_point=None,
                 db_port=None,
                 db_name=':memory:',
                 db_connection_string_params=None)
     AppSettings.db_create_tables([User.__table__])
     user = User(name='ed',
                 fullname='Edward Scissorhands',
                 password='******')
     user.insert()
     user_from_db = User.get(name='ed')
     self.assertIsNotNone(user_from_db)
     self.assertEqual(user_from_db.password, '12345')
     AppSettings.db_close()
Пример #7
0
 def setUp(self):
     """Runs before each test."""
     AppSettings(prefix='{0}-'.format(self._testMethodName))
     self.temp_dir = tempfile.mkdtemp(prefix='tX_test_Md2HtmlConverter')
     self.out_dir = ''
     self.out_zip_file = ''
Пример #8
0
 def test_init(self):
     gogs_url = 'https://my.gogs.org'
     AppSettings(gogs_url=gogs_url)
     self.assertEqual(AppSettings.gogs_url, gogs_url)
Пример #9
0
        'TSV_Translation_Notes',
        'tn',
        'other',
    ), 'html'),
    ('usfm2html', Usfm2HtmlConverter, ('usfm', ), (
        'Bible',
        'Aligned_Bible',
        'Greek_New_Testament',
        'Hebrew_Old_Testament',
        'bible',
        'reg',
        'other',
    ), 'html'),
)

AppSettings(prefix=prefix)
if prefix not in ('', 'dev-'):
    AppSettings.logger.critical(
        f"Unexpected prefix: '{prefix}' — expected '' or 'dev-'")
tx_stats_prefix = f"tx.{'dev' if prefix else 'prod'}"
job_handler_stats_prefix = f"{tx_stats_prefix}.tx-job-handler"

# Get the Graphite URL from the environment, otherwise use a local test instance
graphite_url = os.getenv('GRAPHITE_HOSTNAME', 'localhost')
stats_client = StatsClient(host=graphite_url,
                           port=8125,
                           prefix=job_handler_stats_prefix)


def get_linter_module(glm_job: Dict[str, Any]) -> Tuple[Optional[str], Any]:
    """
Пример #10
0
 def setUp(self):
     """Runs before each test."""
     AppSettings(prefix=f'{self._testMethodName}-', db_connection_string='sqlite:///:memory:')
     self.items = {}
     self.init_items()
     self.populate_table()
Пример #11
0
 def setUp(self):
     # Make sure that other tests didn't mess up our prefix
     AppSettings(prefix=prefix)
Пример #12
0
 def test_init(self):
     AppSettings()