Ejemplo n.º 1
0
 def test_non_sqlite(self, config_instance):
     """Make sure that passing a store other than 'sqlalchemy' raises exception."""
     config_instance = config_instance(db_engine='postgres')
     backend, client = hamster_cli._get_config(config_instance)
     assert backend['db_host'] == config_instance.get('Backend', 'db_host')
     assert backend['db_port'] == config_instance.get('Backend', 'db_port')
     assert backend['db_name'] == config_instance.get('Backend', 'db_name')
     assert backend['db_user'] == config_instance.get('Backend', 'db_user')
     assert backend['db_password'] == config_instance.get('Backend', 'db_password')
Ejemplo n.º 2
0
 def test_non_sqlite(self, config_instance):
     """Make sure that passing a store other than 'sqlalchemy' raises exception."""
     config_instance = config_instance(db_engine='postgres')
     backend, client = hamster_cli._get_config(config_instance)
     assert backend['db_host'] == config_instance.get('Backend', 'db_host')
     assert backend['db_port'] == config_instance.get('Backend', 'db_port')
     assert backend['db_name'] == config_instance.get('Backend', 'db_name')
     assert backend['db_user'] == config_instance.get('Backend', 'db_user')
     assert backend['db_password'] == config_instance.get(
         'Backend', 'db_password')
Ejemplo n.º 3
0
 def test_daystart_valid(self, config_file, day_start):
     backend, client = hamster_cli._get_config(config_file(
         daystart=day_start))
     assert backend['day_start'] == datetime.datetime.strptime(
         '05:00:00', '%H:%M:%S').time()
Ejemplo n.º 4
0
 def test_log_levels_invalid(self, log_level, config_file):
     with pytest.raises(ValueError):
         backend, client = hamster_cli._get_config(
             config_file(log_level=log_level))
Ejemplo n.º 5
0
 def test_log_levels_valid(self, log_level, config_file):
     backend, client = hamster_cli._get_config(
         config_file(log_level=log_level))
     assert client['log_level'] == 10
Ejemplo n.º 6
0
 def test_cwd(self, config_file):
     backend, client = hamster_cli._get_config(config_file())
     assert client['cwd'] == '.'
Ejemplo n.º 7
0
 def test_invalid_store(self, config_instance):
     """Make sure that encountering an unsupportet store will raise an exception."""
     with pytest.raises(ValueError):
         backend, client = hamster_cli._get_config(
             config_instance(store='foobar'))
Ejemplo n.º 8
0
 def test_log_levels_invalid(self, log_level, config_instance):
     """Test that invalid *string loglevels* raise ``ValueError``."""
     with pytest.raises(ValueError):
         backend, client = hamster_cli._get_config(
             config_instance(log_level=log_level))
Ejemplo n.º 9
0
 def test_daystart_valid(self, config_instance, day_start):
     """Test that ``day_start`` string translate to proper ``datetime.time`` instances."""
     backend, client = hamster_cli._get_config(
         config_instance(daystart=day_start))
     assert backend['day_start'] == datetime.datetime.strptime(
         '05:00:00', '%H:%M:%S').time()
Ejemplo n.º 10
0
 def test_log_levels_invalid(self, log_level, config_instance):
     """Test that invalid *string loglevels* raise ``ValueError``."""
     with pytest.raises(ValueError):
         backend, client = hamster_cli._get_config(
             config_instance(log_level=log_level))
Ejemplo n.º 11
0
 def test_log_levels_valid(self, log_level, config_instance):
     """Make sure that *string loglevels* translate to their respective integers properly."""
     backend, client = hamster_cli._get_config(
         config_instance(log_level=log_level))
     assert client['log_level'] == 10
Ejemplo n.º 12
0
 def test_invalid_store(self, config_instance):
     """Make sure that encountering an unsupportet store will raise an exception."""
     with pytest.raises(ValueError):
         backend, client = hamster_cli._get_config(config_instance(store='foobar'))
Ejemplo n.º 13
0
 def test_daystart_invalid(self, config_instance, day_start):
     """Test that invalid ``day_start`` strings raises ``ValueError``."""
     with pytest.raises(ValueError):
         backend, client = hamster_cli._get_config(
             config_instance(daystart=day_start))
Ejemplo n.º 14
0
 def test_daystart_valid(self, config_instance, day_start):
     """Test that ``day_start`` string translate to proper ``datetime.time`` instances."""
     backend, client = hamster_cli._get_config(config_instance(
         daystart=day_start))
     assert backend['day_start'] == datetime.datetime.strptime(
         '05:00:00', '%H:%M:%S').time()
Ejemplo n.º 15
0
 def test_daystart_invalid(self, config_file, day_start):
     with pytest.raises(ValueError):
         backend, client = hamster_cli._get_config(
             config_file(daystart=day_start))
Ejemplo n.º 16
0
 def test_daystart_invalid(self, config_instance, day_start):
     """Test that invalid ``day_start`` strings raises ``ValueError``."""
     with pytest.raises(ValueError):
         backend, client = hamster_cli._get_config(
             config_instance(daystart=day_start))
Ejemplo n.º 17
0
 def test_log_filename_empty(self, config_file):
     """Test that a empty filename throws an error."""
     with pytest.raises(ValueError):
         backend, client = hamster_cli._get_config(
             config_file(log_filename=''))
Ejemplo n.º 18
0
 def test_log_levels_valid(self, log_level, config_instance):
     """Make sure that *string loglevels* translate to their respective integers properly."""
     backend, client = hamster_cli._get_config(
         config_instance(log_level=log_level))
     assert client['log_level'] == 10