How to use test_bad_config method in Molotov

Best Python code snippet using molotov_python

test_badconfigs_rc2.py

Source: test_badconfigs_rc2.py Github

copy

Full Screen

1import unittest2import os3import tempfile4import yaml5import supreme6import supreme_test_base7class BadConfigTestCase(supreme_test_base.SupremeTestBase):8 """9 Tests for giving bad configs.10 """11 def _write_dict_as_yaml(self, filename, out_dict):12 with open(filename, 'w') as f:13 yaml.dump(out_dict, stream=f)14 @property15 def _minimal_config_dict(self):16 return {'outbase': 'test',17 'map_types': {'exptime': ['sum']}}18 def test_no_mandatory(self):19 """20 Test if we are missing mandatory fields.21 """22 self.test_dir = tempfile.mkdtemp(dir='./​', prefix='TestPatchHsc-')23 test_file = os.path.join(self.test_dir, 'test_bad_config.yml')24 config_dict = {}25 self._write_dict_as_yaml(test_file, config_dict)26 self.assertRaises(TypeError, supreme.Configuration.load_yaml, test_file)27 config_dict = {'outbase': 'test'}28 self._write_dict_as_yaml(test_file, config_dict)29 self.assertRaises(TypeError, supreme.Configuration.load_yaml, test_file)30 config_dict = {'map_types': {'exptime': ['sum']}}31 self._write_dict_as_yaml(test_file, config_dict)32 self.assertRaises(TypeError, supreme.Configuration.load_yaml, test_file)33 def test_bad_nside(self):34 """35 Test if we give a bad nside36 """37 self.test_dir = tempfile.mkdtemp(dir='./​', prefix='TestPatchHsc-')38 test_file = os.path.join(self.test_dir, 'test_bad_config.yml')39 config_dict = self._minimal_config_dict40 config_dict['nside'] = 041 self._write_dict_as_yaml(test_file, config_dict)42 self.assertRaises(RuntimeError, supreme.Configuration.load_yaml, test_file)43 config_dict['nside'] = 102544 self._write_dict_as_yaml(test_file, config_dict)45 self.assertRaises(RuntimeError, supreme.Configuration.load_yaml, test_file)46 def test_bad_map_type(self):47 """48 Test if we give a bad map type49 """50 self.test_dir = tempfile.mkdtemp(dir='./​', prefix='TestPatchHsc-')51 test_file = os.path.join(self.test_dir, 'test_bad_config.yml')52 config_dict = self._minimal_config_dict53 config_dict['map_types'] = {'blah': ['sum']}54 self._write_dict_as_yaml(test_file, config_dict)55 self.assertRaises(RuntimeError, supreme.Configuration.load_yaml, test_file)56 def test_bad_map_operation(self):57 """58 Test if we give a bad map operation59 """60 self.test_dir = tempfile.mkdtemp(dir='./​', prefix='TestPatchHsc-')61 test_file = os.path.join(self.test_dir, 'test_bad_config.yml')62 config_dict = self._minimal_config_dict63 config_dict['map_types'] = {'exptime': ['blah']}64 self._write_dict_as_yaml(test_file, config_dict)65 self.assertRaises(RuntimeError, supreme.Configuration.load_yaml, test_file)66if __name__ == '__main__':...

Full Screen

Full Screen

test_config_reader.py

Source: test_config_reader.py Github

copy

Full Screen

1import json2import os3from marshmallow import ValidationError4import pytest5from parallelagram.config_parser import read_config6class TestReadConfig:7 test_filepath = 'test-config.json'8 test_bad_config = 'test-bad-config.json'9 def setup_class(self):10 from tests.unit.conftest import good_config, bad_config11 with open(self.test_filepath, 'w') as out:12 json.dump(good_config, out)13 with open(self.test_bad_config, 'w') as out:14 json.dump(bad_config, out)15 @staticmethod16 def remove_file(path: str):17 try:18 os.remove(path)19 except FileNotFoundError:20 pass21 def teardown_class(self):22 self.remove_file(self.test_filepath)23 self.remove_file(self.test_bad_config)24 def test_read(self, mock_config):25 data = read_config(self.test_filepath)26 assert len(data.lambdas) == 127 lambdas = mock_config.get('lambdas')[0]28 assert data.lambdas[0].code_path == lambdas.get('code_path')29 assert data.lambdas[0].dynamo_response_table == lambdas.get('dynamo_response_table')30 assert data.lambdas[0].lambda_name == lambdas.get('lambda_name')31 assert data.lambdas[0].s3_request_bucket == lambdas.get('s3_request_bucket')32 assert data.lambdas[0].s3_response_bucket == lambdas.get('s3_response_bucket')33 def test_throws_validation_error(self):34 with pytest.raises(ValidationError):...

Full Screen

Full Screen

test_config.py

Source: test_config.py Github

copy

Full Screen

...7class TestMMConfig(unittest.TestCase):8 def setUp(self):9 self.real_config = MMConfig("./​test_config.cfg")10 #pp.pprint(self.real_config.cfg.dict)11 def test_bad_config(self):12 self.assertRaises( NoConfigFile, lambda : MMConfig("/​fake/​stuff/​here") )13 def test_no_set(self):14 def myf(): self.real_config['bad'] = 'change'15 self.assertRaises( ConfigAccessViolation, myf )16 def test_copying(self):17 k = 'list_value_testing'18 mycopy = self.real_config[k]19 mycopy.append("another element")20 self.assertTrue( len(mycopy) , len(self.real_config[k]) + 1 )...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Why Agile Teams Have to Understand How to Analyze and Make adjustments

How do we acquire knowledge? This is one of the seemingly basic but critical questions you and your team members must ask and consider. We are experts; therefore, we understand why we study and what we should learn. However, many of us do not give enough thought to how we learn.

How to increase and maintain team motivation

The best agile teams are built from people who work together as one unit, where each team member has both the technical and the personal skills to allow the team to become self-organized, cross-functional, and self-motivated. These are all big words that I hear in almost every agile project. Still, the criteria to make a fantastic agile team are practically impossible to achieve without one major factor: motivation towards a common goal.

Dec’22 Updates: The All-New LT Browser 2.0, XCUI App Automation with HyperExecute, And More!

Greetings folks! With the new year finally upon us, we’re excited to announce a collection of brand-new product updates. At LambdaTest, we strive to provide you with a comprehensive test orchestration and execution platform to ensure the ultimate web and mobile experience.

How To Get Started With Cypress Debugging

One of the most important tasks of a software developer is not just writing code fast; it is the ability to find what causes errors and bugs whenever you encounter one and the ability to solve them quickly.

How to Recognize and Hire Top QA / DevOps Engineers

With the rising demand for new services and technologies in the IT, manufacturing, healthcare, and financial sector, QA/ DevOps engineering has become the most important part of software companies. Below is a list of some characteristics to look for when interviewing a potential candidate.

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 Molotov 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