Rebased migrations, all tests working.

This commit is contained in:
Nicholas Staples
2016-04-08 13:34:46 +01:00
parent 2abdad8d20
commit c4b316bde6
67 changed files with 392 additions and 1850 deletions

View File

@@ -42,10 +42,13 @@ def test_save_api_key_should_update_the_api_key(notify_api, notify_db, notify_db
assert all_api_keys[0].service_id == saved_api_key.service_id
def test_get_api_key_should_raise_exception_when_api_key_does_not_exist(notify_api, notify_db, notify_db_session,
sample_service):
def test_get_api_key_should_raise_exception_when_api_key_does_not_exist(notify_api,
notify_db,
notify_db_session,
sample_service,
fake_uuid):
try:
get_model_api_keys(sample_service.id, id=123)
get_model_api_keys(sample_service.id, id=fake_uuid)
fail("Should have thrown a NoResultFound exception")
except NoResultFound:
pass
@@ -78,9 +81,10 @@ def test_get_unsigned_secret_returns_key(notify_api,
def test_should_not_allow_duplicate_key_names_per_service(notify_api,
notify_db,
notify_db_session,
sample_api_key):
sample_api_key,
fake_uuid):
api_key = ApiKey(
**{'id': sample_api_key.id + 1, 'service_id': sample_api_key.service_id, 'name': sample_api_key.name})
**{'id': fake_uuid, 'service_id': sample_api_key.service_id, 'name': sample_api_key.name})
try:
save_model_api_key(api_key)
fail("should throw IntegrityError")

View File

@@ -42,20 +42,6 @@ def test_create_email_template(sample_service):
assert dao_get_all_templates_for_service(sample_service.id)[0].name == 'Sample Template'
def test_create_email_template_fails_if_no_subject(sample_service):
data = {
'name': 'Sample Template',
'template_type': "email",
'content': "Template content",
'service': sample_service
}
template = Template(**data)
with pytest.raises(IntegrityError) as e:
dao_create_template(template)
assert 'new row for relation "templates" violates check constraint "ch_email_template_has_subject"' in str(e.value)
def test_update_template(sample_service):
data = {
'name': 'Sample Template',
@@ -154,7 +140,7 @@ def test_get_template_by_id_and_service(notify_db, notify_db_session, sample_ser
assert Template.query.count() == 1
def test_get_template_by_id_and_service_returns_none_if_no_template(sample_service):
def test_get_template_by_id_and_service_returns_none_if_no_template(sample_service, fake_uuid):
with pytest.raises(NoResultFound) as e:
dao_get_template_by_id_and_service_id(template_id=999, service_id=sample_service.id)
dao_get_template_by_id_and_service_id(template_id=fake_uuid, service_id=sample_service.id)
assert 'No row was found for one' in str(e.value)

View File

@@ -54,9 +54,9 @@ def test_get_user(notify_api, notify_db, notify_db_session):
assert get_model_users(user_id=another_user.id).email_address == email
def test_get_user_not_exists(notify_api, notify_db, notify_db_session):
def test_get_user_not_exists(notify_api, notify_db, notify_db_session, fake_uuid):
try:
get_model_users(user_id="12345")
get_model_users(user_id=fake_uuid)
pytest.fail("NoResultFound exception not thrown.")
except NoResultFound as e:
pass