How to use load_fixtures_from_file method in Lemoncheesecake

Best Python code snippet using lemoncheesecake

fixture.py

Source:fixture.py Github

copy

Full Screen

...318 sym = getattr(mod, sym_name)319 if hasattr(sym, "_lccfixtureinfo"):320 fixtures.extend(load_fixtures_from_func(sym))321 return fixtures322def load_fixtures_from_file(filename):323 # type: (str) -> List[Fixture]324 """325 Load fixtures from a given file.326 """327 try:328 mod = import_module(filename)329 except ModuleImportError as e:330 raise FixtureLoadingError(str(e))331 return load_fixtures_from_module(mod)332def load_fixtures_from_files(patterns, excluding=[]):333 # type: (Any[str, Sequence[str]], Any[str, Sequence[str]]) -> List[Fixture]334 """335 Load fixtures from files.336 :param patterns: a mandatory list (a simple string can also be used instead of a single element list)337 of files to import; the wildcard '*' character can be used338 :param excluding: an optional list (a simple string can also be used instead of a single element list)339 of elements to exclude from the expanded list of files to import340 Example::341 load_fixtures_from_files("test_*.py")342 """343 fixtures = []344 for file in get_matching_files(patterns, excluding):345 fixtures.extend(load_fixtures_from_file(file))346 return fixtures347def load_fixtures_from_directory(dir):348 # type: (str) -> List[Fixture]349 """350 Load fixtures from a given directory (not recursive).351 """352 fixtures = []353 for file in get_py_files_from_dir(dir):354 fixtures.extend(load_fixtures_from_file(file))...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

...27 return json.loads(rv.data)['access_token']28 def test_get_oauth2_token(self):29 token = self.get_oauth2_token()30 self.assertIsNotNone(token)31def load_fixtures_from_file(fixtures):32 """33 :param fixtures:34 :return:35 """36 fixtures_dirs = current_app.config['FIXTURES_DIRS']37 if not isinstance(fixtures, list):38 _fixtures = [fixtures]39 else:40 _fixtures = fixtures41 for filename in _fixtures:42 for directory in fixtures_dirs:43 filepath = os.path.join(directory, filename)44 if os.path.exists(filepath):45 # TODO load the data into the database...

Full Screen

Full Screen

test_user.py

Source:test_user.py Github

copy

Full Screen

...11 rv = self.client.get(url_for('api.users_self'), headers={'Authorization': 'Bearer ' + token})12 self.assert200(rv)13class UserModelTest(BaseTestCase):14 def test_followed_by(self):15 load_fixtures_from_file(['user_relations.json'])16 user = User.query.filter_by(email='yoophi@gmail.com').first()17 user_a = User.query.filter_by(email='a@gmail.com').first()18 user_b = User.query.filter_by(email='b@gmail.com').first()19 for u in [user, user_a, user_b]:20 self.assertIsNotNone(u)21 self.assertEqual(0, len(user.followed_by))22 self.assertEqual(0, len(user_a.follows))23 db.session.add(Relationship(user_id=user.id, followed_by_id=user_a.id))24 db.session.commit()25 self.assertEqual(1, len(user.followed_by))26 self.assertEqual(1, len(user_a.follows))27 db.session.add(Relationship(user_id=user.id, followed_by_id=user_b.id))28 db.session.commit()29 self.assertEqual(2, len(user.followed_by))...

Full Screen

Full Screen

test_load_fixtures_from_file.py

Source:test_load_fixtures_from_file.py Github

copy

Full Screen

...18 db.session.expunge_all()19 db.drop_all()20 pop_ctx()21 def test_load_fixtures_file_json(self):22 load_fixtures_from_file(db, 'authors.json', fixtures_dirs)23 assert Author.query.count() == 124 assert Book.query.count() == 325 def test_load_fixtures_file_json_abs(self):26 load_fixtures_from_file(db, 'myapp/fixtures/authors.json')27 assert Author.query.count() == 128 assert Book.query.count() == 329 def test_load_fixtures_file_yaml(self):30 load_fixtures_from_file(db, 'authors.yaml', fixtures_dirs)31 assert Author.query.count() == 1...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Lemoncheesecake automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful