def test_save_fails_if_integrity_error(self): """Test save raises a DBIntegrityError if the instance to be saved lacks a required value""" project = AppFactory.build(name=None) assert_raises(DBIntegrityError, self.project_repo.save, project)
def test_update_category_only_updates_categories(self): """Test update_category raises a WrongObjectError when an object which is not a Category instance is updated""" bad_object = AppFactory.build() assert_raises(WrongObjectError, self.project_repo.update_category, bad_object)
def test_delete_autoimporter_works_as_expected(self): autoimporter = {'type': 'csv', 'csv_url': 'http://fakeurl.com'} app = AppFactory.build(info={'autoimporter': autoimporter}) assert app.has_autoimporter() is True app.delete_autoimporter() assert app.has_autoimporter() is False, app.get_autoimporter()
def test_set_autoimporter_works_as_expected(self): autoimporter = {'type': 'csv', 'csv_url': 'http://fakeurl.com'} app = AppFactory.build(info={}) assert app.has_autoimporter() is False app.set_autoimporter(autoimporter) assert app.get_autoimporter() == autoimporter, app.get_autoimporter()
def test_save(self): """Test save persist the project""" project = AppFactory.build() assert self.project_repo.get(project.id) is None self.project_repo.save(project) assert self.project_repo.get(project.id) == project, "Project not saved"
def test_save(self): """Test save persist the project""" project = AppFactory.build() assert self.project_repo.get(project.id) is None self.project_repo.save(project) assert self.project_repo.get( project.id) == project, "Project not saved"
def test_needs_password_empty_password_key(self, mock_signer): """Test needs_password returns false if the app has an empty password""" mock_signer.loads = lambda x: x app = AppFactory.build(info={'passwd_hash': None}) assert app.needs_password() is False
def test_needs_password_no_password_key(self): """Test needs_password returns false if the app has not a password""" app = AppFactory.build(info={}) assert app.needs_password() is False
def test_check_password_bad_password(self, mock_signer): mock_signer.loads = lambda x: x app = AppFactory.build(info={'passwd_hash': 'mypassword'}) assert not app.check_password('notmypassword')
def test_needs_password_with_password_key_and_value(self, mock_signer): """Test needs_password returns true if the app has a password""" mock_signer.loads = lambda x: x app = AppFactory.build(info={'passwd_hash': 'mypassword'}) assert app.needs_password() is True
def test_has_autoimporter_returns_true_if_autoimporter(self): autoimporter = {'type': 'csv', 'csv_url': 'http://fakeurl.com'} app = AppFactory.build(info={'autoimporter': autoimporter}) assert app.has_autoimporter() is True
def test_has_autoimporter_returns_false_if_no_autoimporter(self): app = AppFactory.build(info={}) assert app.has_autoimporter() is False
def test_get_autoimporter_returns_autoimporter(self): autoimporter = {'type': 'csv', 'csv_url': 'http://fakeurl.com'} app = AppFactory.build(info={'autoimporter': autoimporter}) assert app.get_autoimporter() == autoimporter, app.get_autoimporter()