Best Python code snippet using assertpy_python
test_BR.py
Source:test_BR.py
...15 with open('parsers/test/mocks/BR.html') as f:16 self.fake_data = json.load(f)17 with patch('parsers.BR.get_data', return_value = self.fake_data) as gd:18 self.data = BR.fetch_production('BR-CS')19 def test_is_not_none(self):20 data = self.data21 self.assertIsNotNone(data)22 def test_hydro_merge(self):23 """Check that hydro keys correctly merge into one."""24 data = self.data25 self.assertEqual(data['production']['hydro'], 35888.05363)26 def test_wind(self):27 data = self.data28 self.assertEqual(data['production']['wind'], 4.2)29 def test_correct_datetime(self):30 data = self.data31 expected_dt = get("2018-01-27T20:19:00-02:00").datetime32 self.assertEqual(data['datetime'], expected_dt)33 def test_source(self):34 data = self.data35 self.assertEqual(data['source'], 'ons.org.br')36 def test_zoneKey_match(self):37 data = self.data38 self.assertEqual(data['zoneKey'], 'BR-CS')39 def test_storage_type(self):40 data = self.data41 self.assertIsInstance(data['storage'], dict)42class ExchangeTestcase(unittest.TestCase):43 """44 Tests for fetch_exchange.45 Patches in a fake response from the data source to allow repeatable testing.46 """47 def setUp(self):48 with open('parsers/test/mocks/BR.html') as f:49 self.fake_data = json.load(f)50 with patch('parsers.BR.get_data', return_value = self.fake_data) as gd:51 self.data = BR.fetch_exchange('BR-S', 'UY')52 def test_is_not_none(self):53 data = self.data54 self.assertIsNotNone(data)55 def test_key_match(self):56 data = self.data57 self.assertEqual(data['sortedZoneKeys'], 'BR-S->UY')58 def test_correct_datetime(self):59 data = self.data60 expected_dt = get("2018-01-27T20:19:00-02:00").datetime61 self.assertEqual(data['datetime'], expected_dt)62 def test_flow(self):63 data = self.data64 self.assertEqual(data['netFlow'], 14.0)65 def test_source(self):66 data = self.data67 self.assertEqual(data['source'], 'ons.org.br')68class RegionTestcase(unittest.TestCase):69 """70 Tests for fetch_region_exchange.71 Patches in a fake response from the data source to allow repeatable testing.72 """73 def setUp(self):74 with open('parsers/test/mocks/BR.html') as f:75 self.fake_data = json.load(f)76 with patch('parsers.BR.get_data', return_value = self.fake_data) as gd:77 self.data = BR.fetch_region_exchange('BR-N', 'BR-NE')78 def test_is_not_none(self):79 data = self.data80 self.assertIsNotNone(data)81 def test_key_match(self):82 data = self.data83 self.assertEqual(data['sortedZoneKeys'], 'BR-N->BR-NE')84 def test_correct_datetime(self):85 data = self.data86 expected_dt = get("2018-01-27T20:19:00-02:00").datetime87 self.assertEqual(data['datetime'], expected_dt)88 def test_flow(self):89 data = self.data90 self.assertEqual(data['netFlow'], 2967.768)91 def test_source(self):92 data = self.data...
tests.py
Source:tests.py
1from django.test import TestCase2from .models import User3class UserTests(TestCase):4 def test_is_not_none(self):5 user = User.objects.create("test@test.com", "123")6 self.assertIs(user is not None, True)7 return user8 def test_is_not_admin(self):9 user = self.test_is_not_none()...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!